[jboss-user] [Installation, Configuration & DEPLOYMENT] - Need help using ejb-jar.xml instead of EJB3 annotations

smyers68 do-not-reply at jboss.com
Thu Dec 11 14:23:37 EST 2008


Hi I'm using JBoss5.0GA to deploy a remote EJB3 session bean that depends on a local EJB3 session bean.  I need to do my deployment using an ejb-jar.xml file and not use EJB3 annotations in my session beans.  I've removed my EJB3 annotations and I am able to successfully access my remote session bean, but I'm unable to figure out the ejb-jar.xml config that is equivalent to the @EJB annotation to inject a local session bean into my remote session bean.  

Thank you all in advance for your assistance!

-- Steve

Code snipets, configs, jndi tree, and error log below:


---------------  PurchaseOrderServiceBean --------------------

package test.service.po
  | 
  | import test.entity.po.PurchaseOrder;
  | import test.persistence.po.PurchaseOrderDao;
  | 
  | public class PurchaseOrderServiceBean implements PurchaseOrderService {
  | 
  |      private PurchaseOrderDao purchaseOrderDao;
  | 
  | etc...
  | 
---------------  PurchaseOrderService --------------------

package test.service.po;
  | 
  | import java.io.Serializable;
  | 
  | import test.entity.po.PurchaseOrder;
  | 
  | public interface PurchaseOrderService extends Serializable  {
  | 
  | etc...

---------------  PurchaseOrderDaoJpa --------------------

package test.persistence.po;
  | 
  | import test.entity.po.PurchaseOrder;
  | import test.persistence.GenericDaoJpa;
  | 
  | public class PurchaseOrderDaoJpa extends GenericDaoJpa<PurchaseOrder, Integer> implements PurchaseOrderDao
  | {
  | 
  | etc...

---------------  PurchaseOrderDao --------------------

package test.persistence.po;
  | 
  | import test.entity.po.PurchaseOrder;
  | import test.persistence.GenericDao;
  | 
  | public interface PurchaseOrderDao extends GenericDao<PurchaseOrder, Integer>
  | {
  | 
  | etc...

---------------  ejb-jar.xml --------------------

<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  | 	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  | 		  http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
  | 	version="3.0">
  | 
  | 	<description>Test Application </description>
  | 	<display-name>Test</display-name>
  | 
  | 	<enterprise-beans>
  | 		<session>
  | 			<ejb-name>PurchaseOrderService</ejb-name>
  | 			<mapped-name>test-app/PurchaseOrderServiceBean/remote</mapped-name>
  | 			<business-remote>test.service.po.PurchaseOrderService</business-remote>
  | 			<ejb-class>test.service.po.PurchaseOrderServiceBean</ejb-class>
  | 			<session-type>Stateless</session-type>
  | 			
  | 			<ejb-ref>
  | 				<ejb-ref-name>PurchaseOrderDaoJpa</ejb-ref-name>
  | 				<ejb-ref-type>Session</ejb-ref-type>
  | 				<injection-target>
  | 					<injection-target-class>
  | 						test.service.po.PurchaseOrderServiceBean</injection-target-class>
  | 					<injection-target-name>purchaseOrderDao</injection-target-name>
  | 				</injection-target>
  | 			</ejb-ref>
  | 
  | 		</session>
  | 
  | 		<session>
  | 			<ejb-name>PurchaseOrderDaoJpa</ejb-name>
  | 			<business-local>test.persistence.po.PurchaseOrderDao</business-local>
  | 			<ejb-class>test.persistence.po.PurchaseOrderDaoJpa</ejb-class>
  | 			<session-type>Stateless</session-type>
  | 		</session>
  | 
  | 	</enterprise-beans>
  | 
  | </ejb-jar>

---------------  jndi tree --------------------

 Other components with java:comp namespace
  | 
  | java:comp namespace of the component jboss.j2ee:ear=test-app.ear,jar=test-app.ear,name=PurchaseOrderService,service=EJB3 :
  | 
  |   +- EJBContext (class: javax.ejb.EJBContext)
  |   +- TransactionSynchronizationRegistry[link -> java:TransactionSynchronizationRegistry] (class: javax.naming.LinkRef)
  |   +- UserTransaction (class: org.jboss.ejb3.tx.UserTransactionImpl)
  |   +- env (class: org.jnp.interfaces.NamingContext)
  |   +- ORB[link -> java:/JBossCorbaORB] (class: javax.naming.LinkRef)
  | 
  | 
  | java:comp namespace of the component jboss.j2ee:ear=test-app.ear,jar=test-app.ear,name=PurchaseOrderDaoJpa,service=EJB3 :
  | 
  |   +- EJBContext (class: javax.ejb.EJBContext)
  |   +- TransactionSynchronizationRegistry[link -> java:TransactionSynchronizationRegistry] (class: javax.naming.LinkRef)
  |   +- UserTransaction (class: org.jboss.ejb3.tx.UserTransactionImpl)
  |   +- env (class: org.jnp.interfaces.NamingContext)
  |   |   +- em (class: org.jboss.jpa.tx.TransactionScopedEntityManager)
  |   |   +- test.persistence.GenericDaoJpa (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- em (class: org.jboss.jpa.tx.TransactionScopedEntityManager)
  |   +- ORB[link -> java:/JBossCorbaORB] (class: javax.naming.LinkRef)
  | 
  | 
  | java: Namespace
  | 
  |   +- securityManagement (class: org.jboss.security.integration.JNDIBasedSecurityManagement)
  |   +- comp (class: javax.namingMain.Context)
  |   +- XAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  |   +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
  |   +- test-ds (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
  |   +- policyRegistration (class: org.jboss.security.plugins.JBossPolicyRegistration)
  |   +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
  |   +- ClusteredConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  |   +- Mail (class: javax.mail.Session)
  |   +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
  |   +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
  |   +- jaas (class: javax.naming.Context)
  |   |   +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
  |   |   +- profileservice (class: org.jboss.security.plugins.SecurityDomainContext)
  |   |   +- jboss-web-policy (class: org.jboss.security.plugins.SecurityDomainContext)
  |   +- ClusteredXAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  |   +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
  |   +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
  |   +- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  |   +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
  |   +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)
  |   +- timedCacheFactory (class: javax.naming.Context)
  | Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy cannot be cast to javax.naming.NamingEnumeration
  | 
  | 
  | Global JNDI Namespace
  | 
  |   +- UserTransactionSessionFactory (proxy: $Proxy103 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
  |   +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
  |   +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
  |   +- PurchaseOrderService (class: org.jnp.interfaces.NamingContext)
  |   |   +- remote-test.service.po.PurchaseOrderService (class: Proxy for: test.service.po.PurchaseOrderService)
  |   +- XAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  |   +- topic (class: org.jnp.interfaces.NamingContext)
  |   +- persistence.unit:unitName=test-app.ear (class: org.jnp.interfaces.NamingContext)
  |   |   +- #test-pu (class: org.hibernate.impl.SessionFactoryImpl)
  |   +- PurchaseOrderDaoJpa (class: org.jnp.interfaces.NamingContext)
  |   |   +- local (class: Proxy for: test.persistence.po.PurchaseOrderDao)
  |   |   +- local-test.persistence.po.PurchaseOrderDao (class: Proxy for: test.persistence.po.PurchaseOrderDao)
  |   +- ClusteredConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  |   +- ProfileService (class: AOPProxy$0)
  |   +- queue (class: org.jnp.interfaces.NamingContext)
  |   |   +- DLQ (class: org.jboss.jms.destination.JBossQueue)
  |   |   +- ExpiryQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- ClusteredXAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  |   +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
  |   +- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  |   +- jmx (class: org.jnp.interfaces.NamingContext)
  |   |   +- invoker (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- RMIAdaptor (proxy: $Proxy105 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
  |   |   +- rmi (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
  |   +- TomcatAuthenticators (class: java.util.Properties)
  |   +- test-app (class: org.jnp.interfaces.NamingContext)
  |   |   +- PurchaseOrderServiceBean (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- remote (class: Proxy for: test.service.po.PurchaseOrderService)
  |   +- console (class: org.jnp.interfaces.NamingContext)
  |   |   +- PluginManager (proxy: $Proxy106 implements interface org.jboss.console.manager.PluginManagerMBean)
  | 

---------------  server log messages --------------------

  | ...
  | 
  | 11:03:20,691 INFO  [JBossASKernel] Added bean(jboss.j2ee:ear=test-app.ear,jar=test-app.ear,name=PurchaseOrderDaoJpa,service=EJB3) to KernelDeployment of: test-app.ear
  | 11:03:20,863 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=test-app.ear,jar=test-app.ear,name=PurchaseOrderService,service=EJB3
  | 11:03:20,863 INFO  [EJBContainer] STARTED EJB: test.service.po.PurchaseOrderServiceBean ejbName: PurchaseOrderService
  | 11:03:20,878 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
  | 
  | 	test-app/PurchaseOrderServiceBean/remote - EJB3.x Default Remote Business Interface
  | 	PurchaseOrderService/remote-test.service.po.PurchaseOrderService - EJB3.x Remote Business Interface
  | 
  | ...
  | 
  | 11:03:21,894 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=test-app.ear,jar=test-app.ear,name=PurchaseOrderDaoJpa,service=EJB3
  | 11:03:21,894 INFO  [EJBContainer] STARTED EJB: test.persistence.po.PurchaseOrderDaoJpa ejbName: PurchaseOrderDaoJpa
  | 11:03:21,925 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
  | 
  | 	PurchaseOrderDaoJpa/local - EJB3.x Default Local Business Interface
  | 	PurchaseOrderDaoJpa/local-test.persistence.po.PurchaseOrderDao - EJB3.x Local Business Interface
  | 	
  | ...
  | 
  | Caused by: java.lang.RuntimeException: Unable to inject jndi dependency: env/PurchaseOrderDaoJpa into property test.service.po.PurchaseOrderServiceBean.purchaseOrderDao: PurchaseOrderDaoJpa not bound
  | 	at org.jboss.injection.JndiPropertyInjector.lookup(JndiPropertyInjector.java:82)
  | 	at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:99)
  | 	at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:89)
  | 	at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:61)
  | 	at org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionInvocation.java:89)
  | 	at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:83)
  | 	at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
  | 	at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:74)
  | 	at org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1076)
  | 	at org.jboss.ejb3.pool.AbstractPool.create(AbstractPool.java:83)
  | 	at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:56)
  | 	at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:51)
  | 	at org.jboss.ejb3.pool.ThreadlocalPool.create(ThreadlocalPool.java:53)
  | 	at org.jboss.ejb3.pool.ThreadlocalPool.get(ThreadlocalPool.java:93)
  | 	at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:58)
  | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  | 	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
  | 	... 51 more
  | Caused by: javax.naming.NameNotFoundException: PurchaseOrderDaoJpa not bound
  | 	at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
  | 	at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
  | 	at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
  | 	at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
  | 	at org.jnp.server.NamingServer.lookup(NamingServer.java:399)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:713)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:673)
  | 	at org.jboss.ejb3.JndiUtil.lookup(JndiUtil.java:44)
  | 	at org.jboss.injection.JndiPropertyInjector.lookup(JndiPropertyInjector.java:75)
  | 	... 67 more
  | 

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

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



More information about the jboss-user mailing list