1 Reply Latest reply on Oct 2, 2007 10:29 AM by Federico Zuppa

    EJB3StandaloneDeployer does not find annotated beans

    Federico Zuppa Newbie

      My deployer is not finding the annotated beans. I tried adding the URLs explicitily

      EJB3StandaloneBootstrap.boot(null);
      EJB3StandaloneDeployer deployer = EJB3StandaloneBootstrap .createDeployer();
      try {
       URL lDeployDirectories = new File( "target/test-classes" ).toURL();
       deployer.getDeployDirs().add( lDeployDirectories );
       lDeployDirectories = new File( "target/classes" ).toURL();
       deployer.getDeployDirs().add( lDeployDirectories );
       deployer.getArchivesByResource().add( "META-INF/persistence.xml" );
       deployer.getArchivesByResource().add( "META-INF/ejb-jar.xml" );
      } catch (MalformedURLException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
      }
      


      and also scanning

      EJB3StandaloneBootstrap.boot(null);
       EJB3StandaloneBootstrap.scanClasspath("target/classes, target/test-classes");


      What am I doing wrong? Is there a way to add the classes explicitily? I am running the tests from Eclipse and also from maven with the same result.


      Jboss container: jboss-EJB-3.0_Embeddable_ALPHA_9



        • 1. Re: EJB3StandaloneDeployer does not find annotated beans
          Federico Zuppa Newbie

          Now I realized that the problem is with the EntityManager that is injected into the SessionBean. I made a SessionBean that does not use an EntityManager and it finds it. But when I add an instance variable to be injected with the EntityManager, the session bean is not bound anymore

          embedded-jboss-beans.xml

           <bean name="DefaultDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
           <property name="driverClass">org.postgresql.Driver</property>
           <property name="connectionURL">jdbc:postgresql://localhost:5432/corptx_development</property>
           <property name="userName">lala</property>
           <property name="password">lala</property>
           <property name="jndiName">java:/txDS</property>
           <property name="minSize">1</property>
           <property name="maxSize">10</property>
           <property name="blockingTimeout">1000</property>
           <property name="idleTimeout">100000</property>
           <property name="transactionManager"><inject bean="TransactionManager"/></property>
           <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
           <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
           </bean>
          
           <bean name="txDS" class="java.lang.Object">
           <constructor factoryMethod="getDatasource">
           <factory bean="DefaultDSBootstrap"/>
           </constructor>
           </bean>


          persistence.xml

          <persistence>
           <persistence-unit name="manager1">
           <jta-data-source>java:/txDS</jta-data-source>
           <properties>
           <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
           <!-- DESCOMENTAR PARA VER LAS QUERIES QUE SE TIRAN A LA BASE-->
           <!--property name="hibernate.show_sql" value="true"/-->
           </properties>
           </persistence-unit>
          </persistence>



          and I inject my entity manger like this
           @PersistenceContext(unitName = "manager1")
           private EntityManager em;


          Can it be that because there is a problem with the EntityManager, the session bean is not bound at all?