Netbeans deployment fails after class rename - java

I am writing a test client for a webservice. It's a Netbeans 6.9.1 WebApplication using JSF framework. I have one managed bean that calls the webservice.
Everything worked fine until I noticed a typo in my bean class name. It was serviceBean and I renamed it to ServiceBean with first letter upper case. I used safe rename function of Netbeans and both the filename and class signature changed as expected.
But from then I had a lot of trouble running my application on Glassfish 3.0.1.
I can build my application from Netbeans without error (even "Clean & Build"). But if I deploy there is the following message in server log:
WARNUNG: Error in annotation processing: java.lang.NoClassDefFoundError: jsf/serviceBean (wrong name: jsf/ServiceBean)
WARNUNG: WEB9052: Unable to load class jsf.ServiceBean, reason: java.lang.ClassNotFoundException: jsf.ServiceBean
INFO: Mojarra 2.0.2 (FCS b10) für Kontext '/PidClient' wird initialisiert.
SCHWERWIEGEND: Unable to load annotated class: jsf.serviceBean, reason: java.lang.NoClassDefFoundError: jsf/serviceBean (wrong name: jsf/ServiceBean)
INFO: Loading application PidClient at /PidClient
I have a form on a facelet page that will be submitted to my managed bean. The form will be loaded despite of the above error but if I try to submit it I get the following error:
WARNUNG: /index.xhtml #19,94 value="#{serviceBean.fldLname}": Target Unreachable, identifier 'serviceBean' resolved to null
javax.el.PropertyNotFoundException: /index.xhtml #19,94 value="#{serviceBean.fldLname}": Target Unreachable, identifier 'serviceBean' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:93)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
So this will only be a follow-up error caused by the NoClassDefFoundError above.
And now to the strange part:
If I build my project it creates the file ServiceBean.class but if I deploy the project from Netbeans and then look into my deployment directory the class is renamed to serviceBean.class.
It seems that deployment process renames the file.
What is the problem? (Netbeans 6.9.1, Glassfish 3.0.1, Windows 7)
UPDATE: It gets even better: Renamed ServiceBean.java to ServiceBean2.java. Result: If I "Clean & Build" the war file contains ServiceBean2.class only. If I deploy from NB the build dir contains ServiceBean2.class and serviceBean.class. How do I get rid of this ghost?

I was able to replicate a variation of this problem. I had to clear the NetBeans compilation cache (which appears to have issues on OSes that are case-forgiving...)
To move past the issue that I encountered, I had to:
Stop the server
Clean the project
Stop NetBeans
Delete %HOME%.netbeans\6.9\var\cache
Start NetBeans
When I ran the project which was having problems, NetBeans recompiled the project, started the server and opened the index.xhtml. I was able to navigate through the app successfully after that.
I have opened http://netbeans.org/bugzilla/show_bug.cgi?id=198565 to track the issue. Please monitor that issue and add any info that you think would assist somebody that attempts to resolve the issue.

I had a very similar problem with NetBeans 7.3, which means it's still not fixed. It happened after I did a rename and delete of an entity class, and JPA refused to believe that the class was deleted, so I couldn't deploy to Glassfish.
Took me many hours, going from restarting NetBeans and Glassfish to actually reinstalling them. Turns out reinstalling NetBeans doesn't clear its cache though, and that's where the problem lies.
As I run OS X, I did the following in ~/Library/Caches/NetBeans:
$ grep -r MyDeletedEntity *
And boom, there were few references to my deleted class!
I then proceeded to delete the contents in that folder, restarted NetBeans and then deployed to Glassfish again. Now it works!
If this does not work, also look into
/Applications/NetBeans/NetBeans {whateverversion}.app/Contents/Resources/NetBeans/nb/var/cache and delete everything in that folder too.

Too late, but might help others. I just realized JRebel was keeping references to the old names. I disabled JRebel for my project, clean&build+run and problem got away.

Related

NoClassDefFoundError for com.cloudant.client.api.ClientBuilder but class exists

Project returns error Error 500: javax.servlet.ServletException:
java.lang.NoClassDefFoundError: com/cloudant/client/api/ClientBuilder
But class exists.
Error below (removed project's name).
Here is the dependency
I've already tried an mvn clean install -U, removing the .m2
folder and still no luck so far.
Eclipse version is Version: 2018-12 (4.10.0).
My computer is macOS High Sierra 10.13.6
No class definition found error indicates that your Java runtime could not find the class in question. Please check if your app is deployed to the runtime which you think it should be deployed.
Mostly this would be linked to any of the following steps in you project life cycle.
1. Build (turn on 'build automatically') in Eclipse. I see you've done these steps.
2. Deployment to target runtime (like deploying to some web container). Check if your code is being deployed or not to target runtime.
But I see that you've already mentioned that it works for sometime, which means that you need to understand why the runtime is unable to access your class at that moment. I would do the following.
1. Check if JAR is already present.
2. If not present, follow the build deploy steps you've followed. This means that you'll have to establish how the JAR mysteriously got deleted.
3. If JAR is present, but you see this error, then it means that your runtime CLASSPATH has mysteriously changed and that needs to be investigated. Ideally this should not happen, as all softwares usually are 'consistant', i.e. they either consistently have error or consistently work. This inconsistency itself indicates something environmental which you need to crack.
Is that IBM WebSphere? If this is in your company and it is a shared server or something, check if someone is inadvertently fiddling with your deployment or something.
Good luck!
Edit: Check if this helps you conceptually - NoClassDefFoundError by switching to another project

tomcat unable to publish due to deleted java.orig file

I used a merge tool to merge my code with the upstream branch which created a .orig file for one of my java classes. After verifying that everything was working fine I saw not need to keep the .java.orig file around so I deleted it.
Now whenever I try to deploy to tomcat from eclipse I get the following error:
'Publishing to Tomcat v8.0 Server at localhost..' has encountered a problem.
Resource '.../MyClass.java.orig' does not exist.
I've tried removing all applications off the server and removing the server from eclipse and then recreating it but to no avail.
I'm running out of things to try and I'm not sure what dependency tomcat thinks my project has on the .orig file. Any help is appreciated.
Ok so rebooting my machine seemed to have fixed the issue I was able to start tomcat normally after that using the same eclipse workspace. I'm not sure what the underlying issue actually was but the restart seemed to fix it.

An internal error occurred during: "Loading descriptor for <Web Project>.". java.lang.NullPointerException

I just downloaded Eclipse Luna on my new laptop and as soon as I have created a new Dynamic Web project and try to expand the project in the explorer, I get this error message:
"An internal error occurred during: "Loading descriptor for WebProjectTest.".
java.lang.NullPointerException"
I initially ignored the message, but when I go to add a servlet through the 'create servlet' window and type a name for the class I'm unable to press 'next'.
I have Java 1.7 installed and had no problems at all using Eclipse Juno on my old laptop
I just had this problem and realized that it was because I had accidentally downloaded the non-J2EE version of Eclipse. It looks like the plugins and Eclipse itself does not recognize that you're asking it to to J2EE things in a non-J2EE app and will throw mysterious errors and exceptions like this. My solution was to start over and download the J2EE version of Eclipse and reload the project in that.
I think it might be possible to upgrade a non-J2EE Eclipse by downloading all of the right tools but it is probably simpler to just re-download it.
Remove a descriptor, as far as servlet 3.0 spec the web project doesn't required to use web project deployment descriptor. If a descriptor is a main cause of the error then it would solve you first problem. The second problem required some mode details. If the button is disabled it might be an internal error, or restricted behavior of the control. You need to use a stable release to have less bugs.

Glassfish 4 deployment error

I added some libraries to my JavaEE project and then deploy the application works. I modified something and I got this error message in Eclipse:
Cannot Deploy ProjectName
deploy is failing=Error occurred during deployment: Keys cannot be duplicate.
Old value of this key property, nullwill be retained.
Please see server.log for more details.
java.lang.LinkageError: loader (instance of
org/glassfish/web/loader/WebappClassLoader):
attempted duplicate class definition for name:
"org/glassfish/web/loader/JdbcLeakPrevention"
loader (instance of org/glassfish/web/loader/WebappClassLoader): attempted duplicate
class definition for name: "org/glassfish/web/loader/JdbcLeakPrevention"
I made some research and I found out that it is not an Eclipse bug. I'm working with Kepler but I tested with Juno too. Got the same error message.
I downloaded Glassfish 3.1.2.2 and the message gone.
Why am I getting this message?
I Had the same error. I stopped the GLassfish server and then I cleaned the project (Project -> Clean... ). Started the server and worked
I also had this issue, and I was also using the SVNKit library plus its dependencies so it looks like there is some kind of conflict there. I can get around it by cleaning out the osgi-cache folder & restarting glassfish, but I have to do this every time I want to deploy, so not a great solution.
Try to remove all the files under osgi-cache and generated directories. It worked for me.
In my Glassfish log file it says:
Application with name ws is already registered. Either specify that redeployment must be forced, or redeploy the application. Or if this is a new deployment, pick a different name
Following my logs instructions I deployed the app with --force option:
asadmin deploy --force=true ws.war
and it worked. More info on deploy --force=true
Try to clean autodeploy directory, restart the server.
Also clean the project deployment directory.
following steps worked for me.
stop the glassfish server(if running)
kill all the java process (using terminal or activity monitor)
now try redeploy.
Was somehow related to a single #Singleton bean. Converted it to #Stateless and everything worked fine. Not quite sure why this happened...

intermittent ClassNotFoundException for JSP using eclipse

Running Eclipse Indigo, Tomcat 7 on Windows - running the web application on the ROOT context with eclipse wtp plugin I am getting this intermittent problem where eclipse cannot find the compiled JSP. It occurs when first accessing the JSP and cannot be resolved except by stopping the Tomcat server and cleaning the Work directory and the project directory. The compile version is there in the eclipse directory structure:
.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\_\org\apache\jsp\WEB_002dINF\...
but it still produces this error.
After some research I found this related thread which seems to suggest the problem only occurs when the application is deployed on ROOT.
http://comments.gmane.org/gmane.comp.jakarta.tomcat.user/208071
And a bug has been entered:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=334977
Has anyone had a similar issue to this and knows a solution?
Hi please try to configure value as per first screen shot and change location as per second screenshot and try if that works for you.

Categories

Resources