0
votes

Disclaimer: this is not a duplicate of the "why isn't my JDBC resource declared in META-INF/context.xml taken into account" genre questions.

I have two Java EE web applications:

  • one is created inside Eclipde IDE using Eclipse's "Web Application Project" template

  • the other one is created using Maven, and then imported into Eclipse

Inside Eclipse I also have a Tomcat configured using the WTP Plugin, such that I can easily (or so I hoped) deploy my Eclipse Web Apps in there in a "one button push" way.

For each of the above described applications, I have a context.xml file placed in their META-INF directory, in which I declare some JDBC datasources as JNDI resources.

The Eclipse created application works fine when deployed in the WTP Tomcat inside Eclipse. I right-click the Tomcat server in Eclipse, add the project, start it and it all works fine, the JNDI datasources are found etc.

For the other project, the one created with Maven and imported inside Eclipse, if I add it to the WTP Tomcat, and manually specify where the war file was built by Maven (in the "target" dir) it seems to work, but the JNDI datasources are not found, more specifically, my Spring declared datasource:

 <jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/whatever" />

throws an exception saying no JNDI name is bound for "whatever".

If I deploy the very same war file in a "regular" Tomcat (just un unzipped Tomcat, no Eclipse involved) it works fine and the JNDI datasource declared in the war's META-INF/context.xml is found.

I've looked inside Eclipse's Tomcat working dir, and sure enough while for the Eclipse created project the context.xml file is copied inside "{catalina home}\wtpwebapps\eclipeProjectName\META-INF\context.xml", there's no such file (and folder structure) for the Maven project.

My question is then: does anyone know how you can have a Maven-created web app imported inside Eclipse and deployed in WTP Tomcat such that the META-INF/context.xml file is taken into account?

1
Have you installed the m2e wtp for Eclipse? eclipse.org/m2e-wtp - Charlee Chitsuk
Thanks, that a great advice. I will try it, though it says on their site that it has issues with pre-Juno Eclipse versions, and I'm constrained to use Eclipse Helios for this project... It is worth a shot none the less. - Shivan Dragon

1 Answers

0
votes

As you've mentioned that you are using the Eclipse Helios. There is a alternative one provided by JBoss as the Eclipse Update Site. The document told us as the following: -

The following folders should never be removed as they are part of composite requirement sites used for current/previous JBoss Tools releases:

Helios SR2: 0.13.1

Indigo SR2: 0.15.3

Juno (SOA Tooling Integration Stack ONLY - may not be needed much longer?): 0.14.0

Juno SR1 (can be removed when we have a Juno SR2 target platform instead, if anything newer exists): 0.16.0

Please note, before the Eclipse Juno, I used Helios and Indigo with this plugin. It also gives me a good result.

I hope this may help.