I have a web project with some native libraries. Most of them are loaded by JNA library.
I put them in this folder
WEB-INF\classes\*.dll
of a ROOT package.
When the application starts they are loaded by Tomcat in
${catalina.home}\webapps\ROOT\WEB-INF\classes\mylibrary.dll
All libraries are founded by JNA and work, however there is just one library managed by third parties (Zebra Multilink platform SDK) that I cannot load from that folder. Maybe because it doesn't work with JNA but with JNI.
If I move that libraries to
${catalina.home}\bin
that is the folder defined by java.library.path param in tomcat start command it works!
Can I distribute libraries in ROOT.war package and set tomcat to look into all my applications to find native libraries?
Well, you can modify java.library.path and let it point to the exploded webapp directory (your ${catalina.home}\webapps\ROOT\WEB-INF\classes\, but resolve ${catalina.home} yourself beforehands).
Related
I have a problem using waffle and tomcat 7 to enable login via windows authentication.
Everything is working fine but everytime I deploy the application, I get this error:
java.lang.UnsatisfiedLinkError: Native Library C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\work\Catalina\localhost\seedInventory\loader\com\sun\jna\win32-x86\jnidispatch.dll already loaded in another classloader
When I restart tomcat, it started working again. However, I want to be
able to deploy the application without restarting.
I see that this file jnidispatch.dll is still being used even after the undeploy and I can't delete it manually.
What could I do?
Take a look at Apache Tomcat HowTo section about classloader problems when using JNI under Tomcat. It says, that:
The important thing to know about using JNI under Tomcat is that one cannot place the native libraries OR their JNI interfaces under the WEB-INF/lib or WEB-INF/classes directories of a web application and expect to be able to reload the webapp without restarting the server.
So, it seems, that some of your libraries contains a native jnidispatch.dll lib, which you should move out of jar or war into Tomcat's lib folder, to make it possible to redeploy you application.
I successfully introduced xuggle in my tomcat environment and it worked perfectly.
Than something happens , and from that moment on, any time my thumbnail generator is called ( is the class that uses xuggle the most) i got the
*java.lang.UnsatisfiedLinkError: Native Library /usr/local/xuggler/lib/libxuggle-xuggler.so.3.4.1012 already loaded in another classloader* exception.
The only way I have to fix it is by restarting tomcat.
Since I can't reproduce the error nor on my laptop, I really appreciate a little help.
This happens probably because you have the Xuggler Jars in a webapp lib directory, and it needs to be at the CATALINA_ROOT directory. See the Xuggler FAQ for details. Stop tomcat, move the Xuggler jar files to the ${CATALINA_HOME}/shared/lib directory and restart tomcat and all should be OK.
If you can't reproduce the same problem on other devices, try to check if your system classpath has entry for this specific jar file because in usual tomcat configuration, system classpath is added along-with lib jar files.
I'm a beginner java developer and i'm not very confident with java world tools.
i'm using eclipse helios, jsdk 1.5, axis2 plugin and tomcat 6.0.29 on windows to port a very old webservice , preaviosuly deployed on a websphere.
I've added a tomcat server to my eclipse project, when i start the server i get the following message : the APR based Apache Tomcat Native library ... etc ... was not found on the java.library.path .
How do i change that variable (or any environment variable in general ) from inside eclipse ?
Then i've another problem i don't know if can be solved with some kind of configuration : i must use some third party .class library grouped togheter into a zip file. I've added the zip to the shared.loader property of the tomcat catalina.properties file and my project can't see them. If i rename the .zip file to .jar everything works fine . How can i use classes inside zip file without renaming it to jar ?
thank you in advance
A Jar is based on the same format as that of Zip. All the third party classes are bundled as Jars (Java Archives) and should be used like that instead of Zip. So if you happen to have a zip housing your classes you should rename it to jar as per java's conventions.
You can check where java.library.path variable is pointing to? using System.getProperty("java.library.path"); and see if the native libs are present in there..you should use the jar instead as its the standard format for archiving java class files
when i start the server i get the following message : the APR based Apache Tomcat Native library ... etc ... was not found on the java.library.path
The exact message is:
INFO: The APR based Apache Tomcat Native library which
allows optimal performance in production environments
was not found on the java.library.path
As you can see, the message is logged as INFO and the easiest thing would be to ignore it, especially in a development environment. But if want to make things more complicated, go to the Apache Portable Runtime (APR) based Native library for Tomcat and follow the install instructions.
(...) I've added the zip to the shared.loader property of the tomcat catalina.properties file and my project can't see them. If i rename the .zip file to .jar everything works fine . How can i use classes inside zip file without renaming it to jar?
In other words, using a (standard) *.jar worked, but a *.zip didn't. I'm tempted to answer: use a .jar extension.
I have made a Java Applet that depends on some third party libriaries as well as a DLL that is called via JNI. These will obviously not be installed on clients computers. Is there anyway to package these third party libriaries and external DLLs within my Applet's JAR so that it can be run by any client with a base Java install?
Using JNI within a web application is a recipe for heartburn, particularly in Windows.
You obviously can't deploy the DLL within your WAR file and will probably require a separate installer be run by the deployer beforehand.
You'll have to ensure that your java.library.path is setup correctly, which is usually done by settings in the application server rather than something deployable in the WAR file.
The way that JNI links the native class with the library will cause class loader headaches if you try to run more than one instance of that web application. One way to work around this is to move the containing JAR file into a shared class loader (like Tomcat's common folder) but that has its own complications.
Is there anyway to package these third
party libriaries
In Eclipse, under the Java project properties (right click), I can do a:
Export... => Export as Runnable JAR
Then I tell it to pack my jar dependencies into that exported JAR.
The exported JAR will have all its dependencies packed into it.
alt text http://www.ubuntu-pics.de/bild/97131/selection_016_mg6IDm.png
I am no expert on the topic, but there are working solutions to all these problems. They might give you a headache, but some things can only be done this ways (and I am quite sure that your problem with the Entrust CSP is one of those).
You can take a look at OpenSign from the OpenOCES-project. The magic happens in org.openoces.opensign.client.applet.bootstrap.
I also believe that JNLPAppletLauncher solves the same problem, but I have no experience with i.
I earlier got to create a simple RESTful webservice on my localhost using Eclipse IDE, Tomcat, and JAX-RS libraries.
I am now trying to move the same on to a different unix server which has Tomcat installed. I am not knowing how to get started as in what is equivalent to creating a "Dynamic Web Project" that I do in Eclipse. Do I need to just create a directory myself with all the sub-directories as created by Eclipse? Should this directory be placed in webapps folder in Tomcat container. Should META-INF and WEB-INF also be created by myself?
Where should I put my Java classes?
Can somebody please clarify this or direct me to any documentation about the same.
You need to package your application in a WAR file.
The Sun Java EE 6 Tutorial has a chapter deciated to packaging.
It's pretty easy to export a web application as a war in Eclipse.
Dynamic Web Project (right click) => Export => Web =>war file =>war export dialog
Creation of web application archive - WAR is the solution for your problem,
but take care about all libraries that you need there.
You can easily extract (unzip) WAR file content
and check your project structure and libraries needed
and they will be in WAR's WEB-INF/lib.
Make sure that both Tomcats are set same way,
make sure your code is all OS friendly (users, file paths, permissions)
Always write some test simple code that will run up on app start,
and check all dependencies and libs, system clock, outside world network communication, so you can trace it in web app console or logger easily.
regards