I am using a non open source library for working with images. This library relies on JAI (jai_imageio.jar) for JPEG2000 image type. In a stand-alone program things work just fine and JPEG2000 images are processed correctly. However, when these two JARs are deployed to Tomcat within a WAR the required JAI class(es) are not found. Furthermore, if I place jai_imageio.jar in $CATALINA_HOME/lib the JAI class is found and things work correctly.
The vendor tells me they locate the required class as follows:
Iterator iter = ImageIO.getImageReadersByFormatName("JPEG2000");
My theory here is that because ImageIO is part of the JRE the classloader being used is the "Common" classloader rather than the one for the WAR. For this reason the JAR within the WAR is not found but the one in the Tomcat lib directory is. Does this sound right or is something else going on?
I would prefer not to deploy the JAI JAR to the Tomcat lib directory; I want to release it as part of the WAR. Is there a way around this class loading issue? As I mentioned, I don't have access to the source. I may be able to ask for some change to facilitate WAR deployment but I'm not sure what that might be, perhaps a method to set the reader but this seems kludgy.
I appreciate feedback on any part of this. Thanks.
Related
When trying to run my webapplication in both an embedded jetty (locally) and a 'normal' jetty instance (remotely), I think I encounter some class collision.
java.lang.ClassCastException:
org.keycloak.adapters.RefreshableKeycloakSecurityContext cannot be cast to org.keycloak.KeycloakSecurityContext
The class KeycloakSecurityContext is both defined in the keycloak-jetty-adapter dependency and in the keycloak-core dependency in my project. (same version, 3.4.3 Final)
I've tried using scope 'provided' on the adapter or excluding the keycloak-core dependency from my adapter, but to no effect.
Any suggestions how to handle this combination?
I had similar issues with Keycloak. You need to make sure that libraries are not duplicated.
You download from Keycloak the adapters and place them under tomcat/lib in tomcat/wildfly.
In pom.xml you need to specify the tag without versions. This will make sure that "dependencies that are required for compiling the project code, but that will be provided at runtime by a container running the code".
(For IntelliJ) To make sure that your project can import Keycloak specific classes you need add them into your project. So CTRL+Shift+Alt+S -> under libraries you need to add the same jars you added at point 1.
For me I had to add the scope provided on the keycloak-core maven dependency. It corrected the error.
I am currently trying to basically expose a native C++ library, that I not have the code for, as a WebApi. To do that, I created a managed C++ wrapper library, that allows my web application to communicate with the native code.
So the dependencies of the project look something like this:
Web application (ASP.NET)
Managed C++ Wrapper
Native C++ Library (DLL)
Native Dependencies (DLLs)
My problem is now, that I always get the error message "Could not load file or assembly [ManagedWrapper.dll] or one of its dependencies. The specified module could not be found."
Since the managed wrapper library is in the same solution, it is listed as reference and even copied to the shadow copies, so I assume that the problem lies in the native dependencies. I am well aware that there are problems with loading native DLLs in ASP.NET as no shadow copies will be made of them and they can not be added to the GAC. I tried to tackle this problem by just adding them to my %PATH%, but the error still remains. Dependency walker did not show any additional dependencies and adding the native DLLs to system32/inetsvr fixed the problem, but this is obviously not the way this should be done.
So here my question: What could be the reason that the PATH variable is not working? (And is there maybe another way to get this to work?)
Using loadLibrary to load with an absolute path is not really a possible solution as I have no influence on the native C++ library and how it will load further dependencies.
I think I found my own a solution to my problem and hope this might help someone else as well:
My native DLLs where somewhere in my home folder. Moving them to a more accessible place, i.e. C:\temp\, and adding this folder to the path seemed to do the trick. My guess is, that this was a permission based problem, even though I added rights for IUSR for that folder in my home directory before.
I have an application that I could deploy on other machines (Visual Studio). I added the module QtMultimedia to use the QSound class.
Wanting redeploy my app, the executable indicates me first that I need Qt5Multimedia.dll then Qt5Network.dll (which I have not added in my project).
Now my application doesn't launch, but no error message, I do not understand ...
I did not find much on the internet.
First of all - use dependency walker to list all the dependencies and make sure you have all the required dlls right besides the binary.
Next, make sure you've copied all the required plugins to the appropriate plugin folder besides the binary. In particulary take a look at plugins/audio/qtaudio_windows.dll, I think you might need to deploy it.
Also a good way to check what you app uses is to use process explorer on the machine you have no troubles on to check all the dlls it uses when the app is running.
I finally found !
First I need to go in the folder of my exe
Then use : "windeployqt.exe ." (whithout the quotes).
That add all I need to execute my exe. :)
I am currently working on a Windows desktop application that uses JNI to call methods located inside a jar file.
I need to know the best way to package my application so that it can link to jvm.dll. I am not sure if I should package all the binaries found inside the JDK's bin directory into my setup file (not sure if I am allowed to do so)?
The problem is all examples found online links directly the jvm.dll found in the JDK installation path. And since my application is a commercial one, I cannot rely or ask that every user should install the JDK along side my app because that would be ridiculous.
Please can someone clarify the best method to package such application?
Regards
jvm.dll is also installed with the normal java runtime (bin/client subdirectory). By checking some registry values, you can find the path to it, load it from there and check whether the correct version is installed. If you have already linked jvm.lib, you'll then need to add jvm.dll to the list of delay loaded dlls, so you can load it at runtime.
See my recent answer to another question for details:
https://stackoverflow.com/a/14434203/93652
I use leiningen to manage my clojure project and I want to copy jar file along with some other files into a certain directory as a final part of a build process. Leiningen treats 'resources' as something which should be included into the jar file, and it is unacceptable for me. If I used maven, I could configure it for such task using maven-resource-plugin or fall back to Ant using maven-antrun-plugin, but leiningen is far more convenient tool for clojure projects.
Strangely, I couldn't manage to find anything about similar functionality in leiningen on the internet. This is curious, because one of major clojure applications is web sites, and web sites usually do not include their resources (js, css, etc) into the jar (or do they? That would be weird since slight css tweak will require rather lenghty recompilation). It comes naturally that we have to prepare site environment (copy static resources along with jar bundle into some directory layout), and this task should be done by the build tool.
Is there a plugin to copy files around the filesystem (or something which could substitute it, like running Ant), or I must write one myself? Right now I'm using shell scripts, but it is very inconvenient since I had to run several commands instead of one, and also it is unportable.
did you checkout lein-resource?
in any case. here is a long list of available plugins for lein, maybe you will fine some of them helpful