12 Replies Latest reply on Oct 24, 2012 2:22 AM by sfcoy

    JBAS014343: Invocation was not associated with an instance

    chandrarsa

      I deployed CMP2.0 in JBOSS AS7 sucessfully that i can see in logs but I am getting invocation exception during access entity bean home itself.

       

      Do I need to take care any thing from client side?

       

      10:32:11,175 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named ExampleTable in deployment unit deployment "Migr
      ationEJB.jar" are as follows:

              java:global/MigrationEJB/ExampleTable!com.migration.entity.ExampleTableHome
              java:app/MigrationEJB/ExampleTable!com.migration.entity.ExampleTableHome
              java:module/ExampleTable!com.migration.entity.ExampleTableHome
              java:jboss/exported/MigrationEJB/ExampleTable!com.migration.entity.ExampleTableHome
              java:global/MigrationEJB/ExampleTable!com.migration.entity.ExampleTable
              java:app/MigrationEJB/ExampleTable!com.migration.entity.ExampleTable
              java:module/ExampleTable!com.migration.entity.ExampleTable
              java:jboss/exported/MigrationEJB/ExampleTable!com.migration.entity.ExampleTable

       

       

      JNDI string from client : ejb:/MigrationEJB//ExampleTable!com.migration.entity.ExampleTable

       

      Hashtable<String, String> envs =

      new Hashtable<String, String>();

      envs.put(Context.

      URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

      InitialContext context;

       

      try {

      context =

      new InitialContext(envs);

      String lookupName =

      this.getEntityBeanLookupName();

      System.

      out.println("JNDI : " + lookupName);

      ExampleTable remote = (ExampleTable) context.lookup(lookupName);

       

       

      ExampleTableHome home = (ExampleTableHome) remote.getEJBHome();

       

       

       

      10:33:37,236 ERROR [org.jboss.ejb3.invocation] (EJB default - 2) JBAS014134: EJB Invocation failed on component ExampleTable for method public abstract javax.ejb.EJBHome javax.ejb.EJBObject.getEJBHome() throws
      java.rmi.RemoteException: javax.ejb.NoSuchEJBException: JBAS014343: Invocation was not associated with an instance, primary key was null, instance may have been removed
              at org.jboss.as.ejb3.component.entity.interceptors.EntityBeanAssociatingInterceptor.processInvocation(EntityBeanAssociatingInterceptor.java:57) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
              at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
              at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:80) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
              at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
              at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
              at org.jboss.as.ejb3.component.interceptors.EjbExceptionTransformingInterceptorFactories$1.processInvocation(EjbExceptionTransformingInterceptorFactories.java:65) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Fi
      nal]
              at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

        • 1. Re: JBAS014343: Invocation was not associated with an instance
          wdfink

          How does your jboss-ejb-client.properties look like?

          Are you able to call a simple stateless session bean?

          • 2. Re: JBAS014343: Invocation was not associated with an instance
            chandrarsa

            Yes I can able to call simple statless session bean.

             

             

             

            endpoint.name=client-endpoint
            remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
            remote.connections=default
            remote.connection.default.host=localhost
            remote.connection.default.port = 4447
            remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

            • 3. Re: JBAS014343: Invocation was not associated with an instance
              sfcoy

              This looks like you're running in the same server. If that is the case, then you really just need:

               

              {code:java}     ...

                   Context initialContext = new InitialContext();

                   ExampleTable remote = (ExampleTable) initialContext.lookup("java:global/MigrationEJB/ExampleTable!com.migration.entity.ExampleTable");

                   ...

              {code}

               

              If it's the same application, then you should probably be linking the bean to your client in a deployment descriptor and looking up an ENC name like java:comp/env/ejb/ExampleTable.

              • 4. Re: JBAS014343: Invocation was not associated with an instance
                chandrarsa

                I am calling CMP bean out of the server. Just like thick client application.

                 

                 

                 

                ------------------

                deployment descriptor ejb-jar.xml

                ------------------

                <entity>
                   <ejb-name>ExampleTable</ejb-name>
                   <home>com.migration.entity.ExampleTableHome</home>
                   <remote>com.migration.entity.ExampleTable</remote>
                   <ejb-class>com.migration.entity.ExampleTableEJB</ejb-class>
                   <persistence-type>Container</persistence-type>
                   <prim-key-class>java.lang.Integer</prim-key-class>
                   <reentrant>False</reentrant>
                   <cmp-version>2.x</cmp-version>
                   <abstract-schema-name>ExampleTableEJB</abstract-schema-name>
                   <cmp-field><field-name>implEmpName</field-name></cmp-field>
                   <cmp-field><field-name>implEmptype</field-name></cmp-field>
                   <primkey-field>implEmptype</primkey-field>
                   <ejb-ref>
                    <ejb-ref-name>java:global/ExampleTableJNDI</ejb-ref-name>
                    <ejb-ref-type>Entity</ejb-ref-type>
                    <home>com.migration.entity.ExampleTableHome</home>
                    <remote>com.migration.entity.ExampleTable</remote>
                   </ejb-ref>
                   <resource-ref>
                    <res-ref-name>jdbc/database</res-ref-name>
                    <res-type>javax.sql.DataSource</res-type>
                    <res-auth>Container</res-auth>
                   </resource-ref>
                  </entity>

                 

                 

                 

                • 5. Re: JBAS014343: Invocation was not associated with an instance
                  sfcoy

                  This sentence makes no sense to me. Try to be more explicit.

                   

                  {quote}I am calling CMP bean out of the server{quote}

                   

                  Also, did you intend that the ejb-ref fragment below be self-referential? You would not normally need this.

                  The <ejb-ref-name> value makes no sense either. It would typically be "ejb/ExampleTable", which would be looked up in JNDI using the value "java:comp/env/ejb/ExampleTable".

                  • 6. Re: JBAS014343: Invocation was not associated with an instance
                    sfcoy

                    And to add to the confusion, this:

                     

                    {quote}10:32:11,175 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named ExampleTable in deployment unit deployment "Migr{quote}

                    refers to a session bean - not an entity bean.

                     

                    Have you tried to sanitise some names here? You may have jumbled something up.

                    • 7. Re: JBAS014343: Invocation was not associated with an instance
                      wdfink

                      If I understand correct you try to use an Entity direct from a remote client.

                      This is not recommended because the performance is bad, but in EJB2 it was possible to do. With EJB3 the entities (JPA POJO) are not longer accessable from remote.

                      In former AS versions it was possible to use your approach, but I'm not sure whether the new ejb-client will support this.

                      • 8. Re: JBAS014343: Invocation was not associated with an instance
                        chandrarsa

                        Yes, it’s remote client. I wrote simple java class to invoke deployed ejb’s

                         

                        Your observations are correct. Logs are saying miss understanding information about deployment but I deployed Entity Bean.

                        I am using ejb2

                        public abstract class ExampleTableEJB implements EntityBean{

                         

                                        // table mappings

                                        public abstract Integer getImplEmptype();

                         

                                        public abstract void setImplEmptype(Integer emptype);

                         

                                        public abstract String getImplEmpName();

                         

                                        public abstract void setImplEmpName(String empname);

                         

                         

                        • 9. Re: JBAS014343: Invocation was not associated with an instance
                          chandrarsa

                          Client is attached

                          • 10. Re: JBAS014343: Invocation was not associated with an instance
                            sfcoy

                            Just backing up a bit.

                             

                            I don't think the following makes any sense:

                             

                            {code:java}ExampleTable remote = (ExampleTable) context.lookup(lookupName);{code}

                             

                            A CMP entity bean can only be looked up using ExampleTableHome.findByPrimaryKey(...), created using ExampleTableHome.create(...), or using some other "finder" method on the home interface.

                             

                            If you look it up directly in JNDI, you will get an instance with no identity, and that is what JBoss is complaining about.

                            • 11. Re: JBAS014343: Invocation was not associated with an instance
                              chandrarsa

                              I followed as Session Beans. It’s blind mistake. K

                               

                              Now changed invocation then I am getting below exception from client.

                               

                              Do I need to change anything in jboss-ejb-client.properties for entity beans? or Do I need any extra jars required in class path?

                               

                              java:global/ExampleTableJNDI was mentioned in ejb-jar.xml

                              javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

                                    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)

                                    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)

                               

                               

                               

                              Hashtable<String, String> envs = new Hashtable<String, String>();

                                          envs.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                                          InitialContext context;

                               

                              try {

                                                context = new InitialContext(envs);

                                                String lookupName = this.getEntityBeanLookupName();

                                                Object object = context.lookup("java:global/ExampleTableJNDI");

                                                ExampleTableHome home = (ExampleTableHome)PortableRemoteObject.narrow(object, ExampleTableHome.class);

                                                home.create("Test2", 11);

                               

                              • 12. Re: JBAS014343: Invocation was not associated with an instance
                                sfcoy

                                Now you need to go and read AS71 EJB invocations from a remote client using JNDI.

                                 

                                Secondly your "mention" of "java:global/ExampleTableJNDI" in the ejb-jar.xml file makes no sense. This does not set the JNDI name of the EJB.

                                The ejb-ref fragment you have in your ejb-jar.xml file only makes sense if the class com.migration.entity.ExampleTableEJB is internally looking itself up in JNDI. And the content of it's ejb-ref-name is incorrectly formed anyway, as I mentioned earlier.