5 Replies Latest reply on Aug 29, 2006 2:57 AM by Maurice Zeijen

    2 jars  , no inject

    Nicola De Venuto Newbie

      Hiya

      I am trying to make a XXX.jar with all my "data tier" components
      i can't inject components from another YYY.jar

      this is a Component in the XXX.jar
      @Name("vbasutenticlientiFinder")
      @Stateful
      @Scope(ScopeType.SESSION)
      @Interceptors(SeamInterceptor.class)
      public class VBasUtentiClientiFinderBean implements VBasUtentiClientiFinder {

      private VBasUtentiClienti example = new VBasUtentiClienti();
      ....


      I have another YYY.jar with action components

      this is a component in YYY.jar
      @Name("impiantiPage")
      @Stateful
      @Scope(ScopeType.SESSION)
      @Interceptors(SeamInterceptor.class)
      public class ImpiantiPageBean
      implements ImpiantiPage
      {
      @In (create=true)
      @Out
      private VBasUtentiClientiFinder vbasutenticlientiFinder;
      ......


      the Error
      Caused by: org.jboss.seam.RequiredException: In attribute requires value for component: impiantiPage.vbasutenticlientiFinder

      Questions
      1. How can i inject a component from the XXX.jar into the YYY.jar? is there a jndi problem ? component.xml ? other ?

      2. My dream is to deploy the XXX.jar alone and reference it from many .ears
      Is it possible, how ? ( question 1 is more important )

      i have the 2 .jars in my .ear
      i update application.xml


      M2U_InstalledBaseManager-ejb.jar


      M2U_Data-ejb.jar


      and so is the same :-(


      M2U_InstalledBaseManager-ejb.jar


      M2U_Data-ejb.jar


      Ciao Nicola


        • 1. Re: 2 jars  , no inject
          Nicola De Venuto Newbie

          Corrige application.xml

          [module]
          [ejb]M2U_InstalledBaseManager-ejb.jar[/ejb]
          [module]
          [module]
          [java]M2U_Data-ejb.jar[/java]
          [/module]

          ( so is the same )
          [module]
          [ejb]M2U_Data-ejb.jar[/ejb]
          [/module]

          • 2. Re: 2 jars  , no inject
            Nicola De Venuto Newbie

            Solved

            i put in the .jar

            seam.properties
            META-INF/ejb-jar (for interception)
            META-INF/persistence.xml
            with different name of persistence-unit-name !!!!
            (NO jboss-seam.jar)

            i will think if it is useful to deploy a single .ear with all database components, and if it is possible.

            For now is ok so.

            Nicola


            • 3. Re: 2 jars  , no inject
              Maurice Zeijen Master

              Yeah, I am also very curious if it is possible to deploy the data (entity) layer in a different ear file.

              I have the feeling that it isn't possible, because how should SEAM now how to get the correct JNDI path for the entities. You can only configure one JNDI path where the components should be fetched.

              • 4. Re: 2 jars  , no inject
                Nicola De Venuto Newbie

                 

                "mzeijen" wrote:
                I have the feeling that it isn't possible, because how should SEAM now how to get the correct JNDI path for the entities. You can only configure one JNDI path where the components should be fetched.


                @Name("")
                @LocalBinding(jndiBinding="")
                @JndiName("")
                perhaps ?


                I will study better Ejb3-jndi ASAP and i will solve it and i will post :)
                I have to improove with all new staff before it.

                GoodWork

                ciao Nicola

                • 5. Re: 2 jars  , no inject
                  Maurice Zeijen Master

                  I just read from a different topic (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=89223) that I started that it isn't possible to resolve entity beans over JNDI but that you have to add them to each ear project.

                  I already got this working but there is a trapdoor. Each ejb jar that needs to be able to work with the entity-manager needs a persistence.xml. The problem lies in the ejb jar that doesn't house the entity classes but only uses them. In the persistence.xml in this ejb you need to define, next to the datasource, which classes are entity classes. Normally the easiest way to do this is as following:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <persistence xmlns="http://java.sun.com/xml/ns/persistence"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
                   version="1.0">
                  
                   <persistence-unit name="MyEntityManager" transaction-type="JTA">
                   <jta-data-source>java:/MyDS</jta-data-source>
                   <jar-file>../dataEJB.jar</jar-file>
                   <properties></properties>
                   </persistence-unit>
                  
                  </persistence>
                  


                  The jar-file property links to the jar file where the entity beans can be found. The entityManager should scan this jar for the entities and the problems is solved. But because of a bug in the jboss implementation of ejb3 the path to the jar file isn't resolved correctly.

                  Luckily there is another way to define the entity classes. It isn't pretty but the only solution until they fix the bug (I hope they will do that soon). By using the class tag you can define each class that are entity classes:

                  
                  <?xml version="1.0" encoding="UTF-8"?>
                  <persistence xmlns="http://java.sun.com/xml/ns/persistence"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
                   version="1.0">
                  
                   <persistence-unit name="MyEntityManager" transaction-type="JTA">
                   <jta-data-source>java:/MyDS</jta-data-source>
                   <class>my.package.User</class>
                   <class>my.package.SomeOtherEntity</class>
                   <properties></properties>
                   </persistence-unit>
                  
                  </persistence>
                  
                  


                  I hope this prevents hours of work ;).