简体   繁体   English

NameNotFoundException:仅在从Eclipse Kepler发布而不是Indigo时才尝试查找'jdbc'

[英]NameNotFoundException: While trying to lookup 'jdbc' only when publishing from Eclipse Kepler but not Indigo

I'm able to publish my web-app to an Oracle Weblogic 12c (12.1.1) AdminServer from Eclipse Indigo 3.7.2 with oepe 12.1.1.1.1 我可以使用oepe 12.1.1.1.1将我的web-app从Eclipse Indigo 3.7.2发布到Oracle Weblogic 12c(12.1.1)AdminServer

However, the exact same web-app imported into Eclipse Kepler 4.3.1 with oepe 12.1.2.2 fails to publish with the following (fairly well trodden) exception and I'm trying to work out why?... 但是,使用oepe 12.1.2.2导入到Eclipse Kepler 4.3.1中的完全相同的web-app无法使用以下(相当完善的例程)异常发布,并且我试图找出原因?...

NameNotFoundException: While trying to lookup 'jdbc.oraclexe' didn't find subcontext 'jdbc'. NameNotFoundException:尝试查找'jdbc.oraclexe'时没有找到子上下文'jdbc'。 Resolved ''; 解决 ''; remaining name 'jdbc/oraclexe']; 剩下的名字'jdbc / oraclexe']; Link Remaining Name: 'jdbc/oraclexe' 链接剩余名称:'jdbc / oraclexe'

The Weblogic 12c data source is definitely available and I have to assume its configured correctly as the application deploys and runs with no problems when published from Indigo. Weblogic 12c数据源肯定是可用的,我必须假设它正确配置,因为应用程序部署并运行时从Indigo发布没有任何问题。

I'm also assuming the mappings in applicationContext.xml, web.xml and weblogic.xml are corrects as again there are no problems when published from Indigo. 我还假设applicationContext.xml中的映射,web.xml和weblogic.xml都是正确的,因为从Indigo发布时没有问题。 The mappings are as follows... 映射如下......

src\\main\\webapp\\WEB-INF\\spring\\applicationContext.xml SRC \\主\\ web应用\\ WEB-INF \\弹簧\\ applicationContext.xml中

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
 <property name="jndiName" value="java:comp/env/jdbc/oraclexe" />
</bean>

src\\main\\webapp\\WEB-INF\\web.xml SRC \\主\\ web应用\\ WEB-INF \\ web.xml中

<resource-ref>
 <description>Oracle Weblogic Connection Pool (oraclexe)</description>
 <res-ref-name>jdbc/oraclexe</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
 <mapped-name>jdbc/oraclexe</mapped-name>
</resource-ref>

build\\weboutput\\WEB-INF\\weblogic.xml 建立\\ weboutput \\ WEB-INF \\ weblogic.xml中

<resource-description>
 <res-ref-name>jdbc/oraclexe</res-ref-name>
 <jndi-name>oraclexe</jndi-name>
</resource-description>

I am wondering if the weblogic.xml isn't being made available during deployment (ie its not being copied to the src\\main\\webapp\\WEB-INF folder) rather than a problem with the mappings between jndiName/resource-ref/res-ref-name themselves? 我想知道weblogic.xml是否在部署期间不可用(即它没有被复制到src \\ main \\ webapp \\ WEB-INF文件夹)而不是jndiName / resource-ref / res之间的映射问题-ref-name自己? I've tried putting weblogic.xml directly in the src\\main\\webapp\\WEB-INF folder but I get the same exception. 我已经尝试将weblogic.xml直接放在src \\ main \\ webapp \\ WEB-INF文件夹中,但我得到了相同的异常。

My only other thought is that Indigo oepe 12.1.1.1.1 is happy publishing to Weblogic 12.1.1 but Kepler oepe 12.1.2 isn't and I should be publishing to a Weblogic 12.1.2 server? 我唯一的另一个想法是Indigo oepe 12.1.1.1.1很高兴发布到Weblogic 12.1.1但Kepler oepe 12.1.2不是,我应该发布到Weblogic 12.1.2服务器?

After a week or so of trial and error / process of elimination I've managed to resolve this issue and get a better understanding of the necessary mappings. 经过一周左右的试验和错误/消除过程后,我设法解决了这个问题并更好地理解了必要的映射。 As Elliott suspected this was a problem with the JNDI lookup. 正如Elliott怀疑这是JNDI查找的问题。 It was compounded by the fact that it (inadvertently) works as expected when published from Indigo to weblogic 12.1.1 (I'm still unsure why that's the case). 当它从Indigo发布到weblogic 12.1.1(我仍然不确定为什么会这样)时,它(无意中)按预期工作更加复杂。

My initial attempts to resolve this had focused on the mappings in the weblogic.xml. 我最初尝试解决这个问题的重点是weblogic.xml中的映射。 As I was publishing to a weblogic server I was in incorrectly assuming this was referenced when resolving the data source. 当我发布到weblogic服务器时,我错误地认为在解析数据源时引用了它。 As it turns out this isn't the case and my configuration didn't require a weblogic.xml resource-description. 事实证明情况并非如此,我的配置不需要weblogic.xml资源描述。

The applicationContext.xml remains the same... applicationContext.xml保持不变......

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
 <property name="jndiName" value="java:comp/env/jdbc/oraclexe" />
</bean>

However, the jndiName value of java:comp/env/ jdbc/oraclexe maps to the web.xml res-ref-name value jdbc/oraclexe (and not the weblogic.xml res-ref-name as I'd wrongly assumed)... 但是,java:comp / env / jdbc / oraclexe的jndiName值映射到web.xml res-ref-name值jdbc / oraclexe (而不是我错误地假设的weblogic.xml res-ref-name)。 ..

The web.xml mapped-name has been amended... web.xml映射名已被修改...

<resource-ref>
 <description>Oracle Weblogic console JDBC Data Source</description>
 <res-ref-name>jdbc/oraclexe</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
 <mapped-name>oraclexe</mapped-name>
</resource-ref>

...it's then the mapped-name value oraclexe that maps to the Weblogic console JDBC Data Source JNDI name. ...然后映射到Weblogic控制台JDBC数据源JNDI名称的映射名称值oraclexe

The resource-description node in the weblogic.xml has now been completely omitted as its not referenced in this particular configuration . weblogic.xml中的资源描述节点现在已完全省略,因为在此特定配置中未引用节点。

In my case, configuration was Weblogic 12.1.3 and Eclipse Mars 4.5.0; 在我的例子中,配置是Weblogic 12.1.3和Eclipse Mars 4.5.0; the ear worked fine deployed on wls but I had the same error when publishing from elipse. 耳朵工作得很好,但是从elipse发布时我也有同样的错误。 The problem was that the destiny of the datasource was a server created to deploy the application, and the eclipse published it on AdminServer. 问题是数据源的命运是为部署应用程序而创建的服务器,而ec​​lipse是在AdminServer上发布的。 I added both destinies to the datasource, and it worked ok. 我将两个命运添加到数据源,它运行正常。

This is a configuration that worked for me: 这是一个适合我的配置:

applicationContext.xml applicationContext.xml中

<jee:jndi-lookup id="dataSource" resource-ref="true"
    jndi-name="jdbc/alias" expected-type="javax.sql.DataSource" />

web.xml web.xml中

<resource-ref>
   <res-ref-name>jdbc/alias</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
</resource-ref>

weblogic.xml weblogic.xml中

<wls:resource-description>
    <wls:res-ref-name>jdbc/alias</wls:res-ref-name>
    <wls:jndi-name>jdbc/resource/weblogic</wls:jndi-name>
</wls:resource-description>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM