Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-9451

EJBs get shared environment context instead of isolated context

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 6.1.0
    • Naming
    • None
    • Hide

      See description

      Show
      See description

      JBoss wrongly uses a shared environment for all EJBs in a WAR module or in an EJB module if there are JAX-WS annotations on some classes.

      The problem can be reproduced with the help of the attached application. Steps to reproduce:

      1. Build the application and deploy the jar into JBoss.
      2. Deploy file ectx-jboss-beans.xml. Observe the following (expected!) output in the console:

      13:10:27,743 INFO [STDOUT] Sc1: [value1]
      13:10:29,960 INFO [STDOUT] Sc2: [value2]

      3. Undeploy ectx-jboss-beans.xml and the application jar.
      4. Modify Sc2Bean.java, uncomment @WebService annotation.
      5. Build the application and deploy the modified jar into JBoss.
      6. Deploy file ectx-jboss-beans.xml. Observe the following (wrong!) output in the console:

      13:15:13,001 INFO [STDOUT] Sc1: [value2]
      13:15:14,753 INFO [STDOUT] Sc2: [value2]

      There is an additional problem that manifests itself at undeploy of the application with the shared environment context: there are multiple exceptions like the following

      14:13:18,965 WARN [org.jboss.kernel.plugins.dependency.StartStopLifecycleAction] Error during stop for jboss-switchboard:appName=ectx,module=ectx,name=Sc2Bean: javax.naming.NameNotFoundException: ORB not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]
      at org.jnp.server.NamingServer.unbind(NamingServer.java:349) [:5.0.5.Final]
      at org.jnp.interfaces.NamingContext.unbind(NamingContext.java:873) [:5.0.5.Final]
      at org.jboss.util.naming.Util.unbind(Util.java:151) [jboss-common-core.jar:2.2.17.GA]
      at org.jboss.util.naming.Util.unbind(Util.java:141) [jboss-common-core.jar:2.2.17.GA]
      at org.jboss.switchboard.mc.SwitchBoardImpl.unbindFromRelevantContext(SwitchBoardImpl.java:303) [:1.0.0-alpha-15]
      at org.jboss.switchboard.mc.SwitchBoardImpl.stop(SwitchBoardImpl.java:102) [:1.0.0-alpha-15]
      ...

      The root cause of the problems is in class org.jboss.reloaded.naming.deployers.ComponentNamingDeployer, line 63:

      // If the deployment is a web module, then java:comp == java:module
      // (See JavaEE6 Spec, section EE.5.2.2). So we create a MCJavaEEComponent,
      // which uses the same context as its parent JavaEEModule
      boolean useJavaModuleContext = this.informer.belongsToWebModule(unit);

      Why this is wrong? For the following reasons:

      1. I do not think that the mere presence of @WS annotations turns an EJB module into a web module. Yes, some web infrastructure is needed to provide HTTP transport, but this is an implementation detail.

      2. Next, "JavaEE6 Spec, section EE.5.2.2" says: "For historical reasons, the java:comp namespace is shared by all components in a web module. To preserve compatibility, this specification doesn't change that.". The thing is: historically it was not possible to define EJBs in a web module, at least, not according to the previous JavaEE specifications. So historical reasons are applied only for components that historically could be deployed in a web module.

      3. Even more, "historically" JavaEE developers expect that EJBs do NOT share their java:comp namespace.

              johnbailey_jira John Bailey (Inactive)
              klv_m72 Leonid Kosmylev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated: