1 2 Previous Next 15 Replies Latest reply on Aug 25, 2003 5:42 AM by zwets

    ERROR: The ejb-name for a CMP2.x Entity must be a valid Java

    kishore


      First I am a novice to JBOSS /. I need a help to identify the Error when I try to deploy applications using JBoss

      I used to the Quick Start Guide and installed Ant/JUNIT/Xdoclet etc . Using the SAmple Prj template from the source forge( reference Quick start guide) I used Ant to deploy it . with JBOSS -C all on another window , I got the following exception during deployment
      .
      09:50:43,625 ERROR [URLDeploymentScanner] Failed to deploy: org.jboss.deployment
      .scanner.URLDeploymentScanner$DeployedURL@7dbb2579{ url=file:/C:/jboss/server/al
      l/deploy/ejb-test.jar, deployedLastModified=1051675279703 }
      org.jboss.deployment.DeploymentException: Error in ejb-jar.xml for Entity Bean t
      est/TestEntity: The ejb-name for a CMP2.x Entity must be a valid Java Identifier

      at org.jboss.metadata.ApplicationMetaData.importEjbJarXml(ApplicationMet
      aData.java:247)

        • 1. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid

          Remove the / from ejb-name

          Regards,
          Adrian

          • 2. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid
            deepaksumani

            Kishore ,

            use test_TestEntity instead of test/TestEntity and replace this everywhere with ejb name .

            Cheers
            Dee

            • 3. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid
              sunsphoto

              Dear,

              I face the same problem!

              I find that "test/TestEntity" is not appear in the original java. It is by generation.

              Have you fix the problems?

              Thank you!

              • 4. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid
                mmeany

                I also find this very frustrating. This must be one of the slowest Quick Starts I have tried.

                I am new to JBoss and am sure it has lots to offer. I want to get up to speed, but at the moment can't even get started!

                What is required is a Quick Start that inspires confidence in the product, not one that leaves the developer baffled and facing the task of fixing the example and suggested Template.

                Does anyone have a fixed, buildable, deployable and testable version of the Template that is available for download, email?

                Cheers, Mark

                • 5. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid
                  sundaram

                  I am also having the same problem. Is there any fixed version of example code
                  -SR

                  • 6. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid

                    We'll it worked with previous versions of JBoss. The problem is as they try to get JBoss J2EE compliant, they tend to fix things that worked before but should not have. I'm working on a fix right now and will post when I get it working.

                    • 7. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid

                      This works:

                      In TestEntityBean
                      @ejb:bean name="TestEntity"


                      In TestSessionBean
                      * @ejb:ejb-ref ejb-name="TestEntity"

                      In index.jsp:

                      TestSessionHome lHome = (TestSessionHome) lContext.lookup(
                      "ejb/test/TestSession"
                      );



                      I am not sure why the java:comp/ prefix doesn't resolve. Anyone know why?

                      • 8. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid
                        eberhaas

                        The fix above didn't work for me. I then got another error during deployment.

                        I changed from jboss-3.2.0_tomcat-4.1.24 to jboss-3.0.7_jakarta-tomcat-4.1.24.

                        Now it works.

                        • 9. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid

                          Yes the quick start applies to 3.0.x series only! Not 3.2.x, 4.0.x or anything that has been released after 3.0.x

                          • 10. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid

                            Juha Lindfors,

                            Many thanks...I had the same issue as we've all experienced.

                            In the "Template Project" portion of the JBoss Quick Start it indicates JBoss 3.0 or higher. Your clarification explains things :-)

                            • 11. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid
                              ssjoshi

                              I faced the same problem. However I went ahead to modify the TestEntity*Bean and session beans by hand and with some tweaking in the ejb-jar.xml I got the stuff to deployed on to the Jboss 3.2 server. I got rid of names liek test/TestEntity and simply used TestEntity (same for TestBMPENtity and files in session) . Pulled down the directories entity and session one level down (adjusted the package the file accordingly). Got rid of PackageSubstitution part. REmoved all referenced to test.interfaces ro simply "entity" or "session" as appropriate. Added following section in the ejb-jar.xml for entity bean TestEntity .


                              <query-method>
                              <method-name>findByName</method-name>
                              <method-params>
                              <method-param>java.lang.String </method-param>
                              <method-param>java.lang.String </method-param>
                              </method-params>
                              </query-method>
                              <ejb-ql>
                              <![CDATA[SELECT * FROM TestEntity WHERE First_Name = ?1 AND Last_Name = ?2]]>
                              </ejb-ql>




                              <query-method>
                              <method-name>findAnotherByName</method-name>
                              <method-params>
                              <method-param>int </method-param>
                              <method-param>java.lang.String </method-param>
                              <method-param>java.lang.String </method-param>
                              </method-params>
                              </query-method>
                              <ejb-ql>
                              <![CDATA[SELECT * FROM TestEntity WHERE Id = ?1 AND First_Name = ?2 AND Last_Name = ?3]]>
                              </ejb-ql>


                              Added a method "public java.util.COllection ejbFindAll " to the TestBMPEntityBean.

                              Howevere once the bean gets deployed a SQL error is given in JBOSS log and "TestEntity" fails to get in "start" phase (others are fine). Following error comes. ANy idea how to get past this (I tried to remove "SELECT * FROM TestEntity" as well as "SELECT *" but did not work)

                              org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'SELECT * FROM TestEntity WHERE Id = ?1 AND First_Name = ?2 AND Last_Name = ?3'; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "" at line 1, column 77.
                              Was expecting one of:
                              "AS" ...
                              ...
                              )
                              at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:46)
                              at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createEJBQLQuery(JDBCCommandFactory.java:53)
                              at org.jboss.ejb.plugins.cmp.jdbc.JDBCQueryManager.start(JDBCQueryManager.java:218)
                              at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDBCStoreManager.java:505)
                              at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:410)
                              at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:170)

                              • 12. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid

                                Should be SELECT OBJECT(t) FROM TestEntity AS t WHERE First_Name = ?1 AND Last_Name = ?2

                                • 13. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid
                                  ssjoshi

                                  Thanks Juha,
                                  With this change and few more I finally got it runnign on JBoss 3.2 . The added changes are as follows

                                  a) (wonder if there is soem directive in ejbdoclet to add following autoatically to ejb-jar.xml for TestEntity)


                                  <query-method>
                                  <method-name>findByName</method-name>
                                  <method-params>
                                  <method-param>java.lang.String </method-param>
                                  <method-param>java.lang.String </method-param>
                                  </method-params>
                                  </query-method>
                                  <ejb-ql>
                                  <![CDATA[SELECT OBJECT(t) FROM TestEntity AS t WHERE t.firstName = ?1 AND t.lastName = ?2]]>
                                  </ejb-ql>




                                  <query-method>
                                  <method-name>findAnotherByName</method-name>
                                  <method-params>
                                  <method-param>int </method-param>
                                  <method-param>java.lang.String </method-param>
                                  <method-param>java.lang.String </method-param>
                                  </method-params>
                                  </query-method>
                                  <ejb-ql>
                                  <![CDATA[SELECT OBJECT(t) FROM TestEntity AS t WHERE t.id = ?1 AND t.firstName = ?2 AND t.lastName = ?3]]>
                                  </ejb-ql>



                                  b) Change the lookup (has even lookup mechanism changed between JBoss 3.0 and 3.2) in TestSessionBean and TestEntityBean (basically remove "ejb" from the lookup key [see ejb-jar.xml] )

                                  String lSequenceName = (String) lContext.lookup(
                                  "java:comp/env/SequenceName"
                                  );
                                  SequenceGeneratorHome lHome = (SequenceGeneratorHome) PortableRemoteObject.narrow(
                                  lContext.lookup(
                                  "java:comp/env/ejb/SequenceGenerator"
                                  ),
                                  SequenceGeneratorHome.class
                                  );

                                  ------------------------
                                  TestEntityHome lHome = (TestEntityHome) PortableRemoteObject.narrow(
                                  lContext.lookup(
                                  "java:comp/env/mytest/TestEntity"
                                  ),
                                  TestEntityHome.class
                                  );


                                  c) Add localhomeinterface and localhome directives to the build.xml for ejbdoclet (forgot to post this earlier)

                                  (I also removed the lookup for java:comp/test/env/Mail but it may be unnecessary)

                                  Cheers ...
                                  Shrikant

                                  • 14. Re: ERROR: The ejb-name for a CMP2.x Entity must be a valid

                                    > b) Change the lookup (has even lookup mechanism
                                    > changed between JBoss 3.0 and 3.2)

                                    Nope. The private bean ENC lookup name is defined by your ejb-jar.xml file.

                                    Glad you got it working though.

                                    -- Juha

                                    1 2 Previous Next