10 Replies Latest reply on Feb 14, 2012 1:57 AM by mihovil

    When migrating from AS6.0 to AS7.2 multiple EJB contexts do not work any more

    mihovil

      Hi,

       

      We've had 4 EJBs made like this:

       

      ctx = new InitialContext();

      DiaryServiceLocal diaryService = (DiaryServiceLocal) ctx.lookup("LarisEAR/DiaryServiceBean/local");

       

      When saw in new server 7.1 that context creation is changed, we created four of these:

       

      @EJB(lookup="java:app/LarisEJB/DiaryServiceBean!com.wiset.laris.service.DiaryServiceLocal")

      private DiaryServiceLocal diaryServiceLocal;

       

      But when running app, only first EJB was resolved - all others where null, so application stopped when accessing other EJBs...

       

      We made workaround by putting all four EJBs into one:

       

      private LarisServiceLocal larisServiceLocal1;

       

      ... and accessing it from the session scope - first time we set it there and read it when needed:

       

        LarisServiceLocal lar = (LarisServiceLocal)getSessionScope().get("contextLaris");

        if (lar == null) {

         lar = larisServiceLocal1;

         getSessionScope().put("contextLaris", lar);

        }

        return lar;

      }

       

      Session bean is of type @Stateless and it's interface is @@Local

      ----

       

      Of course, we are not satisfied with this workaround - we want to have separate EJBs... Is it possible with JBoss 7.1? With AS6.0 it worked fine as described at the begining...

      Thanks

      Mihovil

        • 1. Re: When migrating from AS6.0 to AS7.2 multiple EJB contexts do not work any more
          ctomc

          Hi,

           

          this is really strange as this should not give you any problems. Are this ejbs all in same ejb jar? or separate jars?

          i saw problems like this when there ware ejb-api's jar mistakenly in my application.

           

          --

          tomaz

          • 2. Re: When migrating from AS6.0 to AS7.2 multiple EJB contexts do not work any more
            prasad.deshpande

            Could you please give some more information on packaging of your application & ejb's? Also, what type of class is it where you are injecting beans (ejb/servlet/app-client/pojo)?

            • 3. Re: When migrating from AS6.0 to AS7.2 multiple EJB contexts do not work any more
              mihovil

              Hi Prasad,

              We injecting beans into managed bean.

               

              Structure:

               



              EAR:
              ---lib
              -------larisModel.jar
              ---META_INF
              -------MANIFEST.MF (empty)
              ---larisEjb.jar
              ---larisUI.war



              1. LarisEAR.ear\LarisUI.war\WEB-INF\lib\:


              primefaces-3.0.jar
              jasperreports-fonts-4.5.0.jar
              jasperreports-4.5.0.jar
              iText-2.1.5.ja
              commons-logging-1.1.jar
              commons-io-1.4.jar
              commons-fileupload-1.2.2.jar
              commons-digester-1.7.jar
              commons-collections-3.2.1.jar
              commons-beanutils-1.8.2.jar

              • 4. Re: When migrating from AS6.0 to AS7.2 multiple EJB contexts do not work any more
                prasad.deshpande

                We injecting beans into managed bean.

                And where that managed bean packaged in? I presume in larisModel.jar?

                • 5. Re: When migrating from AS6.0 to AS7.2 multiple EJB contexts do not work any more
                  ctomc

                  I am just curious is there any special reason you are using ear deployment for such simple deployment scenario?

                  as of EE6 you can have ejb3 jars inside war/web-inf/lib and it should work, as far as i see that would mean just to move larisModel.jar and larisEJB.jar to war/web-inf/lib and then deploy .war instead of ear.

                  I thing this would really simplfy your deployment and also some of your problems will go away...

                   

                   

                  --

                  tomaz

                  • 6. Re: When migrating from AS6.0 to AS7.2 multiple EJB contexts do not work any more
                    mihovil

                    We use this deployment directly from Eclipse and it worked well with AS6.0. Now we have finished project and wanting to make it work with AS7.1 (because of performance reasons). We do not see how the problems will go away by packaging it differently? The main problem is decreasing of connection pool...

                    thx anyway, Mihovil

                    • 7. Re: When migrating from AS6.0 to AS7.2 multiple EJB contexts do not work any more
                      sfcoy

                      Mihovil Santic wrote:

                      ...

                       

                      When saw in new server 7.1 that context creation is changed, we created four of these:

                       

                      @EJB(lookup="java:app/LarisEJB/DiaryServiceBean!com.wiset.laris.service.DiaryServiceLocal")

                      private DiaryServiceLocal diaryServiceLocal;

                       

                      ...

                       

                      This should work with no lookup at all specified (in both AS6 and AS7):

                       

                      {code:java}@EJB

                      private DiaryServiceLocal diaryServiceLocal;

                      {code}

                       

                      Later you say that you're injecting into a "managed" bean. Did you mean a JSF managed bean or a bean managed by something else?

                      • 8. Re: When migrating from AS6.0 to AS7.2 multiple EJB contexts do not work any more
                        mihovil

                        Hi Stephen - this works actually what you said. We use JSF managed bean. Still only first EJB is interpreted ok by JBoss - other are null - so we enclosed all in one... we can live with this but cannot say it is right solution...

                        • 9. Re: When migrating from AS6.0 to AS7.2 multiple EJB contexts do not work any more
                          jaikiran

                          Mihovil Santic wrote:

                           

                          Still only first EJB is interpreted ok by JBoss - other are null -

                          That really can't be right. Could you try going back to using multiple @EJB injections in that managed bean and post the exact code along with the entire exception stacktrace (which shows the NullPointerException).

                          • 10. Re: When migrating from AS6.0 to AS7.2 multiple EJB contexts do not work any more
                            mihovil

                            Hi,

                             

                            Can't do that right now - will prepare later - but this is trace from our server startup - there are some strange things but do not know how to fix'em now:

                             

                            Calling "C:\jboss-as-7.1.0.Final-SNAPSHOT\bin\standalone.conf.bat"

                            ===============================================================================

                             

                             

                              JBoss Bootstrap Environment

                             

                             

                              JBOSS_HOME: C:\jboss-as-7.1.0.Final-SNAPSHOT

                             

                             

                              JAVA: C:\Program Files\Java\jdk1.6.0_25\bin\java

                             

                             

                              JAVA_OPTS: -XX:+TieredCompilation -Dprogram.name=standalone.bat -Xms64M -Xmx51

                            2M -XX:MaxPermSize=256M -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.se

                            rver.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.war

                            ning=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.server.default.c

                            onfig=standalone.xml

                             

                             

                            ===============================================================================

                             

                             

                            07:40:18,229 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA

                            07:40:19,229 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA

                            07:40:19,370 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.0.Final-SNAPSHOT "Flu

                            x Capacitor" starting

                            07:40:26,292 INFO  [org.jboss.as.server] JBAS015888: Creating http management se

                            rvice using socket-binding (management-http)

                            07:40:26,339 INFO  [org.xnio] XNIO Version 3.0.0.GA

                            07:40:26,479 INFO  [org.jboss.as.configadmin] JBAS016200: Activating ConfigAdmin

                            Subsystem

                            07:40:26,511 INFO  [org.jboss.as.webservices] JBAS015537: Activating WebServices

                            Extension

                            07:40:26,542 INFO  [org.jboss.as.security] JBAS013101: Activating Security Subsy

                            stem

                            07:40:26,558 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.0.GA

                            07:40:26,729 INFO  [org.jboss.as.naming] JBAS011800: Activating Naming Subsystem

                             

                             

                            07:40:26,714 INFO  [org.jboss.as.osgi] JBAS011940: Activating OSGi Subsystem

                            07:40:29,448 INFO  [org.jboss.as.clustering.infinispan] JBAS010280: Activating I

                            nfinispan subsystem.

                            07:40:29,823 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log han

                            dlers

                            07:40:30,761 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.0.GA

                            07:40:34,214 INFO  [org.jboss.as.connector] (MSC service thread 1-1) JBAS010408:

                            Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)

                            07:40:34,542 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS01

                            5400: Bound mail session [java:jboss/mail/Default]

                            07:40:34,604 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC se

                            rvice thread 1-2) JBoss Web Services - Stack CXF Server 4.0.1.GA

                            07:40:34,979 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread

                            1-2) JBAS015012: Started FileSystemDeploymentService for directory C:\jboss-as-7

                            .1.0.Final-SNAPSHOT\standalone\deployments

                            07:40:34,995 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBA

                            S015876: Starting deployment of "LarisEAR.ear"

                            07:40:35,058 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread

                            1-2) Starting Coyote HTTP/1.1 on http--0.0.0.0-9090

                            07:40:35,339 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-t

                            hreads - 1) JBAS015014: Re-attempting failed deployment ojdbc6.jar

                            07:40:35,776 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100:

                            Listening on /127.0.0.1:9999

                            07:40:36,026 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100:

                            Listening on /0.0.0.0:4447

                            07:40:39,870 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBA

                            S015876: Starting deployment of "LarisEJB.jar"

                            07:40:39,870 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBA

                            S015876: Starting deployment of "LarisUI.war"

                            07:40:39,979 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-2) Cla

                            ss Path entry LarisEJBClient.jar in "/C:/jboss-as-7.1.0.Final-SNAPSHOT/bin/conte

                            nt/LarisEAR.ear/LarisEJB.jar"  does not point to a valid jar for a Class-Path re

                            ference.

                            07:40:44,354 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-2) Cla

                            ss Path entry iText-toolbox.jar in "/C:/jboss-as-7.1.0.Final-SNAPSHOT/bin/conten

                            t/LarisEAR.ear/LarisUI.war/WEB-INF/lib/iText-2.1.5.jar"  does not point to a val

                            id jar for a Class-Path reference.

                            07:40:44,370 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-2) Cla

                            ss Path entry iText-toolbox-2.1.5.jar in "/C:/jboss-as-7.1.0.Final-SNAPSHOT/bin/

                            content/LarisEAR.ear/LarisUI.war/WEB-INF/lib/iText-2.1.5.jar"  does not point to

                            a valid jar for a Class-Path reference.

                            07:40:44,370 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-2) Cla

                            ss Path entry bcmail-jdk14-138.jar in "/C:/jboss-as-7.1.0.Final-SNAPSHOT/bin/con

                            tent/LarisEAR.ear/LarisUI.war/WEB-INF/lib/iText-2.1.5.jar"  does not point to a

                            valid jar for a Class-Path reference.

                            07:40:44,386 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-2) Cla

                            ss Path entry bcprov-jdk14-138.jar in "/C:/jboss-as-7.1.0.Final-SNAPSHOT/bin/con

                            tent/LarisEAR.ear/LarisUI.war/WEB-INF/lib/iText-2.1.5.jar"  does not point to a

                            valid jar for a Class-Path reference.

                            07:40:44,948 INFO  [org.jboss.as.jpa] (MSC service thread 1-2) JBAS011401: Read

                            persistence.xml for LarisModel

                            07:40:46,745 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeplo

                            ymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean name

                            d LarisServiceBean in deployment unit subdeployment "LarisEJB.jar" of deployment

                            "LarisEAR.ear" are as follows:

                             

                             

                                    java:global/LarisEAR/LarisEJB/LarisServiceBean!com.wiset.laris.service.L

                            arisServiceLocal

                                    java:app/LarisEJB/LarisServiceBean!com.wiset.laris.service.LarisServiceL

                            ocal

                                    java:module/LarisServiceBean!com.wiset.laris.service.LarisServiceLocal

                                    java:global/LarisEAR/LarisEJB/LarisServiceBean

                                    java:app/LarisEJB/LarisServiceBean

                                    java:module/LarisServiceBean

                             

                             

                            07:40:52,839 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS018559: De

                            ployed "LarisEAR.ear"

                            07:40:52,854 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774

                            : Service status report

                            JBAS014775:    New missing/unsatisfied dependencies:

                                  service jboss.jdbc-driver.ojdbc6_jar (missing) dependents: [service jboss.

                            data-source.java:/LarisDS]

                             

                             

                            07:40:52,901 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss AS

                            7.1.0.Final-SNAPSHOT "Flux Capacitor" started (with errors) in 35609ms - Started

                            277 of 442 services (88 services failed or missing dependencies, 76 services ar

                            e passive or on-demand)

                            07:40:52,917 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBA

                            S015876: Starting deployment of "ojdbc6.jar"

                            07:40:53,448 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1

                            -2) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (

                            version 11.1)

                            07:40:53,589 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service

                            thread 1-1) JBAS010400: Bound data source [java:/LarisDS]

                            07:40:53,651 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011402: Start

                            ing Persistence Unit Service 'LarisEAR.ear#LarisModel'

                            07:40:56,370 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC serv

                            ice thread 1-2) Initializing Mojarra 2.1.5 (SNAPSHOT 20111202) for context '/Lar

                            isUI'

                            07:40:56,417 INFO  [org.hibernate.annotations.common.Version] (MSC service threa

                            d 1-1) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}

                            07:40:56,433 INFO  [org.hibernate.Version] (MSC service thread 1-1) HHH000412: H

                            ibernate Core {4.0.1.Final}

                            07:40:56,448 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-1) HHH0

                            00206: hibernate.properties not found

                            07:40:56,464 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-1) HHH0

                            00021: Bytecode provider name : javassist

                            07:40:56,495 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-1

                            ) HHH000204: Processing PersistenceUnitInfo [

                                    name: LarisModel

                                    ...]

                            07:41:01,323 INFO  [org.hibernate.service.jdbc.connections.internal.ConnectionPr

                            oviderInitiator] (MSC service thread 1-1) HHH000130: Instantiating explicit conn

                            ection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvid

                            er

                            07:41:08,214 INFO  [org.hibernate.dialect.Dialect] (MSC service thread 1-1) HHH0

                            00400: Using dialect: org.hibernate.dialect.OracleDialect

                            07:41:08,229 WARN  [org.hibernate.dialect.Oracle9Dialect] (MSC service thread 1-

                            1) HHH000063: The Oracle9Dialect dialect has been deprecated; use either Oracle9

                            iDialect or Oracle10gDialect instead

                            07:41:08,229 WARN  [org.hibernate.dialect.OracleDialect] (MSC service thread 1-1

                            ) HHH000064: The OracleDialect dialect has been deprecated; use Oracle8iDialect

                            instead

                            07:41:08,276 INFO  [org.hibernate.engine.transaction.internal.TransactionFactory

                            Initiator] (MSC service thread 1-1) HHH000268: Transaction strategy: org.hiberna

                            te.engine.transaction.internal.jta.CMTTransactionFactory

                            07:41:08,276 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (M

                            SC service thread 1-1) HHH000397: Using ASTQueryTranslatorFactory

                            07:41:08,354 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-

                            1) Hibernate Validator 4.2.0.Final

                            07:41:18,042 INFO  [org.primefaces.webapp.PostConstructApplicationEventListener]

                            (MSC service thread 1-2) Running on PrimeFaces 3.1

                            07:41:18,104 INFO  [org.jboss.web] (MSC service thread 1-2) JBAS018210: Register

                            ing web context: /LarisUI

                            07:41:21,729 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018

                            559: Deployed "ojdbc6.jar"

                            07:41:21,729 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBA

                            S014774: Service status report

                            JBAS014776:    Newly corrected services:

                                  service jboss.jdbc-driver.ojdbc6_jar (no longer required)