I have a web application running in Tomcat on Linux. My webapp uses a third party jar, and the jar uses a native library.
Whenever I redeploy my application, Tomcat notices the new war file and reloads my application. However, it apparently doesn't unload the previous version, and when I try to execute code that uses the jar, I get this error:
java.lang.UnsatisfiedLinkError: Native Library /var/cache/tomcat7/temp/libaocr_x64.so already loaded in another classloader
If I restart the entire Tomcat process, I can clear the error, but I would prefer not to do that.
What is causing Tomcat to not release the old version of the app?
I'm aware that this kind of problem is sometimes caused by connection pools that have threads running to monitor connections -- I have a connection in my app, but I don't think it's configured to have this kind of thread running.
Thanks,
Frank
JNI is so low-level that it is outside of Tomcats Container. Unfortunately You can not unload the librarys.
Try to put the jar into tomcat's endorsed-folder ($CATALINA_HOME/commons/endorsed) but it will be available for each app in the tomcat.
Related
I am coding my basic servlet programs in notepad but every time I make changes in my java file and after compiling it, I need to restart my tomcat apache to see that changes on browser. Is there any solution for this as I have to work on project and will need changes frequently.
I have tried making service automatic from services manager.
The changes made in Servlet/Java code will not reflect itself, we have to re-compile the Java code and again deploy the application to the Tomcat server. Only after these work server will be able to get the modified values.
If you don't want to do it manually then you can set reloadable="true" in the context.xml file. Now Catalina (tomcat server) will monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.
I need to undeploy a library deployed on my weblogic domain but first I should undeploy all deployed applications reference to this library. this is very hard to do even in the script it will take a lot of time
do you have any way to undeploy the library without affecting any dependent application
I found this post WebLogic Application redeployment using shared libraries - without downtime which may save some time than redeploying all referencing applications, though it's not the direct answer to this question.
We have two web applications developed using Spring and Hibernate. We have deployed these two applications on Tomcat 7. Sometimes these applications are running fine if we don't access both applications. Sometimes it is giving some exceptions if the both the applications are accessed at the same time.
Ex: java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser.
Whichever the application we have accessed first works fine but second one doesn't work.
We are sure that we can run n number of applications on server.
Answering your actual question,
Is it possible to run multiple web application on the same port in tomcat 7?
Yes, it is. Tomcat can run multiple web applications on a single port. The default Tomcat port number is 8080.
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
Something else is causing this error.
Multiple web applications running on the tomcat, on the same port will
not create problem unless and until each others context-path is
overridden.
From the exception it is clear that one of the web-application is not correctly configured to access the required jar. You can copy the required jars to Tomcat/libs, e.g on windows the path is "C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\lib".
Jars in $Tomcat/lib directory are visible to all the deployed web-apps. Reference: Difference between keeping jar files in WAR and Tomcat lib folder
Feel free to comment out for further help.
I export my maven java project in Eclipse to War file.
On the server, I open the manager of tomact and add the war application, but when I run the application it seems the application isn't running (or some problem with the resources).
From the other hand, when I start the tomcat by the startup.bat in the tomcat folder and add the War to the webapps folder, it is working. But if I logoff the server , I cannot connect the application remotly. The server is shut down. Why?
What can be the problems?
Thanks!
Me
Why is your application not running? Well - if there's a specific reason for it (and the manager application works) you will see it in the logfile - e.g. tomcat's log/catalina.out. Check it or give us a snippet of the error messages in there if you don't understand them.
I like to recommend not to use the manager application, rather deploy through the OS or any other maintenance tool (e.g. scripted). This typically results in a better maintainable system. As it already works well for you when you just add your WAR file to the webapps directory, everything seems well. Introducing a manager application in production just provides another means to attack your site - and I frequently see those applications poorly maintained (and the passwords poorly chosen & protected)
When you start tomcat with startup.bat, it will run the server process in a console window. This console process will be shut down when you log out. In order to have tomcat running even when you're not logged in (and in order for it to start automatically), you'll have to install it as a service. There's plenty of information on the internet on how to do this - should be extremely easy to find.
Why do we use external tomcat server while working in the industry though there is support for the server in the Eclipse?
Previously I was using the server integrated with the eclipse itself. But now as a part of the industry I've started using the external tomcat server.
The reason we use external server during development is that the server integrated with Eclipse works most of the time but not all of the time. This you will notice when there are multiple number of web application being deployed as part of the development in your Eclipse and you start and stop Tomcat a number of times to refresh web applications in rapid succession. The problems that can happen are:
1) Source/WAR files updated but deployed application does not update
2) Tomcat throws exception during start within Eclipse
3) A web context becomes unavailable from within eclipse
all the above are not limitations of either eclipse or tomcat, since we change the deployables in rapid succession, sometimes the WAR files get corrupted while exporting or old remnants of previously deployed files remain within tomcat work/localhost directory.
In general this kind of errors become difficult to determine. the best way to avoid them is to have a separate tomcat and export the WAR to the webapp directory, even then it is good to clear the work/localhost directory from time to time.