I'm developing an enterprise project with Liferay 6.1 EE and tomcat 6. Coding is in local PC, but deploy to a CentOS virtual machine.
There's a custom .jar file to handle some special logic with URL redirecting. After I modified a Java class, recompile and built the new .jar, replaced the existing .jar file on the vm. (located in {$tomcat}/lib/ext and {$tomcat}/webapps/ROOT/WEB-INF/lib) and restarted tomcat, I found it was still using the previous code logic. I'm sure that the .jar file was updated on VM (grabbed from VM, and decompiled the .class, the code was there)
This class is instantiated by Class.forName().newInstance method, and put to a static final map in another custom filter.
Clearing {$tomcat}/temp and {$tomcat}/work folders didn't help, is it possible that this stale class is cached in JVM ? If yes how can I remove the stale content ?
Any insight is appreciated.
Related
I am doing development of a web app with Java. My current process is to export the project as a WAR to the Tomcat folder, where it picks it up and reloads the WAR. I wait for it to run through its startup process and away it goes.
I would like to make it not need to do an entire reload when it isn't necessary. If I'm making a small change to a single class, perhaps it could reload just that class. If I'm changing static content, perhaps it could just send that HTML file or JS file.
How can I achieve this? My only real dealbreakers is that I need a solution that works with Eclipse. I'd even consider a different container than Tomcat, although it's where I'm familiar.
You can hot reload/deploy your application inside Eclipse , but for seperate Tomcat server , I don't think hot reload is possible .
For Eclipse
For eclipse , you can follow the instructions in this link https://mkyong.com/eclipse/how-to-configure-hot-deploy-in-eclipse/
This will speed up your development , but it has it's limitations
Hot deploy will support the code changes in the method implementation only. If you add a new class or a new method, restart is still required.
For Tomcat
I haven't tried it , but all the class files of war will be loaded/rendered from binary memory of Tomcat . So try changing the class files in that location(Not sure about the path of binary class folder ) .
But if you want to render static HTML,js and css from tomcat server , it can be easily done adding another folder inside "webapps" folder (eg : /webappps/static)
We are using YAJSW to wrap our Java application as a Windows Service. While testing workstation images there is a warning from the corporate McAfee Antivirus because on launching the service, the jnidispatch.dll is copied from the jna-4.1.0.jar to a new name in a temporary folder.
Adding the dll signature to the antivirus rules prevents a showstopping error but a severe warning pops up every time.
We tried copying the jnidispath.dll to C:\DLLfolder and adding to wrapper.conf the line:
wrapper.java.additional.4 = -Djna.boot.library.path=C:/DLLfolder/
We then added C:\DLLfolder to the Windows System %PATH% and rebooted Windows.
However when monitoring the Windows Service start, we can still see the DLL being extracted from the Jar instead and the antivirus complains.
The comments in the YAJSW code native.java say:
When JNA classes are loaded, the native shared library (jnidispatch) is
loaded as well. An attempt is made to load it from the any paths defined
in <code>jna.boot.library.path</code> (if defined), then the system library
path using {#link System#loadLibrary}, unless <code>jna.nosys=true</code>.
If not found, the appropriate library will be extracted from the class path
(into a temporary directory if found within a jar file) and loaded from
there, unless <code>jna.noclasspath=true</code>.
What step are we missing?
I confirm we resolved with the following actions:
1) added -Djna.nounpack=true to wrapper.conf
2) deleted the 2 jnidispatch.dll 32-bit and 64-bit DLLs from the JAR
3) Placed the DLLs on the Windows path
Please note to install the Windows Service, the jnidispatch.dll is required.
Big thanks to technomage!
I need to work on an existing java servlet project (tomcat 7). it's the first time to me to work on an existing project that other developers worked on before.
What I have, are the .class files, configs (web.xml and and all the resources) on the server. I can access to them. but my client asked me to work on that files in order to solve bugs and to develop additional features.
I want to work with eclipse so that I can import .java classes files (through decompiler tools, I aready have) and perform those changes my client needs.
my question is:
once I re-create the environment (new eclipse dynamic project with the existing/[on server] file classes .java on my local pc), can I overwrite the .class files once compiled and tested in order to perform changes that my client needs (with tomcat restarted)?
do you have alternatives in order to proceed with developing new features/resolve bugs and deploy the project into the existing/running remote tomcat server without complications?
thanks in advance
I am trying to deploy a WAR file on weblogic server.
This is a simple java application.
I am new to this and experimenting.
JRE: 1.5.0_41, OS: redhat 5.8, Weblogic: WebLogic Server 10.0 MP2
The contents just include a jsp file and a java file (jsp inside jsp folder and java class inside WEB-INF\classes folder and correct package structure). I am using this java util file inside the jsp for some common utility methods.
However, when I deploy the WAR, it gives me NoClassDefinitionFoundError for this java utility class.
I have searched the threads and found that this exception points to some other inherent issue in the deployment. It also mentioned class path conflicts etc. I can understand this issue when it comes to using a class from an external JAR file, but could not understand how it fails to locate a file in the same context as that of the jsp.
How come the import statements in the jsp worked and the jsp got compiled and rendered and failed only when the part of accessing this object came into picture? (runtime problem maybe?)
Please educate me on this. My debugging efforts are still on. Thanks a lot, folks!!
[P.S.: Could it be because i compiled and built my source using eclipse setting 1.7 compliance and used it on a lesser JRE?]
For a war file classes is normally packaged inside WEB-INF/classes, not classes.
Given a remote JNLP which works (all jars are available etc) but you need to run a debug session on the code.
Is there any facility that easily allows you to create a local project in ANY reasonably modern IDE which consists of a local copy of the resources stated in the JNLP and can run said code in debug mode? Assume that a decompiler is available so it is just a matter of getting the debug session running.
Are there any IDE's (Eclipse, Netbeans, IntelliJ, JDeveloper, etc. etc. - even a commercial offering) which can do this just given the JNLP URL?
I have a pre-defined project in Eclipse which is blank except for a utility that parses a JNLP file and downloads all the jars specified in the jnlp codebase. Optionally, you can replace any jars with updated code you want to test here. It uses reflection to add all the jars to the classpath (which is a hack) and then reflectivly invokes the main method of the class specified as the main-class in the JNLP with any arguments.
Unfortunately I can't share the source for this but it only took me a day to get it running.
The class path hack is available here: How should I load Jars dynamically at runtime?
Should work well with any debugging.
I am facing a similar problem with a JNLP program. The only way I found to debug the program is by debugging into Eclipse (I have the project and the code source) and copy-pasting all parameters passed by the JNLP file in the Arguments tab into Debug configuration in Eclipse. I don't know if this is related because my problem came from the arguments passed to the application through JNLP file.
I don't understand something... Why you want to debug directly on the compiled code from the final location?