无法在Websphere中的组件级别上查找资源 [英] Unable to lookup resource on component level in Websphere

查看:97
本文介绍了无法在Websphere中的组件级别上查找资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在处理必须使用连接工厂的应用程序. 当我通过WAS中设置的名称在全局级别上直接查找连接工厂时,一切工作正常,但是为了进行解耦,我想在我的应用程序中定义资源引用并查找该名称.因此,我在application.xml中创建了以下条目:

At the moment I'm working on an application that has to use a connection factory. When I lookup the connection factory directly on a global level by the name set in WAS everything is working fine, but for means of decoupling I want to define a resource reference in my application and lookup that name. So I created following entry in my application.xml:

<resource-ref>
    <res-ref-name>jms/connectionFactory</res-ref-name>
    <res-type>javax.jms.ConnectionFactory</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

接下来我在EJB中要做的事情是进行以下查找:

What I do then inside my EJB is making following lookup:

ConnectionFactory connectionFactory = 
(ConnectionFactory) ic.lookup("java:comp/env/jms/connectionFactory");

这导致此异常:

javax.naming.NameNotFoundException: Name comp/env/jms not found in context "java:".

我也尝试过:

ConnectionFactory connectionFactory = 
(ConnectionFactory) ic.lookup("java:app/jms/connectionFactory");

导致:

javax.naming.NameNotFoundException: Context: BPMDev/applications/com.ibm.ws.AppNameSpaces/MAN_POT/root,
name: jms/connectionFactory: First component in name jms/connectionFactory not found.

有人知道我在做什么错吗? 预先感谢!

Does anyone know what I'm doing wrong here? Thanks in advance!

推荐答案

进一步的调查使我了解到:

Further investigations brought me to: Lookup jndi resources WebSphere 8.5, Spring 3.1.3, Hibernate 4.1.10 EJB 3

答案包含在其中:

application.xml中的条目和查找都必须以java:app/env开头.就我而言,这是:

Both the entry in the application.xml and the lookup have to be preceeded with java:app/env. For my case this is:

<resource-ref>
    <res-ref-name>java:app/env/jms/connectionFactory</res-ref-name>
    <res-type>javax.jms.ConnectionFactory</res-type>
    <res-auth>Container</res-auth>
   <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

和:

ConnectionFactory connectionFactory = 
(ConnectionFactory) ic.lookup("java:app/env/jms/connectionFactory");

这篇关于无法在Websphere中的组件级别上查找资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆