简体   繁体   中英

how to deploy an EJB module from Netbeans to Glassfish

How is a Netbeans @Stateless and @Remote EJB deployed to Glassfish from an EJB module ?

Netbeans is able to do so, but how is this accomplished outside of the IDE?

server log:

thufir@dur:~$ 
thufir@dur:~$ tail glassfish-4.1/glassfish/domains/domain1/logs/server.log -n 34
    at java.lang.Thread.run(Thread.java:744)
]]

[2014-09-22T01:41:57.266-0700] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=42 _ThreadName=admin-listener(5)] [timeMillis: 1411375317266] [levelValue: 1000] [[
  Exception while deploying the app [HelloEJB] : Invalid ejb jar [HelloEJB]: 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.]]

[2014-09-22T03:52:08.027-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383128027] [levelValue: 800] [[
  visiting unvisited references]]

[2014-09-22T03:52:08.067-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383128067] [levelValue: 800] [[
  visiting unvisited references]]

[2014-09-22T03:52:08.511-0700] [glassfish 4.1] [INFO] [AS-EJB-00054] [javax.enterprise.ejb.container] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383128511] [levelValue: 800] [[
  Portable JNDI names for EJB HelloBean: [java:global/HelloEJB/HelloBean, java:global/HelloEJB/HelloBean!hello.HelloBeanRemote]]]

[2014-09-22T03:52:08.513-0700] [glassfish 4.1] [INFO] [AS-EJB-00055] [javax.enterprise.ejb.container] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383128513] [levelValue: 800] [[
  Glassfish-specific (Non-portable) JNDI names for EJB HelloBean: [hello.HelloBeanRemote#hello.HelloBeanRemote, hello.HelloBeanRemote]]]

[2014-09-22T03:52:09.142-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383129142] [levelValue: 900] [[
  WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]]

[2014-09-22T03:52:09.152-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383129152] [levelValue: 900] [[
  WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]]

[2014-09-22T03:52:09.157-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383129157] [levelValue: 900] [[
  WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]]

[2014-09-22T03:52:10.646-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383130646] [levelValue: 800] [[
  HelloEJB was successfully deployed in 2,783 milliseconds.]]

thufir@dur:~$ 


package hello;

import javax.ejb.Stateless;

@Stateless
public class HelloBean implements HelloBeanRemote {

    @Override
    public String hi() {
        return "hello world";
    }

    @Override
    public String bye() {
        return "goodbye";
    }

}


package hello;

import javax.ejb.Remote;

@Remote
public interface HelloBeanRemote {

    public String hi();

    public String bye();
}

see also:

Deploying standalone EJB module does not work if EJB module depends on some other jar files - these jars files are ignored and not deployed to server which consequently will result in ClassNotFound exception from EJB module. Similar situation is in AppClient.

This has never ever worked and the problem exists since early 4.x NB versions.

The workaround is to deploy EJB module and its required JARs in EAR project or use command line, eg. "glassfishv3/bin/asadmin deploy --libraries projs/JavaLibrary1/dist/JavaLibrary1.jar projs/EJBModule2/dist/EJBModule2.jar" which deploys standalone EJB module EJBModule2.jar and its required library JavaLibrary1.jar.

https://netbeans.org/bugzilla/show_bug.cgi?id=186331

Is that bug effecting the deploy of HelloEJB? The code for HelloEAR is almost exactly the same, the only difference being that it was created in Netbeans as an Enterprise Application with an EJB module of HelloEAR-ejb rather than HelloEJB as an EJB module .

If module's can't be deployed to glassfish, what are they used for? Is using an EJB module a dead-end, a false path towards deploying an @Stateless and @Remote EJB?

Try to do the same EJB module but creating it through an Enterprise Application. Select New Project > Java EE > Enterprise Application. You can unselect the option "Web Application Module" and only leave selected the option "Create EJB Module". After to code your EJBs left click on your Entrerprise App and select "Deploy". This video can help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM