[jboss-user] [EJB 3.0] - Accessing stateless EJB3 bean from a ejb-jar

zhuhuapeng@gmail.com do-not-reply at jboss.com
Tue Jul 29 13:11:42 EDT 2008


this problem had been nagging me for days,i had made a project using ejb3. and deployed it to jboss4.2.3GA. the following is part of my project:

1:persistence.xml
<persistence-unit name="cattle_persis"
  | transaction-type="JTA">
  | <provider>org.hibernate.ejb.HibernatePersistence</provider>
  | <jta-data-source>java:/cattleDB</jta-data-source>
  | <properties>
  | <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.CMTTransactionFactory" />
  | <property name="org.hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
2:interface

  | @Remote
  | public interface ICustomerService {
  | public void persist(CustomerEO eo);
  | }
3:bean

  | @Stateless
  | public class CustomerService implements ICustomerService {
  | @PersistenceContext(unitName="cattle_persis")
  | private EntityManager entityManager;
  | public void persist(CustomerEO eo) {
  | 	entityManager.persist(eo);
  | }
  | }
  | 
4:entity

  | @Entity
  | @Table(name="CUSTOMER")
  | public class CustomerEO {...
  | 
5:testClient

  | ...
  | Hashtable<String,String> props = new Hashtable<String,String>();
  | props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
  | props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
  | props.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
  | context = new InitialContext(props);
  | ...
  | Context ctx = getInitialContext();
  | Object obj = ctx.lookup("CustomerService/remote");
  | ICustomerService service = (ICustomerService)PortableRemoteObject.narrow(obj,
  | 		ICustomerService.class);
  | ....
  | 

then run jboss, part of the loginfo

  | [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=/cattleDB' to JNDI name 'java:/cattleDB'
  | 17:01:19,664 INFO  [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.entity.PersistenceUnitDeployment
  | 17:01:19,667 INFO  [JmxKernelAbstraction] installing MBean: persistence.units:jar=demoEJB-1.0.jar,unitName=cattle_persis with dependencies:
  | 17:01:19,667 INFO  [JmxKernelAbstraction] 	jboss.jca:name=cattleDB,service=DataSourceBinding
  | 17:01:19,853 INFO  [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
  | 17:01:19,857 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=demoEJB-1.0.jar,name=CustomerService,service=EJB3 with dependencies:
  | 17:01:19,857 INFO  [JmxKernelAbstraction] 	persistence.units:jar=demoEJB-1.0.jar,unitName=cattle_persis
  | 17:01:19,859 INFO  [EJB3Deployer] Deployed: file:/E:/TheOrc/base/jboss-4.2.3.GA/server/default/deploy/demoEJB-1.0.jar
  | 17:01:19,886 INFO  [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
  | 17:01:20,009 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
  | 
  | --- MBeans waiting for other MBeans ---
  | ObjectName: persistence.units:jar=demoEJB-1.0.jar,unitName=cattle_persis
  |   State: NOTYETINSTALLED
  |   I Depend On:
  |     jboss.jca:name=cattleDB,service=DataSourceBinding
  |   Depends On Me:
  |     jboss.j2ee:jar=demoEJB-1.0.jar,name=CustomerService,service=EJB3
  | 
  | ObjectName: jboss.j2ee:jar=demoEJB-1.0.jar,name=CustomerService,service=EJB3
  |   State: NOTYETINSTALLED
  |   I Depend On:
  |     persistence.units:jar=demoEJB-1.0.jar,unitName=cattle_persis
  | 
  | --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
  | ObjectName: jboss.jca:name=cattleDB,service=DataSourceBinding
  |   State: NOTYETINSTALLED
  |   Depends On Me:
  |     persistence.units:jar=demoEJB-1.0.jar,unitName=cattle_persis
  | 

in jmx-console page,get the following message:

  | persistence.units
  | jar=demoEJB-1.0.jar,unitName=cattle_persis 
  | 

at last ,run testClient,and got the following exception:

  | Exception in thread "main" javax.naming.NameNotFoundException: CustomerService not bound
  | ...
  | 

can there anyone help me to resolve this problem,very thanks.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4167400#4167400

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4167400



More information about the jboss-user mailing list