I need your help. I am facing unusual problem dealing with Tomcat classloader. I have a WAR and inside the WAR there's a third-party JAR that has native methods. The WAR successfully deployed in a development server for the first time and had been running for about 3 months.
Last week, I did some code refactoring and wanted to deploy the updated WAR, so I delete the old instance and deployed WAR. But now after the redeployment, I always face NoClassDefFoundError. I redeploy the WAR for several times, and the result is same, NoClassDefFoundError.
Oddly, when I deployed the updated WAR in my laptop also use Tomcat, it works fine. My co-worker also tried to deployed in his laptop using Tomcat, it works fine.
I had deleted files inside work directory, but still NoClassDefFoundError appeared. I had turn off the Tomcat, delete the instance on webapp folder, copy the updated WAR again in webapp folder, turn on Tomcat again, but still the error shows up.
What's wrong with the Tomcat in the development server?
You can only register a native library once in the lifetime of a JVM. I suspect that when you updated the WAR, it tried to register the native library again, that failed and that in turn lead to the NoClassDefFoundError. That a restart of the Tomcat server fixed it is consistent with this theory.
If you ship a WAR that contains a native library then the safest course is to restart Tomcat everytime you need to update the app.
Related
I need to create a local environment to deploy an EAR, which is currently in production.
By documentation, it needs:
Java EE 7
Oracle WebLogic 12.1.2
Maven
Installed everything fine and configured, but this is my first time with Java Enterprise and WebLogic. I downloaded WebLogic from the official website (the 12.1.3 version, which is the only one available for a development installation). Executed all scripts to create a local domain, realm and server. It starts fine.
So, I proceeded generating the EAR within the source code, using mvn ear:ear and created the package.
Connected to localhost:7001/console and logged in, went into the Deployments Control page and clicked in install button. Browsed the EAR and deployed without changing any default configuration. It leads me to an error:
java.io.FileNotFoundException: class path resource [env.properties] cannot be opened because it does not exist
I thought it was a file missing inside the EAR package, but I opened it with both Eclipse and WinRAR and the env.properties file is present, in the right path. So I tried deploying the EAR package that is currently in production, but it still gives this error.
At this point, I think it's some WebLogic configurations I missed. Am I right? Where should I eventually check?
I can NOT share any code snippet, I'm sorry.
We still have to understand if it's like this by choice, but the WAR file inside the EAR actually didn't have the properties file. It was sufficient opening it with WinRAR, put the file in the right path and re-deploy it.
So, just to say, WebLogic had no missing configurations. The downloadable development package seems to have everything configured.
How can I deploy a war file to Tomcat in exactly the same way Eclipse deploys to Tomcat, if I configured Tomcat in Eclipse?
Reason for asking is that when I deploy with Eclipse everything works fine (databse connection, log4j ect). But when I manually deploy the corresponding war file to the same Tomcat installation, none of my external resources like database connection, logging to files work!
You can add the external jars to $CATALINA_BASE/lib Read here
Common — This class loader contains additional classes that are made
visible to both Tomcat internal classes and to all web applications
I am using Tomcat 7.0.50 server.
How can I delete the tomcat cache memory without restarting the server?
You can find how to delete Tomcat Cache here
You can delete the "work" folder under Tomcat Home. Even if it does allow you to delete the folder while tomcat is running, I would guess it will cause troubles to your running site.
If your Tomcat installation is configured to have a ROOT directory for your webapp, you will have to find a path like
/tomcat/base-myapplication/webapps/ROOT/
which contains your deployed webapp.
Just delete everything inside, including sub directories META-INF, WEB-INF, VAADIN etc., and then re-deploy your webapp. This worked for me even with tomcat running, but it doesn't hurt to restart tomcat after deployment.
I have EAR file (which includes a WAR file and EJB jar file) was deployed on Web-Logic(10.3.6) successful.
Now, I have updated EAR file and I redeploy again follow steps: delete old files on the server and install new EAR file without restart server. Every file have been deployed in Active state. But I got some exception related EJB injection. Then I restart Web-logic, my app is running fine.
What's wrong with the redeploy way?
Thanks in advance for any Help...
Weblogic has an lots of documentation about this topic. Sometimes it's referred to as a "hot deploy" or an "in-place" deploy. In the weblogic admin console there is an option to update an ear file rather than what you are doing with the delete->redeploy method.
Just make sure to update your Weblogic-Application-Version property in the MANIFEST.MF of your ear so that weblogic knows it's a new version. Here are some useful links:
Oracle redeploy documentation
An older but still valid list of steps to hot deploy
That said - the problem you are seeing may be something different and your question will need to be updated with more details if the Oracle docs don't help.
I am trying to fiddle with the gradle-tomcat-plugin and I am having some issues with some of the preliminaries. Assuming that my WAR is present in one of my folders, what do I need to do in order to run the war in an embedded tomcat using gradles tomcat plugin? The readme mentions the tomcatRunWar but I am a little lost as to how to use it in my gradle file
Any help would be appreciated.
Thanks
if you have set up everything right
go to your root directory (your build.gradle file should lie there), then execute
gradle tasks
and you should see tomcats different tasks
tomcatRun: Starts a Tomcat instance and deploys the exploded web
application to it.
tomcatRunWar: Starts a Tomcat instance and deploys
the WAR to it.
tomcatStop: Stops the Tomcat instance.
tomcatJasper:
Runs the JSP compiler (Jasper) and turns JSP pages into Java source
using.
and then you just run it
gradle tomcatRunWar
myself I prefer jetty plugin