WebLogic throws java.lang.ClassNotFoundException when I compile and deploy a change in my eclipse maven project - eclipse

I just started using Maven with eclipse and deployed my application to WebLogic.
When I do a clean install for the first time, my Maven project builds and deploys successfully.
After that, when I make any change to the source code or jsps, I do a pre-clean install to update the project. Now, everytime I do pre-clean install and restart WebLogic I get the following exception:
java.lang.ClassNotFoundException:
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
I did some researches and for some reasons, No one complained about that error before.
Any suggestion what can be the problem ?
This only occurs after I make a change and run "pre-clean install" from within eclipse.

When I do a clean install for the first time, my maven project builds and deploy successfully.
How is it deployed exactly? Do you use WTP and the Weblogic adapter? Do you use m2eclipse?
after that, when I make any change to the source code or jsps.. I do a pre-clean install to update the project.
Why do you run pre-clean? Do you have anything special bound to pre-clean (there is nothing bound to this phase by default). What is the expected result?
Now, everytime I do pre-clean install and restart weblogic I get the following exception:
What is FeatureForm, it it yours? Could this be something you removed that is still referenced by a temporary file generated by WebLogic (e.g. a Servlet generated for a JSP). Does the problem happen with this class only? Did you try to remove the work dir of WebLogic?
Any suggestion what can be the problem?
I'm not sure I'll be able to answer this question but you need to provide more details about your context and the way you use tools.

Related

Run JHipster SpringApplication via eclipse

I'm trying to run the JHipster application via my Eclipse Juno, using jdk 1.7.
The app seems to be loading properly (no console errors), but when i'm trying to reach the server with the client side (or via Postman, by sending a request to the REST servlets in port 8080), it's not responding.
However, when i'm running "mvn spring-boot:run" in the command shell, the server is loaded successfully and is responding to the exact same requests. Also, I managed to run the same command via eclipse with some maven configuration but it seems to be running only the target files (jars) and not the source code. I still haven't been able to run the source code of this app using eclipse in order to properly debug it.
Any suggestions?
Thanks!
So the answer is quite trivial, but since I spent several hours to reach it, it might save some time for others-
Download & install STS IDE.
Import the project as existing Maven project.
Run/Debug the project.
I tried to run it via Eclipse the whole time (wasn't familiar with STS to be honest) and this probably needs some extra configuration (another comment with explanations on eclipse configuration will be much appreciated). Once you work with STS, it's easy.
You should not need STS, just Eclipse with the J2EE stuff.
I've imported the sample jhipster in Eclipse (without STS) as a Maven project and everything was OK, after installing the maven dependencies.
To run the project, run as an application and search for the Application (com.mycompany.myapp.Application)
This app works for me: https://github.com/jhipster/jhipster-sample-app. It is stuck on Boot RC5 which probably means it's a bit old. Maybe Julien can comment on that (or update it)?

Is it possible to do Hotswapping of ATG classes

The deployment we follow is that we use runAssembler.bat to build an ear file and deploy it in a app server. We are using weblogic and jboss for testing purposes of the modules we built. However for every small change, we need to run runAssembler and build a new ear and deploy it in app server and restart the server.
I would like to find out if anyone figured out a way to do Hotswapping of class files which are generated by the code we write in ATG environment in either weblogic or jboss.
By attaching your IDE to your Application server on the Debug port it is generally possible to do hotswapping. Setting this up on Eclipse and JBoss is documented here, here and here. There is some information for setting it up in WebLogic here.
Attach your debugger, edit the java file, click 'save' and with hot code replacement in your IDE it should now update the running class file. In Eclipse it usually gives a popup if it was unable to do the sync. If you are using Eclipse, make sure the 'Build Automatically' flag under projects is ticked or you'll be waiting forever. I've not had any issues doing this via JBOSS (exploded ATG EAR) and variable success in doing this on WebSphere 7. It may also be prudent to make sure the same JAVAC you use to compile your build is the one loaded into your IDE compile path.
Another way to at least reduce the build/deploy time would be to deploy an unpacked/exploded EAR and simply copy your class files across (you could use the Eclipse FileSync plugin) and restart the server.
There are also some commercial options available, like JRebel
In our organization, we had good success in using DCEVM. It simply patches your JDK (in Windows: jvm.dll).
Download and patch your JDK
Launch your JBoss/Weblogic with the patched JDK
Set up Eclipse's Installed JRE's to point to patched JDK (restart and rebuild once)
Start the server, Launch debugger and connect
Ensure Eclipse's Debug view shows "Dynamic Code Evolution VM" (instead of something like "HotSpot VM")
Change your code, and voila!
You can do this with JRebel. After hotswapping you don't need to restart the server, only reload you deployment from Weblogic.

Eclipse juno deployment requires clean and build everytime

I have a web application developed in Eclipse Juno, I am using Tomcat 7.0.32 as a web server. When ever I'm doing small changes and deploying the application, changes are not taken by the tomcat.
Under Eclipse tomcat deploy path wtpwebapps, I have found the following:
Few/all JAR's given in the build path are missing
Recently compiled java files are not updated
These things led into ClassNotFoundException sometimes and Unexpected functionality sometimes.
So, when I do clean and build the project for small changes every time,deployment works fine. But clean and build takes more time
Is it a problem with eclipse deployment plug-in? Help me out to overcome, thanks

Eclipse Jboss processess

I have a couple of questions concerning the way Eclipse 4.3 and JBoss EAP 6.1 work together.
The first would be concerning the Server clean function. Does it matter if the server is running or not when that function is selected within Eclipse? I have tried both ways and get no indication one way or the other that it has preformed the task.
The other question concerns the hot deploy. I'm just starting a project so I have errors in my files, mostly the configuration files. Everything complies clean. When Eclipse deploys my war file it does so with something like 0.0.1-SNAPSHOT.war. It's always the same name so I can't tell if mu updates have been deployed.
The way I'm currently processing my deploys is to:
1. Undeploy the war file from within the Server Admin page
2. Do a Maven clean
3. Do a project clean
4. Do a war build
5. Redeploy from within the Server Admin page.
So this question would be how to determine if my current changes have been deployed? Is there a better way of doing it than the way I currently doing it?
Thanks for the support.
Since you are using Maven, you could use the Maven JBoss Deployment plugin. This would make the entire process automated. Sometimes the Eclipse integration doesn't work like you expect it to. Additionally, you should see on the JBoss command line console from where you started JBoss, that the old war is undeployed and deployed.

JUnit uses wrong Base64

I wanna use the class Base64 from commons-codec 1.5 and when I run the code on Server this works fine. My application runs on Websphere 7.0.
But when I run my JUnit tests the wrong Base64 Class is choosen, when i ask the Class with:
System.out.println(Base64.class.getProtectionDomain().getCodeSource().getLocation());
the output is: file:/C:/EProg/IBM/SDP80/runtimes/base_v7/plugins/com.ibm.ws.prereq.soap.jar
Thats definitly the wrong Version.
And an error occurs because of the wrong Version:
java.lang.NoSuchMethodError:
org/apache/commons/codec/binary/Base64.decodeBase64(Ljava/lang/String;)
The crazy thing is, that happens only it i choose one Test and run it with Run As: JUnit Test in Eclipse, if I run the whole thing with Maven everthing works fine.
I use JUnit 4.8.1 and Eclipse Indigo Service Release 2 with some Plugins for Websphere, GWT and Maven.``
com.ibm.ws.prereq.soap.jar is an OSGi bundle, and in WebSphere (which is built on an OSGi container), the classes in org.apache.commons.codec.binary are not visible to applications because that package is not exported by the OSGi bundle (you can examine the list of exported packages by looking at the META-INF/MANIFEST.MF file in com.ibm.ws.prereq.soap.jar). That explains why you don't encounter any issue when running your application in WebSphere.
On the other hand, when you add that JAR to a Java project in Eclipse, it will be treated like a simple JAR, not an OSGi bundle, and all packages will be visible. In your case this creates a conflict with another commons-codec dependency.
I guess that the reason why you don't encounter that issue in Maven is that com.ibm.ws.prereq.soap.jar is only a dependency of your Eclipse project, but not of your Maven project.
Unfortunately there are not many (simple) ways to solve that issue. One is to remove com.ibm.ws.prereq.soap.jar from your Java project (I doubt that you are actually using Apache SOAP). The other is to change the order, so that your other commons-codec dependency comes before com.ibm.ws.prereq.soap.jar.
It looks like a class path issue. More precisely, Eclipse integration with Maven. I would investigate Eclipse dependencies and make sure that it uses Maven for dependency management.
You can do it in two ways, either you can run mvn eclipse:eclipse command or use M2Eclipse plugin. If you use the later, then there is a update dependency option, in the project context menu.