3 Replies Latest reply on May 3, 2006 11:27 AM by Jens Elkner

    Bean (+mysql) doesn't get  deployed

    M A Newbie

      My example EJB app using MYSQL doesn't seem to get deployed. Help/suggestions will be appreciated.

      $JBOSS_HOME/server/deploy/default/experiment-ds.xml is:

      <datasources>
       <local-tx-datasource>
       <jndi-name>experimentDB</jndi-name>
       <connection-url>jdbc:mysql://localhost/expr</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>root</user-name>
       <password></password>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
       <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>
      


      $JBOSS_HOME/server/default/deploy/experiment.ear/META-INF/persistence.xml is:
      <entity-manager>
       <name>JBoss Experiment</name>
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
      
       <jta-data-source>java:/experimentDB</jta-data-source>
      
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
       <property name="hibernate.case.use_query_cache" value="true" />
       <property name="hibernate.show_sql" value="true" />
       <property name="hibernate.hbm2ddl.auto" value="create-drop" />
       <property name="hibernate.connection.datasource" value="java:/bookingDatasource"/>
       </properties>
      </entity-manager>


      The bean is:
      public @Stateless class SetBean implements Set {
       @PersistenceContext
       EntityManager em;
      
       public void set(int key, int val) {
       Data data = new Data(key, val);
       em.persist(data);
       }
      
      }
      


      The log says:
      15:16:38,971 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=experimentDB' to JNDI name 'java:experimentDB'
      15:32:01,641 INFO [EARDeployer] Init J2EE application: file:/u/mahluwal/jboss-4.0.4.CR2/server/default/deploy/experiment.ear/
      15:32:02,194 INFO [Ejb3Deployment] EJB3 deployment time took: 149
      15:32:02,298 WARN [ServiceController] Ignoring request to stop nonexistent service: jboss.j2ee:ear=experiment.ear,jar=beans.jar,name=SetBean,service=EJB3
      15:32:02,298 WARN [ServiceController] Ignoring request to destroy nonexistent service: jboss.j2ee:ear=experiment.ear,jar=beans.jar,name=SetBean,service=EJB3
      15:32:02,345 WARN [ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=beans.jar
      java.lang.RuntimeException: Field javax.persistence.EntityManager expr.bean.SetBean.em @PersistenceUnit in error: EMPTY STRING unitName but there is no deployments in scope
       at org.jboss.ejb3.injection.PersistenceContextHandler.loadFieldDependencies(PersistenceContextHandler.java:358)
       at org.jboss.ejb3.injection.PersistenceContextHandler.loadDependencies(PersistenceContextHandler.java:410)
      ...blabla...
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:218)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:197)
      15:32:02,424 INFO [EJB3Deployer] Deployed: file:/u/mahluwal/jboss-4.0.4.CR2/server/default/deploy/experiment.ear/beans.jar
      15:32:02,500 INFO [EARDeployer] Started J2EE application: file:/u/mahluwal/jboss-4.0.4.CR2/server/default/deploy/experiment.ear/
      


      To this, I found the solution here

      First question: Since I've specified the unit name in persistence.xml, why do I need to specify it again in the Bean.java? Shouldn't be required according to the javadoc

      Regardless, when I change the bean to:
      public @Stateless class SetBean implements Set {
       @PersistenceContext(unitName="JBoss Experiment")
       EntityManager em;
      
       public void set(int key, int val) {
       Data data = new Data(key, val);
       em.persist(data);
       }
      
      }
      


      The log says:
      15:37:43,306 WARN [MainDeployer] undeploy 'file:/u/mahluwal/jboss-4.0.4.CR2/server/default/deploy/experiment.ear/' : package not deployed
      15:37:43,307 INFO [EARDeployer] Init J2EE application: file:/u/mahluwal/jboss-4.0.4.CR2/server/default/deploy/experiment.ear/
      15:37:43,447 INFO [Ejb3Deployment] EJB3 deployment time took: 34
      15:37:43,495 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=experiment.ear,jar=beans.jar,name=SetBean,service=EJB3 with dependencies:
      15:37:43,495 INFO [JmxKernelAbstraction] persistence.units:unitName=JBoss Experiment
      15:37:43,497 INFO [EJB3Deployer] Deployed: file:/u/mahluwal/jboss-4.0.4.CR2/server/default/deploy/experiment.ear/beans.jar
      15:37:43,499 INFO [EARDeployer] Started J2EE application: file:/u/mahluwal/jboss-4.0.4.CR2/server/default/deploy/experiment.ear/
      15:37:43,502 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
      
      --- Incompletely deployed packages ---
      org.jboss.deployment.DeploymentInfo@69f14e2 { url=file:/u/mahluwal/jboss-4.0.4.CR2/server/default/deploy/experiment.ear/ }
       deployer: org.jboss.deployment.EARDeployer@c3c315
       status: null
       state: FAILED
       watch: file:/u/mahluwal/jboss-4.0.4.CR2/server/default/deploy/experiment.ear/
       altDD: null
       lastDeployed: 1146523053289
       lastModified: 1146523513000
       mbeans:
      
      ObjectName: jboss.j2ee:ear=experiment.ear,jar=beans.jar,name=SetBean,service=EJB3
       State: NOTYETINSTALLED
       I Depend On:
       persistence.units:unitName=JBoss Experiment
      
      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: persistence.units:unitName=JBoss Experiment
       State: NOTYETINSTALLED
       Depends On Me:
       jboss.j2ee:ear=experiment.ear,jar=beans.jar,name=SetBean,service=EJB3
      
      


      Second question: Why isn't the mysql connection getting deployed?

      Thanks.