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.
1. Create a Maven enterprise application with web module and ejb module 2. Create a Maven library project (inside the enterprise application directory) and set its source level to 1.5 3. Create an EJB in the EJB module with remote interface in the library 4. In the pom file of the library, add <scope>provided</scope> to the declaration of the dependency on the Java EE API, to work around bug 186221, and build EAR app with dependencies 5. Run the EAR application on GlassFish v3. Deployment will fail with the following message: WARNING: Error in annotation processing: java.lang.NoClassDefFoundError: p/NewSessionBeanRemote SEVERE: Exception while deploying the app java.lang.IllegalArgumentException: Invalid ejb jar [mavenproject91-ejb-1.0-SNAPSHOT.jar]: it contains zero ejb. This is because the library is packaged in the root of the ear, which is incorrect. It should be packaged in the 'lib' subdirectory. The workaround is to add the following to the <configuration> section of the maven-ear-plugin in the EAR application's pom file: <defaultLibBundleDir>lib</defaultLibBundleDir> This should probably also be the permanent fix - i.e. we should change the archetype from which the EAR project is creates (for all EE versions) to contain this by default. What do you think, David?
Peter is right with his workaround. Have a look at Java EE 6 spec chapter "EE.8.2.1 Bundled Libraries" for how EAR can bundle libraries - either via Class-Path manifest attribute or via lib directory in EAR. Ant based projects switched in NB68 from Class-Path attribute to lib folder usage.
Fixed by Dafe as suggested above: http://hg.netbeans.org/main-silver/rev/60caac6793cc
Integrated into 'main-golden', will be available in build *201006300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/60caac6793cc User: Dafe Simonek <dsimonek@netbeans.org> Log: #181861, #186223 - update of archetype versions to newly releases archetypes that are addressing issues
I'm not used to Bugzilla. But it looks like this was originally reported for version 7.0. It looks like the feature was brought to 6.9.1. The wizard does add the Java EE 6 API library to the project targeted for the remote interface. It does add the project with the remote interface to the list of libraries for the EJB Module. But it does not bundle the jar with the remote interface properly. I'm getting a ClassNotFound error. I am not using Maven at all. Straight vanilla 6.9.1 and Glassfish 3.0.1. Just simply create a EJB Module project and a Java Class Library project. Add a stateless session bean with a remote interface. Target the Java Class Library for the remote interface. And try to deploy the EJB. It builds just find. But won't deploy because it can't locate the remote interface class. I look at where the jar with the remote interface is and sure enough it is in the root and not the lib directory of the EAR. I look at the manifest and no Class-Path is set. Am I crazy?
(In reply to comment #4) > Just simply create a EJB Module project and a Java Class Library project. Add > a stateless session bean with a remote interface. Target the Java Class > Library for the remote interface. And try to deploy the EJB. It builds just > find. But won't deploy because it can't locate the remote interface class. What you are experiencing is issue 186331 - deployment of standalone EJB module did not work properly. It should be OK in NB7.0Beta1. Workaround is to create an EAR and add your EJB module to EAR and deploy EAR. > Am I crazy? I do not think so. :-) This issue is specific to a Maven problem which was resolved. If you still have a problem just file a new issue and provide details how to reproduce.
Greetings, I followed the same steps as you mentioned. But still i can't get it right. First question is how do you add a Maven library project? I'm using Netbeans 7.0, I created a new Maven enterprise app with web and ejb modules. But I can't find the Maven library project archetype in step 2. So what i did was I added a Maven Java Application and then deleted the main class. But then when i tried to create EJBs using the "Session Beans for Entity classes" wizard, in the last page i selected "Remote in Project" and provided the Maven Java App for remote interfaces, it gives me the error message "EJB Remote Interface depends on JPA Entity classes. JPA Entities are inaccessible if they are located in MyProject-ejb EJB." and it disables the next and finish buttons. How do I solve this issue? I appreciate any help and i thank in advance! Regards, Simon Mebrahtu (In reply to comment #1) > Peter is right with his workaround. Have a look at Java EE 6 spec chapter > "EE.8.2.1 Bundled Libraries" for how EAR can bundle libraries - either via > Class-Path manifest attribute or via lib directory in EAR. Ant based projects > switched in NB68 from Class-Path attribute to lib folder usage. (In reply to comment #0) > 1. Create a Maven enterprise application with web module and ejb module > 2. Create a Maven library project (inside the enterprise application directory) > and set its source level to 1.5 > 3. Create an EJB in the EJB module with remote interface in the library > 4. In the pom file of the library, add <scope>provided</scope> to the > declaration of the dependency on the Java EE API, to work around bug 186221, > and build EAR app with dependencies > 5. Run the EAR application on GlassFish v3. > > Deployment will fail with the following message: > WARNING: Error in annotation processing: java.lang.NoClassDefFoundError: > p/NewSessionBeanRemote > SEVERE: Exception while deploying the app > java.lang.IllegalArgumentException: Invalid ejb jar > [mavenproject91-ejb-1.0-SNAPSHOT.jar]: it contains zero ejb. > > This is because the library is packaged in the root of the ear, which is > incorrect. It should be packaged in the 'lib' subdirectory. The workaround is > to add the following to the <configuration> section of the maven-ear-plugin in > the EAR application's pom file: > <defaultLibBundleDir>lib</defaultLibBundleDir> > > This should probably also be the permanent fix - i.e. we should change the > archetype from which the EAR project is creates (for all EE versions) to > contain this by default. What do you think, David?
(In reply to comment #6) > So what i did was I added a > Maven Java Application That sounds right. > it gives me the error message "EJB Remote Interface depends on JPA > Entity classes. JPA Entities are inaccessible if they are located in > MyProject-ejb EJB." You are using 'Session Beans for Entity Classes' wizard, right? This wizard generates EJB 'facades' for you JPA entities which means that singatures of your EJB methods will contains references to JPA classes. Now if you decide to generate EJBs with remote interface then remote interfaces will be generated into your Maven Java Application. But because these interfaces references JPA entity classes they need access to them and have them on compilation classpath. And the error says that you cannot do that because JPA entities are defined in the same jar where EJBs are being generated. > and it disables the next and finish buttons. How do I solve > this issue? Move JPA entities into a separate jar. It can be the same one into which you would like you generate remote EJB interfaces or it can be yet another jar. Got it?
[SOLUTION] This can be solved by adding proper library folder while deploying via webinterface example: If your project is JPAEntityClassWithPersistanceXml.jar (and as you can see I am not using ear in this case), then, when deploying you can see this information just below "Libraries: " field (after selecting jar file for upload formular appears): "A comma-separated list of library JAR files. Specify the library JAR files by their relative or absolute paths. Specify relative paths relative to instance-root/lib/applibs. The libraries are made available to the application in the order specified." If we place ../../applications/JPAEntityClassWithoutPersistanceXml/DummyRemote.jar in this field, where DummyRemote.jar is project with interface declaration, and we make sure that *this project adds this jar file to final dist jar file (by checking package jar files in RMB at project>Build: packaging *this DummyRemote.jar is actually in final jar file then, by filling this "library: " formular field, we force Glassfish to look through DummyRemote.jar file in order to find classes for EJB remote declaration.
The solution in comment #8 works fine (I just tried). However..shouldn't this be solved in the packagin process? (creating the jar)