3 Replies Latest reply on Jul 20, 2012 3:48 AM by Mayank Gupta

    JBoss AS 7.1 get sessionfactory and datasource failed

    Areak Huang Newbie

      Hi all,

       

      I update jboss4.2 to jboss7.1.(JSF2+Hibernate4 + EJB2.1+AS 7.1) ,but get sessionfactory and datasource failed. waitting for your help.

       

      I know  that AS7 not support EJB2.x,but AS7.1can do it. I has been configured some module like datasource,hibernate,mail,myfaces and other modules.

       

       

      1、datasource and mail bound success.

       

      server.log:

       

      15:57:30,315 INFO  [org.jboss.as.naming] (MSC service thread 1-2) JBAS011802: Starting Naming Service

      15:57:30,409 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-4) JBAS015400: Bound mail session [java:jboss/mail/Default]

      15:57:30,534 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 26) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 10.2)

      15:57:30,643 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-3) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080

      15:57:31,112 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-1) JBoss Web Services - Stack CXF Server 4.0.1.GA

      15:57:31,393 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/OracleDS]

      15:57:31,440 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) JBAS015012: Started FileSystemDeploymentService for directory D:\ALFRED\jboss-as-7.1.0.Final\standalone\deployments

       

      * * * * * *

       

       

      2、web.xml:

       

          <resource-ref>

              <res-ref-name>jdbc/OracleDS</res-ref-name>

              <res-type>javax.sql.DataSource</res-type>

              <res-auth>Container</res-auth>

              <lookup-name>java:jboss/OracleDS</lookup-name>

          </resource-ref>

       

         <resource-ref >

            <res-ref-name>SessionFactory</res-ref-name>

            <res-type>org.hibernate.SessionFactory</res-type>

            <res-auth>Container</res-auth>

         </resource-ref>


      * * * * * *

       

       

       

      3、one bean :BeBean

       

      /**

      * @ejb.bean name="Be" display-name="Name for Be" description="Description for

      *           Be" jndi-name="ejb/Be" type="Stateless" view-type="remote"

      *           transaction-type="Container

      * @ejb.resource-ref res-ref-name = "SessionFactory" res-type =

      *                   "org.hibernate.SessionFactory" res-auth = "Container"

      * @jboss.resource-ref res-ref-name = "SessionFactory" jndi-name =

      *                     "java:/SessionFactory"

      * @ejb.resource-ref res-ref-name = "OracleDS" res-type =

      *                   "javax.sql.DataSource" res-auth = "Container"

      *

      * @jboss.resource-ref res-ref-name = "OracleDS" jndi-name =

      *                     "java:jboss/OracleDS"

      *

      */

      public class BeBean implements SessionBean {

       

      * * * * * *

       

      4、ejb-jar.xml

       

            <session >

               <description><![CDATA[Description for Be]]></description>

               <display-name>Name for Be</display-name>

       

       

               <ejb-name>Be</ejb-name>

       

       

               <home>com.mycompany.weberp.ejb.interfaces.BeHome</home>

               <remote>com.mycompany.weberp.ejb.interfaces.Be</remote>

               <ejb-class>com.mycompany.weberp.ejb.beans.BeBean</ejb-class>

               <session-type>Stateless</session-type>

               <transaction-type>Container</transaction-type>

       

       

               <resource-ref >

                  <res-ref-name>SessionFactory</res-ref-name>

                  <res-type>org.hibernate.SessionFactory</res-type>

                  <res-auth>Container</res-auth>

               </resource-ref>

               <resource-ref >

                  <res-ref-name>OracleDS</res-ref-name>

                  <res-type>javax.sql.DataSource</res-type>

                  <res-auth>Container</res-auth>

               </resource-ref>

       

            </session>


      * * * * * *

       

      5、jboss.xml :

       

            <session>

               <ejb-name>Be</ejb-name>

               <jndi-name>ejb/Be</jndi-name>

       

       

               <resource-ref>

                  <res-ref-name>SessionFactory</res-ref-name>

                  <jndi-name>java:/SessionFactory</jndi-name>

               </resource-ref>

               <resource-ref>

                  <res-ref-name>OracleDS</res-ref-name>

                  <jndi-name>java:jboss/OracleDS</jndi-name>

               </resource-ref>

       

       

            </session>

       

       

      6、when I start the AS first it can start nomal but then errors are coming:

       

      Correct:

       

       

      15:58:55,177 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named EmployeeMaint in deployment unit subdeployment "myEjb.jar" of deployment "myWeberp.ear" are as follows:

       

       

                java:global/myWeberp/myEjb/EmployeeMaint!com.mycompany.weberp.ejb.interfaces.EmployeeMaintHome

                java:app/myEjb/EmployeeMaint!com.mycompany.weberp.ejb.interfaces.EmployeeMaintHome

                java:module/EmployeeMaint!com.mycompany.weberp.ejb.interfaces.EmployeeMaintHome

                java:jboss/exported/myWeberp/myEjb/EmployeeMaint!com.mycompany.weberp.ejb.interfaces.EmployeeMaintHome

                java:global/myWeberp/myEjb/EmployeeMaint!com.mycompany.weberp.ejb.interfaces.EmployeeMaint

                java:app/myEjb/EmployeeMaint!com.mycompany.weberp.ejb.interfaces.EmployeeMaint

                java:module/EmployeeMaint!com.mycompany.weberp.ejb.interfaces.EmployeeMaint

                java:jboss/exported/myWeberp/myEjb/EmployeeMaint!com.mycompany.weberp.ejb.interfaces.EmployeeMaint

       

      Errors:

       

      JBAS014775:    New missing/unsatisfied dependencies:

            service jboss.naming.context.java.SessionFactory (missing) dependents: [service jboss.naming.context.java.module.myWeberp.myWeb.env.SessionFactory]

       

      service jboss.naming.context.java.jboss.resources.OracleDS (missing) dependents: [service jboss.naming.context.java.comp.myWeberp.myEjb.CPI.env.OracleDS, service jboss.naming.context.java.comp.myWeberp.myEjb.MtgWO3P.env.OracleDS, service jboss.naming.context.java.comp.myWeberp.myEjb.MtgRmaAlloc.env.OracleDS, service jboss.naming.context.java.comp.myWeberp.myEjb.BuildPlanGME.env.OracleDS, JBAS014799: ... and 96 more ]

       

      service jboss.naming.context.java.jboss.resources.SessionFactory (missing) dependents: [service jboss.naming.context.java.comp.myWeberp.myEjb.DocRemark.env.SessionFactory, service jboss.naming.context.java.comp.myWeberp.myEjb.BDCT.env.SessionFactory, service jboss.naming.context.java.comp.myWeberp.myEjb.WipEcnEditor.env.SessionFactory, service jboss.naming.context.java.comp.myWeberp.myEjb.DeptShopFloor3P.env.SessionFactory, JBAS014799: ... and 359 more ]

       

       

      Thank you so much.

       

      Areak

        • 1. Re: JBoss AS 7.1 get sessionfactory and datasource failed
          Scott Marlow Master

          JNDI name "java:/SessionFactory" is not valid.  Try updating the jndi name associated with the session factory.  Change from "java:/SessionFactory" to "java:app/SessionFactory".

           

          Other migration tips are here.

          • 2. Re: JBoss AS 7.1 get sessionfactory and datasource failed
            Areak Huang Newbie

            Hi Scott,

             

            Thank you for your reply.

             

            I change from "java:/SessionFactory" to "java:app/SessionFactory".

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

            like this in my bean(BeBean.java):

             

            /**

            * @ejb.bean name="Be" display-name="Name for Be" description="Description for

            *           Be" jndi-name="ejb/Be" type="Stateless" view-type="remote"

            *           transaction-type="Container

            * @ejb.resource-ref res-ref-name = "SessionFactory" res-type =

            *                   "org.hibernate.SessionFactory" res-auth = "Container"

            * @jboss.resource-ref res-ref-name = "SessionFactory" jndi-name =

            *                     "java:app/SessionFactory"

            * @ejb.resource-ref res-ref-name = "OracleDS" res-type =

            *                   "javax.sql.DataSource" res-auth = "Container"

            *

            * @jboss.resource-ref res-ref-name = "OracleDS" jndi-name =

            *                     "java:jboss/OracleDS"

            *

            */

            public class BeBean implements SessionBean {

             

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

             

            and in jboss-web.xml

             

               <resource-ref>

                  <res-ref-name>SessionFactory</res-ref-name>

                  <jndi-name>java:app/SessionFactory</jndi-name>

               </resource-ref>

             

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

            then I use Ant to xdoclet,produce ejb-jar.xml and jboss.xml

             

            ejb-jar.xml:

                  <session >

                     <description><![CDATA[Description for Be]]></description>

                     <display-name>Name for Be</display-name>

             

                     <ejb-name>Be</ejb-name>

             

                     <home>com.mycompany.weberp.ejb.interfaces.BeHome</home>

                     <remote>com.mycompany.weberp.ejb.interfaces.Be</remote>

                     <ejb-class>com.mycompany.weberp.ejb.beans.BeBean</ejb-class>

                     <session-type>Stateless</session-type>

                     <transaction-type>Container</transaction-type>

             

                     <resource-ref >

                        <res-ref-name>SessionFactory</res-ref-name>

                        <res-type>org.hibernate.SessionFactory</res-type>

                        <res-auth>Container</res-auth>

                     </resource-ref>

                     <resource-ref >

                        <res-ref-name>OracleDS</res-ref-name>

                        <res-type>javax.sql.DataSource</res-type>

                        <res-auth>Container</res-auth>

                     </resource-ref>

                  </session>

             

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

            jboss.xml:

            <session>

                     <ejb-name>Be</ejb-name>

                     <jndi-name>ejb/Be</jndi-name>

                     <resource-ref>

                        <res-ref-name>SessionFactory</res-ref-name>

                        <jndi-name>java:app/SessionFactory</jndi-name>

                     </resource-ref>

                     <resource-ref>

                        <res-ref-name>OracleDS</res-ref-name>

                        <jndi-name>java:jboss/OracleDS</jndi-name>

                     </resource-ref>

                  </session>

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

            but I got the same log in server.log

             

            JBAS014775:    New missing/unsatisfied dependencies:

                  service jboss.naming.context.java.app.myWeberp.SessionFactory (missing) dependents: [service jboss.naming.context.java.module.myWeberp.mtgWeb.env.SessionFactory]

                  service jboss.naming.context.java.jboss.resources.OracleDS (missing) dependents: [service jboss.naming.context.java.comp.myWeberp.myEjb.CPI.env.OracleDS, service jboss.naming.context.java.comp.myWeberp.myEjb.MtgWO3P.env.OracleDS, service jboss.naming.context.java.comp.myWeberp.myEjb.MtgRmaAlloc.env.OracleDS, service jboss.naming.context.java.comp.myWeberp.myEjb.Bte.env.OracleDS, JBAS014799: ... and 96 more ]

                  service jboss.naming.context.java.jboss.resources.SessionFactory (missing) dependents: [service jboss.naming.context.java.comp.myWeberp.myEjb.DocRemark.env.SessionFactory, service jboss.naming.context.java.comp.myWeberp.myEjb.BDCT.env.SessionFactory, service jboss.naming.context.java.comp.myWeberp.myEjb.DeptShopFloor3P.env.SessionFactory, service jboss.naming.context.java.comp.myWeberp.myEjb.WipEcnEditor.env.SessionFactory, JBAS014799: ... and 359 more ]

             

            when I "Ctrl + C" in standalone.bat to stop the server,the last log is:

            JBAS014776:    Newly corrected services:

                  service jboss.naming.context.java.SessionFactory (new available)

                  service jboss.naming.context.java.jboss.resources.OracleDS (new available)

                  service jboss.naming.context.java.jboss.resources.SessionFactory (new available)

             

            11:02:44,508 INFO  [org.jboss.as] JBAS015950: JBoss AS 7.1.0.Final "Thunder" stopped in 28ms

             

            I do not know why my bean can not get the SessionFactory.In fact I can not understand my datasource was bound, but can not get it.

             

            I input http://localhost:9990/.can see that

            Datasource

            Name                                               JNDI                                                  Enabled?

            java:jboss/OracleDS                  

            ava:jboss/OracleDS                                     

            true




             

            who can help me?

             

            Than you so much.

             

            Best Regards;

             

            Areak

            • 3. Re: JBoss AS 7.1 get sessionfactory and datasource failed
              Mayank Gupta Newbie

              Hello Areak,

               

              I also facing the same issue.

              If you found the solution please post it.

               

              Regards,

              Mayank