10 Replies Latest reply on Aug 26, 2013 2:12 AM by Nav Diesel Branched to a new discussion.

    How to configure Ejb 2 entities on JBoss 7.1?

    jsebfranck Newbie

      Hi,

       

      Does anyone know how it is possible to configure ejb 2 entities on jboss 7.1? Is there some tutorials or specific documentations for ejb 2?

       

      Thanks in advance !

        • 1. Re: How to configure Ejb 2 entities on JBoss 7.1?
          Michael Rootman Newbie

          Hi,

           

          Was any progress? Did you succeed to find?

          • 2. Re: How to configure Ejb 2 entities on JBoss 7.1?
            Ondra Chaloupka Master

            I suppose that EJB2 entities work fine in JBoss AS7 and it's possible to configure them in the same way as in JBoss5. But unfortunatelly there is no special tutorial on this theme for AS7 what I know.

            Maybe you can try to check code of tests in Jboss testsuite on github.

            This could be maybe uselful for you:

             

            https://github.com/jbossas/jboss-as/blob/master/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/entity/cmp/simple/SimpleCMPUnitTestCase.java

            https://github.com/jbossas/jboss-as/tree/master/testsuite/integration/basic/src/test/resources/ejb/entity/cmp/simple

            • 3. Re: How to configure Ejb 2 entities on JBoss 7.1?
              Michael Rootman Newbie

              Thank you for reply, I followed provided links but no success.

               

              I am deploying jar with 2.1 entities packed in EAR and deployment is successful, though there are no log records of entity deployment exist. Local lookup within EAR fails.  Jconsole  does not show any EJB entities in the tree for simple.jar

               

              Based on test code and considering, that I deploy jar within EAR lookup path is: java:app/EAR_NAME/simple/ SimpleEJB!org.jboss.as.test.integration.ejb.entity.cmp.simple.SimpleHome

               

              Please advise  what is missing,

              • 4. Re: How to configure Ejb 2 entities on JBoss 7.1?
                Stig Henriksen Newbie

                I've managed to configure EJB 2.1 entities using just ejb-jar.xml. Can you post your current config here?

                 

                By the way, does anyone know how to configure instance caching in 7.1 for EJB 2.x beans? I've managed to configure instance pooling in standalone.xml, but I cannot figure out how to configure the instance cache. I see that in previous versions of JBoss this was done in jboss.xml with <cache-policy-conf>, but where is this supposed to be done now?

                • 5. Re: How to configure Ejb 2 entities on JBoss 7.1?
                  Michael Rootman Newbie

                  My Deployment includes:

                  TEST.EAR

                  --sample.jar (2.1 entities from jboss example)

                  --initTest.war

                   

                  application.xml in TEST.EAR

                   

                  <?xml version="1.0" encoding="UTF-8"?>

                  <application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                               version="6"

                               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">

                    <display-name>TEST</display-name>

                            <module>

                                           <ejb>simple.jar</ejb>

                            </module>

                    <module>

                                           <web>

                                                          <web-uri>initTest.war</web-uri>

                                                          <context-root>/test</context-root>

                                           </web>

                            </module> 

                  </application>

                   

                  ejb-jar.xml in simple.jar:

                   

                  <?xml version="1.0"?>

                  <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"

                           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"

                           version="3.1">

                     <enterprise-beans>

                        <entity>

                           <ejb-name>SimpleEJB</ejb-name>

                           <local-home>org.jboss.as.test.integration.ejb.entity.cmp.simple.SimpleHome</local-home>

                           <local>org.jboss.as.test.integration.ejb.entity.cmp.simple.Simple</local>

                           <ejb-class>org.jboss.as.test.integration.ejb.entity.cmp.simple.SimpleBean</ejb-class>

                           <persistence-type>Container</persistence-type>

                           <prim-key-class>java.lang.String</prim-key-class>

                           <reentrant>False</reentrant>

                           <cmp-version>2.x</cmp-version>

                           <abstract-schema-name>simple</abstract-schema-name>

                           <cmp-field><field-name>id</field-name></cmp-field>

                           <cmp-field><field-name>booleanPrimitive</field-name></cmp-field>

                           <cmp-field><field-name>booleanObject</field-name></cmp-field>

                           <cmp-field><field-name>bytePrimitive</field-name></cmp-field>

                           <cmp-field><field-name>byteObject</field-name></cmp-field>

                           <cmp-field><field-name>shortPrimitive</field-name></cmp-field>

                           <cmp-field><field-name>shortObject</field-name></cmp-field>

                           <cmp-field><field-name>integerPrimitive</field-name></cmp-field>

                           <cmp-field><field-name>integerObject</field-name></cmp-field>

                           <cmp-field><field-name>longPrimitive</field-name></cmp-field>

                           <cmp-field><field-name>longObject</field-name></cmp-field>

                           <cmp-field><field-name>floatPrimitive</field-name></cmp-field>

                           <cmp-field><field-name>floatObject</field-name></cmp-field>

                           <cmp-field><field-name>doublePrimitive</field-name></cmp-field>

                           <cmp-field><field-name>doubleObject</field-name></cmp-field>

                           <cmp-field><field-name>stringValue</field-name></cmp-field>

                           <cmp-field><field-name>utilDateValue</field-name></cmp-field>

                           <cmp-field><field-name>sqlDateValue</field-name></cmp-field>

                           <cmp-field><field-name>timeValue</field-name></cmp-field>

                           <cmp-field><field-name>timestampValue</field-name></cmp-field>

                           <cmp-field><field-name>bigDecimalValue</field-name></cmp-field>

                           <cmp-field><field-name>byteArrayValue</field-name></cmp-field>

                           <cmp-field><field-name>objectValue</field-name></cmp-field>

                           <cmp-field><field-name>valueClass</field-name></cmp-field>

                           <cmp-field><field-name>hashtable</field-name></cmp-field>

                           <primkey-field>id</primkey-field>

                           <query>

                              <query-method>

                                 <method-name>findWithByteArray</method-name>

                                 <method-params>

                                    <method-param>byte[]</method-param>

                                 </method-params>

                              </query-method>

                              <ejb-ql/>

                           </query>

                           <query>

                              <query-method>

                                 <method-name>ejbSelectDynamic</method-name>

                                 <method-params>

                                    <method-param>java.lang.String</method-param>

                                    <method-param>java.lang.Object[]</method-param>

                                 </method-params>

                              </query-method>

                              <ejb-ql/>

                           </query>

                           <query>

                              <query-method>

                                 <method-name>ejbSelectValueClass</method-name>

                                 <method-params/>

                              </query-method>

                              <ejb-ql>

                                 SELECT s.valueClass

                                 FROM simple s

                              </ejb-ql>

                           </query>

                        </entity>

                   

                   

                        <entity>

                           <ejb-name>SimpleEJBWithOptionA</ejb-name>

                           <local-home>org.jboss.as.test.integration.ejb.entity.cmp.simple.SimpleHome</local-home>

                           <local>org.jboss.as.test.integration.ejb.entity.cmp.simple.Simple</local>

                           <ejb-class>org.jboss.as.test.integration.ejb.entity.cmp.simple.SimpleBean</ejb-class>

                           <persistence-type>Container</persistence-type>

                           <prim-key-class>java.lang.String</prim-key-class>

                           <reentrant>False</reentrant>

                           <cmp-version>2.x</cmp-version>

                           <abstract-schema-name>simpleA</abstract-schema-name>

                           <cmp-field><field-name>id</field-name></cmp-field>

                           <cmp-field><field-name>booleanPrimitive</field-name></cmp-field>

                           <cmp-field><field-name>booleanObject</field-name></cmp-field>

                           <cmp-field><field-name>bytePrimitive</field-name></cmp-field>

                           <cmp-field><field-name>byteObject</field-name></cmp-field>

                           <cmp-field><field-name>shortPrimitive</field-name></cmp-field>

                           <cmp-field><field-name>shortObject</field-name></cmp-field>

                           <cmp-field><field-name>integerPrimitive</field-name></cmp-field>

                           <cmp-field><field-name>integerObject</field-name></cmp-field>

                           <cmp-field><field-name>longPrimitive</field-name></cmp-field>

                           <cmp-field><field-name>longObject</field-name></cmp-field>

                           <cmp-field><field-name>floatPrimitive</field-name></cmp-field>

                           <cmp-field><field-name>floatObject</field-name></cmp-field>

                           <cmp-field><field-name>doublePrimitive</field-name></cmp-field>

                           <cmp-field><field-name>doubleObject</field-name></cmp-field>

                           <cmp-field><field-name>stringValue</field-name></cmp-field>

                           <cmp-field><field-name>utilDateValue</field-name></cmp-field>

                           <cmp-field><field-name>sqlDateValue</field-name></cmp-field>

                           <cmp-field><field-name>timeValue</field-name></cmp-field>

                           <cmp-field><field-name>timestampValue</field-name></cmp-field>

                           <cmp-field><field-name>bigDecimalValue</field-name></cmp-field>

                           <cmp-field><field-name>byteArrayValue</field-name></cmp-field>

                           <cmp-field><field-name>objectValue</field-name></cmp-field>

                           <cmp-field><field-name>valueClass</field-name></cmp-field>

                           <cmp-field><field-name>hashtable</field-name></cmp-field>

                           <primkey-field>id</primkey-field>

                           <query>

                              <query-method>

                                 <method-name>findWithByteArray</method-name>

                                 <method-params>

                                    <method-param>byte[]</method-param>

                                 </method-params>

                              </query-method>

                              <ejb-ql/>

                           </query>

                           <query>

                              <query-method>

                                 <method-name>ejbSelectDynamic</method-name>

                                 <method-params>

                                    <method-param>java.lang.String</method-param>

                                    <method-param>java.lang.Object[]</method-param>

                                 </method-params>

                              </query-method>

                              <ejb-ql/>

                           </query>

                           <query>

                              <query-method>

                                 <method-name>ejbSelectValueClass</method-name>

                                 <method-params/>

                              </query-method>

                              <ejb-ql>

                                 SELECT s.valueClass

                                 FROM simple s

                              </ejb-ql>

                           </query>

                        </entity>

                     </enterprise-beans>

                   

                   

                     <assembly-descriptor>

                        <container-transaction>

                           <method>

                              <ejb-name>SimpleEJB</ejb-name>

                              <method-name>*</method-name>

                           </method>

                           <method>

                              <ejb-name>SimpleEJBWithOptionA</ejb-name>

                              <method-name>*</method-name>

                           </method>

                           <trans-attribute>Required</trans-attribute>

                        </container-transaction>

                     </assembly-descriptor>

                  </ejb-jar>

                   

                   

                  Once everything deployed, whitout any errors I make call to initTest servlet and trying to lookup local entities:

                   

                  InitialContext ic = new InitialContext();

                  ic.lookup("java:app/simple/SimpleEJB!org.jboss.as.test.integration.ejb.entity.cmp.simple.SimpleHome")

                   

                   

                   

                  P.S. Session beans deployed succesfully and can be accessed through lookup. But not entities.

                   

                  Please advise.

                  • 6. Re: How to configure Ejb 2 entities on JBoss 7.1?
                    Michael Rootman Newbie

                    I am tending to assume there is bug in JBoss 7.1 in handling EJB 2.1 Entities deployment.

                     

                    Same ear file with adoptation of deployment description schemas can be succesfully deplyed on Jboss 5.1, while 7.1 seems simply to ignore this.

                     

                    I opened Jira issue for proper review: https://issues.jboss.org/browse/AS7-4100

                    • 9. Re: How to configure Ejb 2 entities on JBoss 7.1?
                      jsebfranck Newbie

                      Hi Van,

                       

                      To help you, I shared a working example here : http://jsebfranck.blogspot.fr/2013/08/ejb-2-on-jboss-71-example.html. Don't hesitate to comment this example if you still have a problem.

                       

                      Jean-Sébastien

                      • 10. Re: How to configure Ejb 2 entities on JBoss 7.1?
                        Nav Diesel Newbie

                        Hey Jean,

                         

                        Thank you for the example. I'm working on it. As you've asked,I'll comment the given example, if I face any issues.

                         

                        Thanks again,

                        Diesel