Specifying JNDI Datasources When Debugging WebApp From Idea

This applies somewhat to both 4.0.3 and EAP 4.5 2210.

First a little background:

My JNDI datasource descriptors work beautifully when I define them in my own
deployment descriptor file under $/conf/Catalina/localhost;
however, I have yet to successfully get Tomcat to recognize my JNDI
datasource descriptors when I put them within it's server.xml file. I have
even used the Tomcat Administration console application to define them, so
that it would craft them properly, and choose where within the server.xml
file it wanted to put them. Yet, they never work unless I supply them in my
own deployment descriptor.

Therein lies the rub with debugging webapps in Idea. Idea creates a
temporary deployment descriptor (c:/Documents and
Files/Me/.IntellijStuff/Blah/Blah/Blah/.../ROOT.xml). In EAP4.5, I find
help documentation for adding JNDI descriptors to weblogic apps, and to CMP
EJBs, but I can see no way to inform a Tomcat webapp that it should inject
additional JNDI datasources of my choosing into its temporary, generated
deployment descriptor file.

Any suggestions?



Comment actions Permalink


I too feel your pain....

In 4.0.3, the only way (that worked for me anyway...) was to define the datasources in the part of server.xml as so:- factory org.apache.commons.dbcp.BasicDataSourceFactory ...... and then make a link to the resource within the element of server.xml as so:- With 4.5, i've also been pulling my hair out!!!! Adding something like this to server.xml, seems to work just fine. factory org.apache.commons.dbcp.BasicDataSourceFactory ........ ]]>

OK, so its not the nicest way, but you can still leave the datasources defined in your context descriptor and Idea will ignore them.

Hope this helps, and i've made some sense (if not, blame it on our air con failure!).

If anyone from Jetbrains would like to tell us all how to do this properly, if its a bug, and when its likely to get fixed i'd appreciate it.



Comment actions Permalink

I'm using 4.5 and think I've found a way to do it.

First create a folder in your project named tomcat. Create the following subdirectories under the tomcat directory: conf, logs, temp, work

Next, copy the contents of your real Tomcat installation's conf directory to your tomcat/conf directory. This should include your server.xml.

Edit the server.xml to include your context and any required Resources, etc.

Then, when you configure the Tomcat server in the "Application Servers" dialog, for the "Tomcat base directory" specify your tomcat directory not the original Tomcat installation's.

Comment actions Permalink

I have tried the configuration you described - but my webapps do not seem to initialize. If possible, could you upload an example web app module for IDEA 4.5 ?


Comment actions Permalink

I can verify that JNDI datasources will get picked up (in my case an HSQLDB datasource).

I didn't make a copy of my tomcat. All I did was point my Tomcat Application Servers Tomcat Home and Tomcat Base Directory to my installation of Tomcat. I dropped my Context Descriptor into the appropriate /conf folder and made sure that the Run/Debug configuration Deployment tab for the Web Module showed the proper value in the Application Context.

One thing I found was that the XML file name and the context have to match. So if your webapp is /foo the file name must be foo.xml

Comment actions Permalink


I'm trying to do exactly this but I'm not having success like some of you are. I'm running IDEA 4.5.3 on Mac OS X. I'm running several projects at once on my system, so I want to have a separate catalina base for each project. This is the output of a start script that does what I want to do in IDEA:

afield% burns2 start
Starting Tomcat application server
Using CATALINA_BASE: /Users/afield/Documents/Burns2/Tomcat
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Users/afield/Documents/Burns2/Tomcat/temp
Using JAVA_HOME: /Library/Java/Home
Using CLASSPATH: /Library/Java/Home/lib/tools.jar:/Library/Tomcat/bin/bootstrap.jar
Using JAVA_ENDORSED_DIRS: /Library/Tomcat/common/endorsed

But when I configure the Tomcat plugin with the BASE and HOME set as above, the plugin complains that my HOME does not have a conf/ directory. I don't have a conf. directory there because it is in fact in my BASE. I created a blank CONF directory and even copied the one from the BASE into the HOME to see if that would solve the problem. It did allow me to configure Tomcat and it would actually launch in IDEA:

/Library/Tomcat/bin/catalina.sh run
Using CATALINA_BASE: /Users/afield/Library/Caches/IntelliJ IDEA/tomcat_Tomcat 4_9d44c215
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Users/afield/Documents/Burns2/Tomcat/temp
Using JAVA_HOME: /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home
Using CLASSPATH: /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home/lib/tools.jar:/Library/Tomcat/bin/bootstrap.jar
Using JAVA_ENDORSED_DIRS: /Library/Tomcat/common/endorsed

My application initializes too, so it is being deployed. This indicates to me that IDEA has convinced Tomcat to use my BASE (I don't understand why my BASE is being set in a temp directory if the temp directory does not list my webapps in it though - it appears to just have a conf and work folder). However, my datasource that is set in my /Users/afield/Documents/Burns2/Tomcat/conf/server.xml file is being ignored. In fact, it looks like the whole server.xml is being regenerated by IDEA without any input from me.

My app depends on the database. Does anyone know what I need to do to get IDEA to use my server.xml for my Tomcat installation?

Help would be greatly appreciated. Thanks,



Please sign in to leave a comment.