views:

415

answers:

3

hi,

I am using netbeans 6.8, and glassfish v3, and making a simple jms application to work. I got this:

com.sun.enterprise.container.common.spi.util.InjectionException: 
Exception attempting to inject Unresolved Message-Destination-Ref 
jms/[email protected]@null into class enterpriseapplication4.Main

Code:

public class Main {
@Resource(name = "jms/myQueue")
private static Topic myQueue;
@Resource(name = "jms/myFactory")
private static ConnectionFactory myFactory;
...
// the rest is just boiler plate created by netbeans
}

In my Glassfish v3 admin console, I have jms/myFactory as my ConnectionFactory and jms/myQueue as my Destination Resources.

What am I missing?

Full stack:

WARNING: enterprise.deployment.backend.invalidDescriptorMappingFailure
com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Unresolved Message-Destination-Ref jms/[email protected]@null into class enterpriseapplication4.Main
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:614)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:384)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:210)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:202)
        at org.glassfish.appclient.client.acc.AppClientContainer$ClientMainClassSetting.getClientMainClass(AppClientContainer.java:599)
        at org.glassfish.appclient.client.acc.AppClientContainer.getMainMethod(AppClientContainer.java:498)
        at org.glassfish.appclient.client.acc.AppClientContainer.completePreparation(AppClientContainer.java:397)
        at org.glassfish.appclient.client.acc.AppClientContainer.prepare(AppClientContainer.java:311)
        at org.glassfish.appclient.client.AppClientFacade.prepareACC(AppClientFacade.java:264)
        at org.glassfish.appclient.client.acc.agent.AppClientContainerAgent.premain(AppClientContainerAgent.java:75)
        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 sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/jms/myQueue' in SerialContext targetHost=localhost,targetPort=3700 [Root exception is javax.naming.NameNotFoundException: No object bound for java:comp/env/jms/myQueue [Root exception is java.lang.NullPointerException]]
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:513)
        ... 15 more
Caused by: javax.naming.NameNotFoundException: No object bound for java:comp/env/jms/myQueue [Root exception is java.lang.NullPointerException]
        at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:218)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:428)
        ... 17 more
Caused by: java.lang.NullPointerException
        at javax.naming.InitialContext.getURLScheme(InitialContext.java:269)
        at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:318)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:75)
        at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:688)
        at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:657)
        at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:148)
        ... 18 more

Regards

A: 

The lookup of the topic jms/myQueue failed:

javax.naming.NameNotFoundException: No object bound for java:comp/env/jms/myQueue

Maybe you did create a topic but it is very likely not available under the JNDI name jms/myQueue (by the way, naming a topic jms/myQueue is maybe not the best choice but this is a side note).

To browse the JDNI tree to find your topic, use the following command (GlassFish v3 doesn't ship with the JDNI browser in the admin console):

asadmin list-jndi-entries

Find your context in the list and then use:

asadmin list-jndi-entries --context <your context>
Pascal Thivent
A: 

try to remove static declaration.

kislo_metal
A: 

I was having the same problem as the OP after following a JMS tutorial from "Java EE 5 Development with Netbeans 6". Using a fresh install of Glassfish 3.0.1 and Netbeans 6.9.1.

The solution was to change the attributes of the Resource annotation (that Netbeans had generated) from:

@Resource(name = "jms/myQueue")

to:

@Resource(mappedName = "jms/myQueue")

(and the same for the Connection Factory too)

[Edit: of course, now I reread the chapter I see the author mentions this explicitly in a sidebar. I really should RTFM!]

Gary Hodgson