[jboss-user] [EJB 3.0] - Portable Resource mapping to JNDI Name

ejb3workshop do-not-reply at jboss.com
Wed Oct 10 08:25:00 EDT 2007


I would like to use a symbolic name to link to the Connection factory so using the mapped name attribute in the code does not seem an option.


  | //MappedName does not seem portable
  | //@Resource(mappedName="ConnectionFactory")
  | @Resource(name="jms/ConnectionFactory2")
  | private QueueConnectionFactory factory;
  | 

Then I added the following to my deployment descriptors

ejb-jar.xml

  | <message-driven>
  |     <ejb-name>BatchJobProcessor</ejb-name>
  |     <ejb-class>com.thunderhead.backend.BatchJobProcessor</ejb-class>
  |     <transaction-type>Bean</transaction-type>
  |     <resource-ref>
  |         <description/>              
  |         <res-ref-name>jms/ConnectionFactory2</res-ref-name>
  |         <res-type>javax.jms.QueueConnectionFactory</res-type>
  |         <res-auth>Container</res-auth>
  |         <!--mapped-name>jnp://localhost:1100/ConnectionFactory</mapped-name-->
  |     </resource-ref>
  |     <resource-ref>
  |         <description/>                
  |         <res-ref-name>queue/TransactionProcessors</res-ref-name>
  |         <res-type>javax.jms.Queue</res-type>
  |         <res-auth>Container</res-auth>
  |         <mapped-name>jnp://localhost:1100/queue/TransactionProcessors</mapped-name>
  |     </resource-ref>
  | </message-driven>
  | 
Again specifying the "real" JNDI name in the ejb-jar.xml file works, but does not provide me with suitable abstraction and portability. I was hoping to place all the JBoss specific JNDI mapping in the jboss.xml file like this.

jboss.xml

  | <message-driven>
  |  <ejb-name>BatchJobProcessor</ejb-name>
  |  <destination-jndi-name>queue/BatchJobProcessors</destination-jndi-name>
  |  <resource-ref>
  |      <res-ref-name>jms/ConnectionFactory2</res-ref-name> 
  |      <jndi-name>jnp://localhost:1100/ConnectionFactory</jndi-name>             
  |  </resource-ref>
  |  <resource-ref>
  |      <res-ref-name>queue/TransactionProcessors</res-ref-name> 
  |      <jndi-name>jnp://localhost:1100/queue/TransactionProcessors</jndi-name>             
  |  </resource-ref>
  | </message-driven>
  | 

However during deployment the following error occurs:

anonymous wrote : 
  | 3:17:54,453 WARN  [JmxKernelAbstraction] persistence.units:ear=ThunderheadEJB_1178.ear,jar=ThunderheadEJB.jar,unitName=ThunderheadPU is not registered
  | 3:17:54,453 WARN  [ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=ThunderheadEJB.jar
  | ava.lang.RuntimeException: mapped-name is required for jms/ConnectionFactory2 of deployment BatchJobProcessor
  |        at org.jboss.injection.ResourceHandler.loadXmlResourceRefs(ResourceHandler.java:94)
  |        at org.jboss.injection.ResourceHandler.loadXml(ResourceHandler.java:167)
  |        at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:352)
  |        at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:292)
  |        at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:356)
  |        at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
  |        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
  |        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
  |        at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
  |        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |        at java.lang.reflect.Method.invoke(Method.java:597)
  |        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
  |        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
  |        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
  |        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
  |        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
  |        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
  |        at $Proxy0.start(Unknown Source)
  |        at org.jboss.system.ServiceController.start(ServiceController.java:417)
  |        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
  |        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |        at java.lang.reflect.Method.invoke(Method.java:597)
  |        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
  |        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
  |        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
  |        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
  |        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
  |        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
  |        at $Proxy33.start(Unknown Source)
  |        at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:512)
  |        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  |        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |        at java.lang.reflect.Method.invoke(Method.java:597)
  |        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
  |        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
  |        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
  |        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
  |        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
  |        at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
  |        at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
  |        at org.jboss.ws.integration.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:93)
  |        at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
  |        at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
  |        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
  |        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
  |        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
  |        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
  |        at $Proxy34.start(Unknown Source)
  |        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
  |        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
  |        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
  |        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
  |        at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
  |        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |        at java.lang.reflect.Method.invoke(Method.java:597)
  |        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
  |        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
  |        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
  |        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
  |        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
  |        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
  |        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
  |        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
  |        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
  |        at $Proxy67.deploy(Unknown Source)
  |        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
  |        at org.jboss.ha.framework.server.FarmMemberService.deploy(FarmMemberService.java:412)
  |        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
  |        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
  |        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
  |        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
  | 

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

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



More information about the jboss-user mailing list