10 Replies Latest reply on Jan 2, 2013 11:44 AM by javacoryd

    JBoss 7.1.1 Final with EJB 2.1

    javacoryd

      I'm porting an application from JBoss 4.2.3 to JBoss 7.1.1 Final and am having an issue with delploying the EJB 2.1 ejbs.  My issue is I'm getting this error "JBAS010726: No security-domain configured but created-by specified" when deploying the entity beans.

       

      We use the audit fields on our entity beans for created-by/time and updated-by/time which is tied into the "authenticated" user as that is how the user's id is associated to the created-by and updated-by fields.

       

      In searching the documentation & forums I have created a "jboss-ejb3.xml" file and put that into the META-INF directory of the .jar file.  This seems to replace the old jboss.xml file we used to have.  I have also found that I need to put this entry in the "jboss-ejb3.xml" file to associate the ejbs with the security-domain:

       

      <assembly-descriptor>

              <s:security>

                  <ejb-name>*</ejb-name>

                  <s:security-domain>other</s:security-domain>

              </s:security>

      </assemby-descriptor>

       

      This doesn't seem to work for me as I continue to get the error stated above.  Does this simply not work with EJB 2?

       

      Here is the stack trace:

       

      Caused by: java.lang.RuntimeException: JBAS010732: Couldn't create entity command

          at org.jboss.as.cmp.jdbc.JDBCCommandFactory.createCreateEntityCommand(JDBCCommandFactory.java:132)

          at org.jboss.as.cmp.jdbc.JDBCStoreManager.startStoreManager(JDBCStoreManager.java:215)

          at org.jboss.as.cmp.jdbc.JdbcStoreManagerStartService.start(JdbcStoreManagerStartService.java:44)

          ... 5 more

      Caused by: java.lang.RuntimeException: JBAS010726: No security-domain configured but created-by specified

          at org.jboss.as.cmp.jdbc.JDBCAbstractCreateCommand.initGeneratedFields(JDBCAbstractCreateCommand.java:148)

          at org.jboss.as.cmp.jdbc.JDBCAbstractCreateCommand.init(JDBCAbstractCreateCommand.java:87)

          at org.jboss.as.cmp.jdbc.JDBCInsertPKCreateCommand.init(JDBCInsertPKCreateCommand.java:43)

          at org.jboss.as.cmp.jdbc.JDBCCommandFactory.createCreateEntityCommand(JDBCCommandFactory.java:130)

          ... 7 more

       

      Thanks,

       

      Cory.

        • 1. Re: JBoss 7.1.1 Final with EJB 2.1
          nickarls

          Is the created-by some JBoss-specific auditing stuff? I glanced at the code and it looks like the exception is thrown in

           

          https://github.com/jbossas/jboss-as/blob/master/cmp/src/main/java/org/jboss/as/cmp/jdbc/JDBCAbstractCreateCommand.java

           

          at

           

                  if (securityManager == null && createdPrincipal != null) {

                      throw MESSAGES.noSecurityDomainForCreatedBy();

                  }

           

           

          so it would seam like the security domain is not picked up(?)

          • 2. Re: JBoss 7.1.1 Final with EJB 2.1
            javacoryd

            Thanks for the reponse Nicklas.

             

            On the EJB 2 side, to map the entities there is a deployment descriptor called jbosscmp-jdbc.xml.  In this file, you can see the jboss-ql you define in your entity.

             

            You can also define "audit" tags for setting created-by and updated-by user id/date combinations.  This section looks like this:

             

            <audit>

                 <created-by>

                      <column-name>someUserIdField</column-name>

                 </created-by>

                 <created-time>

                      <column-name>someDateField</column-name>

                 </created-time>

                 <updated-by>

                      <column-name>someUserIdField</column-name>

                 </updated-by>

                 <updated-time>

                      <column-name>someDateField</column-name>

                </updated-time>

            </audit>

             

            Yea, that is what I'm seeing.  I don't know how to associate the entities to the security-domain which is needed to map authenticated "Principal" to the <created-by> & <updated-by> columns. 

             

            Thanks,

             

            Cory.

            • 3. Re: JBoss 7.1.1 Final with EJB 2.1
              nickarls

              Is the jboss-ejb3.xml picked up at all? What happens if you put a typo in it?

              • 4. Re: JBoss 7.1.1 Final with EJB 2.1
                javacoryd

                Thanks again.

                 

                Yes, I know that is getting picked up.  I put a typo in there and it fails to parse.

                 

                Thanks,

                 

                Cory.

                • 5. Re: JBoss 7.1.1 Final with EJB 2.1
                  nickarls

                  What is the deployment structure? EAR with EJB jars?

                  • 6. Re: JBoss 7.1.1 Final with EJB 2.1
                    javacoryd

                    Yes

                    • 7. Re: JBoss 7.1.1 Final with EJB 2.1
                      javacoryd

                      I was just wondering if there was any update on this one.

                       

                      I debugged this through JBoss and I can't see anywhere where the "securityManager" is being set onto the command, at least prior to initialializing the command.  If I track back to the JDBCStoreManager there is a component field which does have securityMetaData setup with the correct securityDomain.

                       

                      Beyond this issue, I am able to get the EJB 2.x to deploy correctly on JBoss 7.1.1 Final.

                       

                      Thanks,

                       

                      Cory.

                      • 8. Re: JBoss 7.1.1 Final with EJB 2.1
                        javacoryd

                        This looks to be a bug in the code.

                         

                        Here is the 7.1.1 Final code in the "init(JDBCStoreManager manager)" method of JDBCAbstractCreateCommand:

                         

                        entity = (JDBCEntityBridge) manager.getEntityBridge();

                        insertAfterEjbPostCreate = manger.getCmpConfig().isInsertAfterEjbPostCreate();

                         

                        ....

                         

                        initGeneratedFields();  // Error occurs in this method

                         

                        In other version of the source:

                         

                        entity = manager.getEntityBridge();

                        securityManager = manager.getContainer().getSecurityManager();

                         

                        ...

                         

                        initGeneratedFields();  // Security manager is set so it won't error out.

                         

                        Is there a newer version of JBoss that has this fix?

                         

                        Cory.

                        1 of 1 people found this helpful
                        • 9. Re: JBoss 7.1.1 Final with EJB 2.1
                          nickarls

                          The last commit to that file appears to have been 5 months ago so I don't think so. It might be that the legacy code isn't being used so often so bugs aren't noticed that quickly if they're "corner cases". You might want to file a JIRA for that.

                          • 10. Re: JBoss 7.1.1 Final with EJB 2.1
                            javacoryd