WebLogic JNDI查找无法正常工作

时间:2018-04-11 10:34:03

标签: java-ee dependency-injection jms weblogic jndi

我在WebLogic中创建了JMS服务器,并添加了JMS模块,JMS子部署和两个JMS资源,如下所示

enter image description here

enter image description here

enter image description here

enter image description here

在代码中我尝试像这样检索这些资源

@Resource(mappedName="jms/DockerQueue")
private Destination localDockerQueue;

@Resource(mappedName="jms/DockerConnectionFactory")
private ConnectionFactory localDockerConnectionFactory;

但是,我遇到了运行时错误

Caused By: com.bea.core.repackaged.springframework.beans.factory.NoSuchBeanDefin
itionException: No bean named 'org.javaee7.sample.PersonDatabase/localDockerQueu
e' is defined; nested exception is javax.naming.LinkException:  [Root exception
is javax.naming.NameNotFoundException: Unable to resolve 'jms.DockerQueue'. Reso
lved 'jms'; remaining name 'DockerQueue']; Link Remaining Name: 'jms/DockerQueue
'
        at com.bea.core.repackaged.springframework.beans.factory.support.Default
ListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:701)
        at com.bea.core.repackaged.springframework.beans.factory.support.Abstrac
tBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1180)
        at com.bea.core.repackaged.springframework.beans.factory.support.Abstrac
tBeanFactory.doGetBean(AbstractBeanFactory.java:284)
        at com.bea.core.repackaged.springframework.beans.factory.support.Abstrac
tBeanFactory.getBean(AbstractBeanFactory.java:202)
        at com.bea.core.repackaged.springframework.beans.factory.support.Abstrac
tBeanFactory.doGetBean(AbstractBeanFactory.java:275)
        Truncated. see log file for complete stacktrace
Caused By: javax.naming.LinkException:  [Root exception is javax.naming.NameNotF
oundException: Unable to resolve 'jms.DockerQueue'. Resolved 'jms'; remaining na
me 'DockerQueue']; Link Remaining Name: 'jms/DockerQueue'
        at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingMana
ger.java:114)
        at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.
java:1037)
        at weblogic.jndi.internal.ApplicationNamingNode.resolveObject(Applicatio
nNamingNode.java:186)
        at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.
java:1009)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:22
3)
        Truncated. see log file for complete stacktrace
Caused By: javax.naming.NameNotFoundException: Unable to resolve 'jms.DockerQueu
e'. Resolved 'jms'; remaining name 'DockerQueue'
        at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(Basic
NamingNode.java:1292)
        at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.jav
a:354)
        at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.j
ava:227)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:21
4)
        at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:
527)
        Truncated. see log file for complete stacktrace
>

另外,我在JNDI树中找不到那些绑定。不过,我可以看到DockerJMSSystemResourceDockerJMSServer

enter image description here

如何正确注入这些JMS资源?

1 个答案:

答案 0 :(得分:0)

解决方案是将缺少的目标添加到JMS资源

enter image description here