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 201303

Summary: Embedded container tests stop working if adding Java-EE-Glassfish-V3 to classpath
Product: javaee Reporter: pablopina
Component: EJB ProjectAssignee: David Konecny <dkonecny>
Status: RESOLVED WONTFIX    
Severity: normal CC: pjiricka
Priority: P1    
Version: 7.0.1   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

Description pablopina 2011-08-25 04:43:08 UTC
Steps to reproduce it:

1) Create EJB project with a Stateless Session Bean and a unit test for it
2) run test (runs ok)
3) Add to the project Java-EE-Glassfish-V3
4) run test again: fails
5) Remove library Java-EE-Glassfish-V3 from ejb project
4) run test again: fails again. Tests will never again run.

Failure message:

javax.ejb.EJBException: No EJBContainer provider available: no provider names had been found.
	at javax.ejb.embeddable.EJBContainer.reportError(EJBContainer.java:216)
	at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:146)
	at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:102)
	at ejbs.NewSessionBeanTest.testToString(NewSessionBeanTest.java:42)



Out of curiosity i copy pasted the project folder before adding the Java-EE-Glassfish-V3 and then i did beyond compare on both  project folders after removing Java-EE-Glassfish-V3 so it looks like that removing the library doesn't revert it to its original state:

This is the difference in nbproject/project properties

Before adding Java-EE-Glassfish-V3
-------------------------------------------

j2ee.platform.classpath=${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.security.auth.message.jar:${j2ee.server.home}/modules/jaxrpc-api-osgi.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/jsf-impl.jar:${j2ee.server.home}/modules/javax.ejb.jar:${j2ee.server.home}/modules/jersey-core.jar:${j2ee.server.home}/modules/jstl-impl.jar:${j2ee.server.home}/modules/javax.servlet.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.resource.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/jsf-api.jar:${j2ee.server.home}/modules/javax.management.j2ee.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.enterprise.deploy.jar:${j2ee.server.home}/modules/jaxr-api-osgi.jar:${j2ee.server.home}/modules/javax.security.jacc.jar:${j2ee.server.home}/modules/endorsed/javax.annotation.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.jms.jar:${j2ee.server.home}/modules/javax.transaction.jar
j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar
j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar
j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar
j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar
j2ee.platform.wsit.classpath=
javac.classpath=



Before adding and removing Java-EE-Glassfish-V3
-------------------------------------------
j2ee.platform.classpath=\
    ${libs.Java-EE-GlassFish-v3.classpath}
j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar
j2ee.platform.jwsdp.classpath=\
    ${libs.Java-EE-GlassFish-v3.wsjwsdp}
j2ee.platform.wscompile.classpath=\
    ${libs.Java-EE-GlassFish-v3.wscompile}
j2ee.platform.wsgen.classpath=\
    ${libs.Java-EE-GlassFish-v3.wsgenerate}
j2ee.platform.wsimport.classpath=\
    ${libs.Java-EE-GlassFish-v3.wsimport}
j2ee.platform.wsit.classpath=\
    ${libs.Java-EE-GlassFish-v3.wsinterop}
javac.classpath=\
    ${libs.Java-EE-GlassFish-v3.classpath}



The reason why we add this library is because we want to build and test our Ear project in jenkins / hudson. 

First I tried adding the Java EE 6 Api Library to the project but by doing so the entity metamodel generation throws this 

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/PersistenceException
 
and trying to run the unit tests throws another java.lang.ClassFormatError.

I don't know the purpose in life of Java EE 6 Api Library is really...
Comment 1 David Konecny 2011-08-26 01:02:33 UTC
I do not mean to offend you Pablo by closing your issues but there is not much to do about this on NB side. It is a messy situation. Why it works in your step #2) is because a jar is added to project classpath from glassfish installation and that jar in its manifest includes via ClassPath attribute dozens of GF jars. That's the scenario I know to work. Everything else never worked for me but perhaps it gets better in newer versions.

If you want to make it pass with Java-EE-Glassfish-V3 then you will have to talk to GF team and ask them why it does not work.

I would suggest to install GlassFish on your hudson and run the tests the same way they are run in IDE. That should work. I never find any other way.
Comment 2 pablopina 2011-08-26 04:48:12 UTC
(In reply to comment #1)

Yes, we did install hudkins and it's running now, but out of frustation....

If we edited the MANIFEST.INF of glassfish-embedded-static-shell.jar and replaced '../../modules/' for '' and then jar it as glassfish-embedded-static-shell-xxx.jar

Could we not then add glassfish-embedded-static-shell-xxx.jar to Java-EE-Glassfish-V3 library as it could then reference all other jars in the same directory?

Thanks David!
Comment 3 David Konecny 2011-08-28 23:47:48 UTC
(In reply to comment #2)
> Could we not then add glassfish-embedded-static-shell-xxx.jar to
> Java-EE-Glassfish-V3 library as it could then reference all other jars in the
> same directory?

In theory you could. Whether it will work is a different story. If you have time to experiment with it and are ready to repackage that way any newer build of GF you may need to use and you accept that newer GF builds/releases may suddenly stop working if repackaged then go for it. :-)