开发者

Netbeans deployment fails after class rename

开发者 https://www.devze.com 2023-03-05 16:00 出处:网络
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.

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.e开发者_如何学Pythonl.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:

  1. Stop the server

  2. Clean the project

  3. Stop NetBeans

  4. Delete %HOME%.netbeans\6.9\var\cache

  5. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消