0 Replies Latest reply: May 27, 2009 3:59 PM by Fin Steenbjerg RSS

Problem placing @Resource#mapped-name into jboss.xml

Fin Steenbjerg Newbie

I have implemented a minor application that needs to be able to run on at least IBM Websphere (V7.0) and JBoss (V5.1.0GA). It is therefore important that all server specific stuff is placed in deployment descriptors. I have a problem with the following code:

@Stateless
public class ApplicationRegistryBean implements ApplicationRegistry {

 @Resource ConnectionFactory connectionFactory;
 @Resource(mappedName="/queue/appstateQueue") Queue queue;


The above code works with the following jboss.xml file (not everything is included):

 <enterprise-beans>
 <session>
 <ejb-name>ApplicationRegistryBean</ejb-name>
 <resource-ref>
 <res-ref-name>dk.kifi.appstate.applicationregistry.ApplicationRegistryBean/queue</res-ref-name>
 <resource-name>AppStateQueue</resource-name>
 </resource-ref>
 <resource-ref>
 <res-ref-name>dk.kifi.appstate.applicationregistry.ApplicationRegistryBean/connectionFactory</res-ref-name>
 <resource-name>AppStateCF</resource-name>
 </resource-ref>
 </session>
 </enterprise-beans>

 <resource-managers>
 <resource-manager res-class="">
 <res-name>AppStateQueue</res-name>
 <res-jndi-name>/queue/appstateQueue</res-jndi-name>
 </resource-manager>
 <resource-manager res-class="">
 <res-name>AppStateCF</res-name>
 <res-jndi-name>java:/ConnectionFactory</res-jndi-name>
 </resource-manager>
 </resource-managers>


But I would like to avoid the mapped-name attribute like this:

@Stateless
public class ApplicationRegistryBean implements ApplicationRegistry {

 @Resource ConnectionFactory connectionFactory;
 @Resource Queue queue;


The above jboss.xml should work with this code, but I get the following exception during deployment:

DEPLOYMENTS IN ERROR:
 Deployment "vfsfile:/D:/udvikling/jboss-5.1.0.GA/server/default/deploy/appstate.ear.ear/" is in error due to the following reason(s): java.lang.RuntimeException: mapped-name or message-destination-link is required for dk.kifi.appstate.applicationregistry.ApplicationRegistryBean/queue of deployment ApplicationRegistryBean

 at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:993)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:939)
 at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:873)
 at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.checkComplete(MainDeployerAdapter.java:128)
 at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:369)
 at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
 at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
 at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 at java.lang.Thread.run(Thread.java:619)


Does anyone know how to avoid the mapped-name attribute ?