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 189174 - Building an EAR app with an app client and ejb module with remote ejbs seems impossible to deploy in GFv3 unless you deploy from netbeans in your local server
Summary: Building an EAR app with an app client and ejb module with remote ejbs seems ...
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: App Client (show other bugs)
Version: 6.x
Hardware: PC Windows 7
: P1 normal (vote)
Assignee: David Konecny
URL: http://forums.java.net/jive/thread.js...
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-03 17:55 UTC by pablopina
Modified: 2010-08-04 00:50 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pablopina 2010-08-03 17:55:04 UTC
In Netbeans 6.9, do New Enterprise Application -> 
Add 1 ejb module 
Add 1 app client module 

In the ejb module, create a persistence unit, a session bean with local interface, a session bean with remote interface and add a reference to the local bean from the remote bean. Clean and build, deploy to GFv3. SEVERE exception. 


By default NB adds the EJB module to the classpath of the app client and "ticks" the "package" checkbox. 

This "package" being "ticked" means that even though it is an EAR module and to my knowledge all ear modules withing the same ear are available to each other. Netbeans adds a classpath entry to the app client Manifest.mf pointing to the jar with the ejb module. This means that at deployment time the APT of  GF scans the app-client modules, "and the jars in it's manifests class-path" and finds annotations of type @EntityManager which doesn't expect in the app-client "at all" and @EJB ejb references to local interfaces which doesn't accept because one it is APTing the app client and in the app client only references to remote interfaces make sense.

So okay, we untick the "package" checkbox in netbean's app-client project libraries. We deploy and we get a ClassNotFoundException for any remote interfaces. Even though they both app-client and ejb module are EAR modules inside the same ear for some reason, the app client runtime doesn't include the ejb module in its classpath.

INFO: [AutoDeploy] Selecting file D:\gfbuilds\glassfish-3.1-b11-07_18_2010\glassfish\domains\domain1\autodeploy\EnterpriseApplication2.ear for autodeployment.
WARNING: Invalid annotation symbol found for this type of class.
symbol: FIELD
location: javax.persistence.EntityManager sample.ejbs.NewSessionBean.em

WARNING: Invalid annotation symbol found for this type of class.
symbol: FIELD
location: javax.persistence.EntityManager sample.ejbs.OtherSessionBean.em

SEVERE: Exception while deploying the app
java.lang.RuntimeException: Target ejb OtherSessionBean for remote ejb 3.0 reference sample.ejbs.NewSessionBean/other does not expose a remote business interface of type sample.ejbs.OtherSessionBeanLocal
at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:733)
at com.sun.enterprise.deployment.ApplicationClientDescriptor.visit(ApplicationClientDescriptor.java:663)
at com.sun.enterprise.deployment.Application.visit(Application.java:1780)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.validate(ApplicationArchivist.java:790)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:269)
at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:235)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:152)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:79)
at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:635)
at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:577)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:281)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:202)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:332)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:368)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:378)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1070)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:98)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1185)
at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:141)
at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:573)
at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:459)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:391)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:376)
at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:209)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

WARNING: [AutoDeploy] Autodeploy failed : D:\gfbuilds\glassfish-3.1-b11-07_18_2010\glassfish\domains\domain1\autodeploy\EnterpriseApplication2.ear.
INFO: [AutoDeploy] Selecting file D:\gfbuilds\glassfish-3.1-b11-07_18_2010\glassfish\domains\domain1\autodeploy\EnterpriseApplication2.ear for autodeployment.
WARNING: Invalid annotation symbol found for this type of class.
symbol: FIELD
location: javax.persistence.EntityManager sample.ejbs.OtherSessionBean.em

WARNING: Invalid annotation symbol found for this type of class.
symbol: FIELD
location: javax.persistence.EntityManager sample.ejbs.NewSessionBean.em

SEVERE: Exception while deploying the app
java.lang.RuntimeException: Target ejb OtherSessionBean for remote ejb 3.0 reference sample.ejbs.NewSessionBean/other does not expose a remote business interface of type sample.ejbs.OtherSessionBeanLocal
at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:733)
at com.sun.enterprise.deployment.ApplicationClientDescriptor.visit(ApplicationClientDescriptor.java:663)
at com.sun.enterprise.deployment.Application.visit(Application.java:1780)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.validate(ApplicationArchivist.java:790)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:269)
at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:235)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:152)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:79)
at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:635)
at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:577)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:281)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:202)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:332)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:368)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:378)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1070)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:98)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1185)
at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:141)
at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:573)
at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:459)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:391)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:376)
at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:209)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

WARNING: [AutoDeploy] Autodeploy failed : D:\gfbuilds\glassfish-3.1-b11-07_18_2010\glassfish\domains\domain1\autodeploy\EnterpriseApplication2.ear.


Downloadable example ear app that reproduces the bug is here:
http://forums.java.net/jive/thread.jspa?threadID=152105&tstart=15

NOTE: If this app you deploy through netbeans everything seems to be fine. Problem starts when you deploy to gf via web console /autodeploy, etc.
Comment 1 David Konecny 2010-08-03 21:22:24 UTC
Agreed, that's an error. I must say that I'm surprised about this behaviour because I believed that this is not happening anymore. The workaround is obvious though: create EAR project just with EJB project and then create AppClient project separately.

When creating Remote EJB interface it does not make any sense to create the interface directly in EJB module - once issue 186332 is fixed users will be forced to store remote interfaces in some none-EE project. I'm mentioning this as it is not obvious from your test case whether you are aware of this or not.
Comment 2 David Konecny 2010-08-04 00:50:29 UTC
EjbModule is now added only to compilation classpath of WAR/AppClient and will not be packaged by default to WAR/App JAR. That resolves this problem. As I mentioned earlier remote interfaces needs to be stored in a separate proejct, for example J2SE Library project which then can be included into any project which has a need to call remote EJB.

(In reply to comment #0)
> So okay, we untick the "package" checkbox in netbean's app-client project
> libraries. We deploy and we get a ClassNotFoundException for any remote

As expected. If jar is not marked for packaging then it is used only for compilation. AppClient can only use EJB's remote interface and simply has to have it in order to run because it is executed locally. Web Application on the other hand if deployed within same EAR with EJB can use EJB's local interface and as you said because all EE module deployed within EAR can see each other on runtime classpath everything will work.

> NOTE: If this app you deploy through netbeans everything seems to be fine.
> Problem starts when you deploy to gf via web console /autodeploy, etc.

I have not tested this but if you follow what I said about putting remote interfaces into separate jars then everything should work both from NB as well as from command line. In theory I mean. Feel free to file another issue if it still does not work. Thanks.

Fixed in: eead68a78117