title: how to deploy an EJB module from Netbeans to Glassfish
body: <p>How is a Netbeans <code>@Stateless</code> and <code>@Remote</code> EJB deployed to Glassfish from an <code>EJB module</code>?</p>
  
  <p>Netbeans is able to do so, but how is this accomplished outside of the IDE?</p>
  
  <p>server log:</p>
  
  <pre><code>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&lt;Object&gt;) 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&lt;Object&gt;) 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&lt;Object&gt;, 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();
  }
  </code></pre>
  
  <p>see also:</p>
  
  <blockquote>
    <p>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.</p>
    
    <p>This has never ever worked and the problem exists since early 4.x NB
    versions.</p>
    
    <p>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.</p>
  </blockquote>
  
  <p><a href="https://netbeans.org/bugzilla/show_bug.cgi?id=186331" rel="nofollow">https://netbeans.org/bugzilla/show_bug.cgi?id=186331</a></p>
  
  <p>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 <code>Enterprise Application</code> with an <code>EJB module</code> of <code>HelloEAR-ejb</code> rather than <code>HelloEJB</code> as an <code>EJB module</code>.</p>
  
  <p>If module's can't be deployed to glassfish, what are they used for?  Is using an <code>EJB module</code> a dead-end, a false path towards deploying an <code>@Stateless</code> and <code>@Remote</code> EJB?</p>