7
votes

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

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?...

NameNotFoundException: While trying to lookup 'jdbc.oraclexe' didn't find subcontext 'jdbc'. Resolved ''; remaining name 'jdbc/oraclexe']; Link Remaining Name: '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.

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. The mappings are as follows...

src\main\webapp\WEB-INF\spring\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

<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

<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 (i.e 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? I've tried putting weblogic.xml directly in the src\main\webapp\WEB-INF folder but I get the same exception.

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?

3
Sorry. It still sounds like a jndi lookup issue. Have you checked the InitialContext?Elliott Frisch

3 Answers

7
votes

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. 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).

My initial attempts to resolve this had focused on the mappings in the weblogic.xml. As I was publishing to a weblogic server I was in incorrectly assuming this was referenced when resolving the data source. As it turns out this isn't the case and my configuration didn't require a weblogic.xml resource-description.

The applicationContext.xml remains the same...

<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)...

The web.xml mapped-name has been amended...

<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.

The resource-description node in the weblogic.xml has now been completely omitted as its not referenced in this particular configuration.

0
votes

In my case, configuration was Weblogic 12.1.3 and Eclipse Mars 4.5.0; the ear worked fine deployed on wls but I had the same error when publishing from 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. I added both destinies to the datasource, and it worked ok.

0
votes

This is a configuration that worked for me:

applicationContext.xml

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

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

<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>