users@glassfish.java.net

Re: JMS Resources in sun-web.xml

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Wed, 18 Mar 2009 10:57:58 +0100

use "mappedName" instead of "name"

> @Resource(mappedName="QueueConnectionFactory")
> private QueueConnectionFactory queueConnectionFactory;

and you don't need to include the sun-web.xml anymore... it is mapped
in the container,,,,,


On Wed, Mar 18, 2009 at 10:42 AM, Adam Jenkins
<adamjenkinstmpredirect_at_yahoo.com.au> wrote:
>
> Hi,
>
> Previously I had my JMS queues and queuConnectionFactories declared in my JSF managed beans using @Resource(mappedName="jms/etcEtc").  But I read on some posts that it's best practice to declare them in the sun-web.xml and reference them by name.
>
> So I declared a couple of resource in my sun-web.xml
>
>  <resource-ref>
>      <res-ref-name>QueueConnectionFactory</res-ref-name>
>      <jndi-name>jms/QueueConnectionFactory</jndi-name>
>  </resource-ref>
>  <resource-env-ref>
>      <resource-env-ref-name>QueryQueue</resource-env-ref-name>
>      <jndi-name>jms/QueryQueue</jndi-name>
>  </resource-env-ref>
>
> And referenced them in code:
>
>    @Resource(name="QueueConnectionFactory")
>    private QueueConnectionFactory queueConnectionFactory;
>
>    @Resource(name="QueryQueue")
>    private Queue queryQueue;
>
> I get the following error (below).  Can someone tell me what I'm doing wrong here and the 'best practice' way to specify references to JMS queues from a web tier?
>
> Caused by: javax.faces.FacesException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Message-Destination-Ref QueryQueue_at_java.lang.String_at_null into class com.megajobindex.web.SearchManagedBean
>        at com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:340)
>        at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:527)
>        ... 100 more
> Caused by: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Message-Destination-Ref QueryQueue_at_java.lang.String_at_null into class com.megajobindex.web.SearchManagedBean
>        at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
>        at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
>        at com.sun.enterprise.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:127)
>        at com.sun.faces.vendor.GlassFishInjectionProvider.inject(GlassFishInjectionProvider.java:79)
>        at com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:298)
>        ... 101 more
> Caused by: java.lang.IllegalArgumentException: Can not set javax.jms.Queue field com.megajobindex.web.SearchManagedBean.queryQueue to com.sun.enterprise.naming.SerialContext
>        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
>        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
>        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
>        at java.lang.reflect.Field.set(Field.java:657)
>        at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:338)
>        ... 105 more
>
>
> Cheers
> Adam
>
>
>      Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>



-- 
Please help to test this application:
http://fgaucho.dyndns.org:8080/cejug-classifieds-richfaces