3 Replies Latest reply on Mar 14, 2004 4:05 PM by Viet

    Help with using UserEJB

    Dennis Przybyla Novice

      Ok, I am trying to add a user to their rating of a download. I use the following for the interface method.

       * @ejb.interface-method
       * @ejb.relation
       * name="DownloadRatings[-]User"
       * role-name="DownloadRatings-]User"
       * target-ejb="UserEJB"
       * target-role-name="User-]DownloadRatings"
       * target-multiple="yes"
       * @jboss.relation
       * fk-column="userId"
       * related-pk-field="id"
       * @jboss.method-attributes
       * read-only="true"

      It builds ok but when it is deployed I am getting the following exception.

      org.jboss.deployment.DeploymentException: Entity: UserEJB not found for relation: DownloadRatings[-]User
       at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.<init>(JDBCRelationshipRoleMetaData.java:106)
       at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationMetaData.<init>(JDBCRelationMetaData.java:133)
       at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.<init>(JDBCApplicationMetaData.java:174)
       at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:52)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCStoreManager.java:706)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreManager.java:409)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:357)
       at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:152)
       at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:342)
       at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)

      I have tried to follow how bb module does it but then the DownloadsRatingsEJB module is not built. Sorry for the EJB question but I am very new at all this EJB stuff and I hope you don't mind helping a novice EJB programmer out.


        • 1. Re: Help with using UserEJB
          Viet Master

          did you modify your build.xml to include the UserEJB in the same ejb-jar archive ? you should have an bean in your generated ejb-jar.xml

          • 2. Re: Help with using UserEJB
            Dennis Przybyla Novice

            That was the problem. This is kind of confusing, I thought that the UserEJB would have already been deployed with the core module. Why do I have to deploy it with my module? I thought the purpose of an application server was to allow resources to be used once they are deployed.


            • 3. Re: Help with using UserEJB
              Viet Master

              It is deployed already but it is possible to have sometimes several containers with the same beans.

              For instance in the BB module, each bean is deployed twice (although it could be once), there is one read-only container optimized for speed and one read-write container used for updates. Of course both containers communicates to invalidate entries.

              In addition, the fact we use several time the same bean deployed is necessary because you are not authorized to create a relationship between deployments. So the only way to have UserEJB + PostEJB (in the forum) is to deploy again the UserEJB in the same ejb-jar the forum is. (It may seem a bit stupid, but it is actually). I don't know if hibernate allow that kind of stuff.

              Otherwise if you don't want to deploy a new UserEJB, you have to use user in your module with the concept of user ID. For instance on the PostEJB we would have get/set UserId(Integer) instance of get/set User(UserEJBLocal) and I prefer the second one rather than the first one.