This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 188740 - Persistent Error in annotation processing after renaming a package and attempt to redeploy on Glassfish v3.0.1
Summary: Persistent Error in annotation processing after renaming a package and attemp...
Status: RESOLVED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: GlassFish (show other bugs)
Version: 6.x
Hardware: PC Windows 7 x64
: P3 normal (vote)
Assignee: Vince Kraemer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-16 19:14 UTC by AlainC
Modified: 2011-02-02 21:20 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
test case (49.54 KB, application/x-gzip)
2011-01-24 23:22 UTC, David Konecny
Details
Stripped down project (110.13 KB, application/x-zip-compressed)
2011-01-25 18:16 UTC, AlainC
Details
test case with 5 projects (57.29 KB, application/x-gzip)
2011-01-25 20:00 UTC, David Konecny
Details
test case with 5 projects (fixed!) (66.65 KB, application/x-gzip)
2011-01-25 20:21 UTC, David Konecny
Details
patch for build scripts which fixes broken deployment (6.67 KB, patch)
2011-01-25 20:43 UTC, David Konecny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description AlainC 2010-07-16 19:14:27 UTC
Product Version = NetBeans IDE 6.9 (Build 201006111053)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.6.0_21
Runtime = Java HotSpot(TM) 64-Bit Server VM 17.0-b16

My JavaWeb project includes a JavaEE project containing a JavaEE objects-ejb library deployed on Glassfishv3.0.1

I refactored a java package defining EJBs : it was called "com/mycorp/myproduct/batch" and the new name is "com/mycorp/myproduct/singleton"

After many redeployments, restarts of GlassFishv3.0.1, etc,  I am still stucked with a message saying:

GRAVE: Class [ Lcom/corp/it/batch/GlobalStatistics; ] not found. Error while loading [ class mycorp.mycmany.myproject.web.controller.GlobalStatisticsController ]
ATTENTION: Error in annotation processing: java.lang.NoClassDefFoundError: Lcom/mycorp/myproduct/batch/GlobalStatistics;
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
GRAVE: Exception while invoking class org.glassfish.ejb.startup.EjbDeployer load method
java.lang.RuntimeException: Unable to load EJB module.  DeploymentContext does not contain any EJB  Check archive to ensure correct packaging for D:\Users\...\build\web

(GRAVE for SEVERE, ATTENTION for WARNING or INFO in french...)

The error is persistent  (cannot fix it after cleanups, rebuilds, redeployments, etc): 
I found no track of the old name of my package in my NetBeans projects directories nor in the GlassFish domain directory

I found the previous package name ("batch") in the following directory : C:\Users\..\.netbeans\6.9\var\cache\index\s45\java\14\classes\com\mycorp\myproduct\batch
where I found files like: MyEJBSingleton.sig, MyEJBSingletonLocal.sig, MyEJBSingletonRemote.sig

I will maybe try to delete the C:\Users\..\.netbeans\6.9\var\cache\index\s45\java\14\classes\com\mycorp\myproduct\batch directory...
Comment 1 AlainC 2010-07-16 20:12:38 UTC
After several attempts, I fixed my problem by deleting the C:\Users\..\.netbeans\6.9\var\cache\index directory
(deleting var\cache\index\s.. directories was not enough)

I encountered Security warnings about inconsistencies from GlassFish, but they disappears after NetBeans and GlassFish restarts

My Java Web project executes correctly but some JSF files disappears and I lost functionalities, but this is maybe another problem...
Comment 2 Peter Pis 2010-07-19 12:17:51 UTC
Reassigning.
Comment 3 AlainC 2011-01-11 16:21:42 UTC
There is an inconsistency problem between NORMAL or DEBUG case: 

Now after several months, I have the same problem on another new project with no connection with package refactoring :

My new project is organized like this:
Project 1: a pure Java library.
Project 2: a Java library importing Project 1 and defining EJB interfaces.
Project 3: a Java EE module importing both Project 1 and Project 2 for persistence and Stateless EJBs of my entities.
Project 4: the Java Web main project importing everybody.

I can run the main project without any problem (F6).

But if I put a breakpoint and try to debug the application (F4), I have:

java.lang.IllegalArgumentException: Invalid ejb jar [Project_3]: it contains zero ejb. 
Note: 
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean. 
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar. 
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.
        at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:72)
        at com.sun.enterprise.deployment.util.ApplicationValidator.accept(ApplicationValidator.java:124)
...


I heard about packaging all this stuff in a EAR to fix a problem of failing annotation processing but I fall with the following messages:

ATTENTION: Error in annotation processing: java.lang.NoClassDefFoundError: com/corp/app/web/controller/Controller
GRAVE: Exception while invoking class org.glassfish.ejb.startup.EjbDeployer load method
java.lang.RuntimeException: Unable to load EJB module.  DeploymentContext does not contain any EJB  Check archive to ensure correct packaging for ...

Now I am still stuck for the moment and currently found no solution on the Web.
Comment 4 Petr Jiricka 2011-01-24 16:41:18 UTC
Hi, can you please try whether it helps to turn off Compile on Save in your project's properties and rebuild the project?

I am not sure if I understand your setup correctly, but I believe you do need an EAR project as the container. Project 4 can *reference* Project 3, but it can not *contain* it. Is Project 3 packaged in WEB-INF/lib of Project 4? Such setup would be incorrect. 
Cc'ing David who was dealing with issues like this before.
Comment 5 AlainC 2011-01-24 21:36:31 UTC
OK, Project4 is referencing Project3.

Thank you, I was able to debug Project3 by putting a breakpoint in it after turning off Compile on Save on Project1 and Project2 and turning off Deploy on Save on Project3 and Project4.

But in fact, the bug still remains:

I am obliged to put a dummy breakpoint in the main project (Project4) first and do F5 to have the debugger stopping on the real breakpoint I want to debug in Project3.

I will consider packaging in a EAR file and keep you informed.
Comment 6 David Konecny 2011-01-24 21:57:17 UTC
It sounds like your EJB has remote interface and you deployed Project 3 first and then deployed Project 4 which accesses the EJB from Project 3 via remote interface. If this is the case then you basically dealing with two separate J2EE modules and therefore if you start debugging of Project 4 and want to step into Project 3 you have to start Project 3 in debugger as well. Imagine two J2SE applications running and one communicating with the other via TCPIP - both apps needs to be started in debug session.

Packaging EJB and WAR into EAR would make this easier as both J2EE modules would be deployed as single EAR app and debugging would work as you are expecting - you are debugging EAR in this case.
Comment 7 David Konecny 2011-01-24 21:59:02 UTC
There has been a few other bugs fixed in Compile/Deploy on Save area for NB7.0.
Comment 8 AlainC 2011-01-24 22:42:28 UTC
You are right, I have remote interface definitions, but I am not currently using them. I do accesses to my EJBs through local interfaces defined in Project3:

I did not used EAR in the past because I remember having spending to much time on the problem without success. Maybe I need to restart from scratch on a small project but here is where I am now:


I use the NetBeans wizard to create a ear file with : New Project/Java EE/Enterprise Application with Existing Sources. Then I add Project4 as a Web Module and Project3 as a EJB Module.

F6 gives:

GRAVE: Class [ Lcom/company/project/singleton/GlobalStatistics; ] not found. Error while loading [ class com.project.web.controller.GlobalStatisticsController ]
ATTENTION: Error in annotation processing: java.lang.NoClassDefFoundError: Lcom/company/project/singleton/GlobalStatistics;
INFO: Cannot find module Project3.jar in application bundle
GRAVE: com/company/project/web/controller/WebController
java.lang.NoClassDefFoundError: com/company/project/web/controller/WebController

I added Project3.jar in the Properties of the ear project but nothing changed and I cannot yet understand what the 'Cannot find module Project3.jar in application bundle' means.
Comment 9 David Konecny 2011-01-24 23:21:44 UTC
Hard to say what's wrong. In your EAR's project properties you should have in your Packaging panel two J2EE module - Project 4 and 3. Nothing else. and Libraries should be empty as well. Could you describe please content of built EAR file (from yourEar/dist folder)? Again there should be Project 4 war and Project 3 JAR in root of EAR and in EAR's lib folder should be Project 1 and Project 2 jars (these two are not J2EE module but just libraries).

There have been several issues fixed in last year or so in this area and I'm not sure which of these are still present in 6.9.

Btw. are you using EE6? or EE5?

I'm attaching a test case from different issue which illustrates similar setup which just works for me. Have a look and perhaps compare it with your one. Might help find some clue. I included all built artifacts in attached ZIP so that you can have a look what correct layout of folders and files should be.
Comment 10 David Konecny 2011-01-24 23:22:17 UTC
Created attachment 105322 [details]
test case
Comment 11 AlainC 2011-01-25 03:01:57 UTC
For testing purpose I tried to install NetBeans 7.0 Beta but without success: JVM has not enough space to start on a 8 Go RAM machine running Windows 7... (I sent a message...)

I use EE6.

Ear/dist folder contains:

gfdeploy\testear\Project 3_jar\com\company\...\*.class files
gfdeploy\testear\Project 4_war\*.xhtml, and subdirectories
gfdeploy\testear\lib\Project 1.jar 15 Ko
gfdeploy\testear\lib\Project 2.jar 15 Ko

Ear/build folder contains:
Project 1.jar 0 Ko
Project 2.jar 0 Ko
Project 3.jar 57 Ko
Project 4.war 113 Ko
lib\Project 1.jar 15 Ko
lib\Project 2.jar 15 Ko

I'll take a look to your attachments.
Comment 12 David Konecny 2011-01-25 03:26:10 UTC
(In reply to comment #11)
> For testing purpose I tried to install NetBeans 7.0 Beta but without success:
> JVM has not enough space to start on a 8 Go RAM machine running Windows 7... 

Well, I cannot help with that. :-) When I myself bumped into similar "not-enough-memory" on Vista on my 2GB RAM laptop a few years ago I replaced the OS with Ubuntu and would never ever ever ever use Windows again.

> Ear/dist folder contains:
> 
> gfdeploy\testear\Project 3_jar\com\company\...\*.class files
> gfdeploy\testear\Project 4_war\*.xhtml, and subdirectories
> gfdeploy\testear\lib\Project 1.jar 15 Ko
> gfdeploy\testear\lib\Project 2.jar 15 Ko
> 
> Ear/build folder contains:
> Project 1.jar 0 Ko
> Project 2.jar 0 Ko
> Project 3.jar 57 Ko
> Project 4.war 113 Ko
> lib\Project 1.jar 15 Ko
> lib\Project 2.jar 15 Ko

This looks pretty much OK. The JARs with 0 size is issue 194041 which has been fixed recently and which will be available in Beta2 of NB 7.0 in a few weeks but it should not cause much harm I believe.

One more option: would it be possible to send me your projects (stripped down from any essential business logic you do not want me to see)? I would be happy to have a look what's wrong.
Comment 13 AlainC 2011-01-25 18:16:16 UTC
Created attachment 105338 [details]
Stripped down project
Comment 14 David Konecny 2011-01-25 18:46:26 UTC
Thanks, I can reproduce the problem and looking at it right now.
Comment 15 David Konecny 2011-01-25 20:00:24 UTC
Created attachment 105341 [details]
test case with 5 projects

user's projects modified to open in the IDE and be compilable out of of the box
Comment 16 David Konecny 2011-01-25 20:21:44 UTC
Created attachment 105343 [details]
test case with 5 projects (fixed!)
Comment 17 David Konecny 2011-01-25 20:42:31 UTC
Vince, there is problem either in deployment to GlassFish from IDE or in GlassFish itself. Could you have a look and file issue for GlassFish if necessary? The projects (use the last fixed attachment) looks OK but deployment fails with "java.lang.ClassNotFoundException: com.company.domain.web.controller.WebController" in server log. I could not figure out what's wrong till I realize that it must be something obscure like...space in the jar file name!...which it is. If I patch the projects and rename all jar artifact to not contain any space characters in its names then project deploys correctly. I will attach a patch which I applied on unzipped projects.
Comment 18 David Konecny 2011-01-25 20:43:43 UTC
Created attachment 105344 [details]
patch for build scripts which fixes broken deployment
Comment 19 David Konecny 2011-01-25 20:46:00 UTC
Btw. I used GlassFish 3.1-b33.
Comment 20 David Konecny 2011-01-25 21:11:11 UTC
Alain, thanks for your project. Apart from discovering this problem I also identified two more issues:

* issue 194711 - "Error occurred during deployment: Application name Product_Portal is already in use"

* issue 194709 - "IllegalStateException: No classpath for /some/path"
Comment 21 David Konecny 2011-01-25 22:20:46 UTC
Alain, one more comment about your project. Having WebController base class in EJB project and extending it from WEB project is not a good idea as it forces you to add EJB project to the classpath of Web project. I would stick with your separation of interfaces/base classes and place WebController and both GlobalConfigurator and GlobalStatistics to "Product Libraries" project. That way Web does not depend on EJB implementation project.

Doing this I was able to run it without problems - index.xhtml calling #{webConfigurationController.portalWebServerURL} via WebConfigurationController.getPortalWebServerURL. via GlobalConfigurator.getPortalWebServerURL (I added a fake one) and finally getting into GlobalConfiguratorSingleton. I was not able to do this when WEB project had dependency on EJB implementation jar. In theory it should work as well though. But I'm not very surprise it did not. HTH.
Comment 22 Vince Kraemer 2011-01-26 06:11:29 UTC
(In reply to comment #17)
> Vince, there is problem either in deployment to GlassFish from IDE or in
> GlassFish itself. Could you have a look and file issue for GlassFish if
> necessary? The projects (use the last fixed attachment) looks OK but deployment
> fails with "java.lang.ClassNotFoundException:
> com.company.domain.web.controller.WebController" in server log. I could not
> figure out what's wrong till I realize that it must be something obscure
> like...space in the jar file name!...which it is. If I patch the projects and
> rename all jar artifact to not contain any space characters in its names then
> project deploys correctly. I will attach a patch which I applied on unzipped
> projects.

There is a problem in the deployment code of GF... it is way too freaked out by spaces... especially on non-windows environments.

The plugin could correct the names of the 'modules' that are created to support directory deployment... but I do not think the plugin gets a chance to remap the names of jar files in the lib directory of an ear at all.

I opened http://java.net/jira/browse/GLASSFISH-15690 to make it visible on the server team's radar.

You should probably get involved with it... since you have the most direct experience with the issue.
Comment 23 David Konecny 2011-01-26 21:15:13 UTC
(In reply to comment #22)
> http://java.net/jira/browse/GLASSFISH-15690

Thanks Vince. Considering only part of the problem is going to be fixed for GF31 I wonder whether we should add a check to GF deployment plugin in NB which would refuse to deploy EAR if one of its J2EE modules or library jars has space character in its name and GF server is 3.0* and 3.1. And provide an error message explaining that GF does not support it. What do you think? That should be simple to do no? On the other hand considering this is first time I've heard about this problem it is certainly not high priority issue - just a good example of usefulness of IDE. :-)
Comment 24 Vince Kraemer 2011-01-26 21:32:58 UTC
I think adding a check during deployment for this case is worth doing.  I will get started on it.
Comment 25 Vince Kraemer 2011-02-02 21:20:08 UTC
http://hg.netbeans.org/web-main/rev/47c0f4d5ba3a applies to this issue also...