jms unresolved message-destination-ref

时间:2010-02-21 13:15:27

标签: netbeans glassfish jms glassfish-3

我正在使用netbeans 6.8和glassfish v3,并使一个简单的jms应用程序工作。 我明白了:

com.sun.enterprise.container.common.spi.util.InjectionException: 
Exception attempting to inject Unresolved Message-Destination-Ref 
jms/myQueue@java.lang.String@null into class enterpriseapplication4.Main

代码:

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
}

在我的Glassfish v3管理控制台中, 我有jms / myFactory作为我的ConnectionFactory和 jms / myQueue作为我的目标资源。

我错过了什么?

完整筹码:

WARNING: enterprise.deployment.backend.invalidDescriptorMappingFailure
com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Unresolved Message-Destination-Ref jms/myQueue@java.lang.String@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

此致

3 个答案:

答案 0 :(得分:1)

主题jms/myQueue的查找失败:

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

也许你确实创建了一个主题,但它很可能在JNDI名称jms/myQueue下无法使用(顺便说一下,命名主题 jms/myQueue可能不是最好的选择,但这是旁注)。

要浏览JDNI树以查找主题,请使用以下命令(GlassFish v3未随管理控制台中的JDNI浏览器一起提供):

asadmin list-jndi-entries

在列表中找到您的上下文,然后使用:

asadmin list-jndi-entries --context <your context>

答案 1 :(得分:1)

尝试删除静态声明。

答案 2 :(得分:1)

在遵循“使用Netbeans 6进行Java EE 5开发”的JMS教程后,我遇到了与OP相同的问题。使用全新安装的Glassfish 3.0.1和Netbeans 6.9.1。

解决方案是从:

更改Resource注释(Netbeans已生成)的属性

@Resource(name =“jms / myQueue”)

为:

@Resource(mappedName =“jms / myQueue”)

(连接工厂也一样)

[编辑:当然,现在我重读了章节,我看到作者在侧栏中明确提到了这一点。我真的应该RTFM!]