Problem working with JNDI in IDEA and Tomcat?

I'm not sure if this is really the right forum for this since it's not EAP but it's a J2EE problem so hopefully it'll fit in ok...

I am trying to get my application to work which uses a jdbc resource defined in my Tomcat 4.0.4 server.xml file. Tomcat starts up from within IDEA just as expected, however when I attempt to load my page it returns the following errors:

In the IDEA run pane:

Unable to connect using primary JNDI
No suitable driver
Trying secondary database connection


In Tomcat:

javax.servlet.ServletException: Unable to connect to database


Has anybody seen this happen before?? In case it makes any difference this project was started in jDeveloper and I'm trying to move it over to IDEA. The move has been successful in every aspect apart from this (it compiles fine etc).

16 comments
Comment actions Permalink

Sorry forgot to be specific... apart from Tomcat 4.0.4 I am using IDEA 4.0.3 and Oracle for the database. The content of my server.xml includes this context:

  
  
    
      user
      db_user
    
    
      password
      db_pass
    
    
      driverClassName
      oracle.jdbc.driver.OracleDriver
    
    
      driverName
      jdbc:oracle:thin@server:port:sid
    
  

]]>

0
Comment actions Permalink

Are you sure you have the oracle driver in your classpath?

0
Comment actions Permalink

Thanks for your response Markus. Yes I have the drivers in the classpath for my module and have "include module classpath" selected in my WebApp configuration. I just double-checked that to make sure. Do you have any other ideas?

0
Comment actions Permalink

Try to put Oracle driver jars into Tomcat common/lib directory

--
regards,
Alexey Kudravtsev
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


"Rob Bradley" <no_mail@jetbrains.com> wrote in message news:4184702.1082996977395.JavaMail.itn@is.intellij.net...

Thanks for your response Markus. Yes I have the drivers in the classpath for my module and have "include module classpath"

selected in my WebApp configuration. I just double-checked that to make sure. Do you have any other ideas?


0
Comment actions Permalink

Hi Alexey. I've tried that already but to no avail. I'm not sure if you are familiar with the Oracle JDBC drivers but the file I'm using is "classes12.zip", I'm assuming the .zip extension shouldn't be causing any problems as I've used this package in the past.

0
Comment actions Permalink

As far as I know Tomcat does not .zip archives. Rename it to xx.jar and put it in Tomcat's common lib - then it should work.

Regards

Reto

0
Comment actions Permalink

Thanks Reto, tried that too but still no luck. It's wierd as I've never had this problem before, however this is the first project I've done in IDEA using JNDI so I suppose there's bound to be some teething probs...

It's definately the JNDI or Tomcat side of things because I've used Oracle JDBC in IDEA before without any problems.

0
Comment actions Permalink

I have this problem too, at least in the 4.0.3 release and I am using Tomcat 5. Just out of curiosity, have you tried to run it outside of IDEA to see if that works? For me it works outside of IDEA, but not when run inside the IDE.

0
Comment actions Permalink

I have to admit I hadn't tried this and when I did I found that I get exactly the same problem... wierd thing is that this works if I'm using jDeveloper and the server embedded in that.

It must be something with my JNDI params not being referenced or something... gotta get to the bottom of this as we will be using Tomcat as our production server for this project which was one of the reasons I wanted to start working with the project in IDEA with Tomcat.

As you can probably tell my Tomcat experience with JNDI is limited to put it mildly, I'm sure I'm probably just making some stupid rookie Tomcat mistake here as this is the first time I've used JNDI in Tomcat.

With regards to your problem Chris, there is a known issue in 4.0.3 which prevents Tomcat 5 from starting from within the IDE, it's a regression bug as it worked fine in the 4.0.2 release. The good news is that JetBrains have fixed this in the 4.0.4 release of IDEA which is in EAP at the moment and due out very shortly.

0
Comment actions Permalink

Can you post the code were you are trying to access the database
connection via the lookup?

If we can't help you quickly, you should post to the Tomcat list. Yoav
and some of the other TC developers are there daily.

Norris Shelton
Sun Certified Java Programmer




Rob Bradley wrote:

>I have to admit I hadn't tried this and when I did I found that I get exactly the same problem... wierd thing is that this works if I'm using jDeveloper and the server embedded in that.
>
>It must be something with my JNDI params not being referenced or something... gotta get to the bottom of this as we will be using Tomcat as our production server for this project which was one of the reasons I wanted to start working with the project in IDEA with Tomcat.
>
>As you can probably tell my Tomcat experience with JNDI is limited to put it mildly, I'm sure I'm probably just making some stupid rookie Tomcat mistake here as this is the first time I've used JNDI in Tomcat.
>
>With regards to your problem Chris, there is a known issue in 4.0.3 which prevents Tomcat 5 from starting from within the IDE, it's a regression bug as it worked fine in the 4.0.2 release. The good news is that JetBrains have fixed this in the 4.0.4 release of IDEA which is in EAP at the moment and due out very shortly.

>

0
Comment actions Permalink

JNDI and Tomcat are just a real pain the butt. I've had to resort to some serious contortions in my code to get it to work consistently. Lit it was suggested, post the code and maybe someone here can nail it for you, or post it to Tomcat list of course. It's not an IDEA problem for SURE because I'm using it right now without a problem.

R

0
Comment actions Permalink

I just wanted to let everybody know I've figured this problem out, not sure if I should admit to this because it was a really stupid mistake on my part... but I feel I can admit to it since none of you picked me up on it when I even made the same mistake in my example ;) (j/k):

  driverName
  jdbc:oracle:thin(at)server:port:sid
]]>

Still confused?? So was I... until I noticed the lack of a colon after the "thin" driver declaration!!

Seriously though thanks to everybody for trying to help me with this... I still can't believe I made such a simple mistake. Wasn't IDEA or Tomcat, I must've just made the typo when I was copying out the JDeveloper connection data into my server.xml file.

0
Comment actions Permalink

A have exactly the same problem with tomcat 4.0.3 / 5.0.16 and IDEA 4.0. I use a firebird database and JayBird JDBC driver. Tomcat says "cannot load driver class 'null'".

0
Comment actions Permalink

Ok, now we are on to something. I am using Firebird and the Jaybird driver. I have given up on this a long time ago and resorted to JDBC connections directly, but it would be nice to figure this out. Let me know if you have any luck, I may try to look into it more since I never suspected Firebird driver before now. Probably a coincidence, but worth checking out.

0
Comment actions Permalink

I was hoping the error was something else :) IDEA beginner and been fighting the same problem now for hours.

I am using Tomcat 4.1.27, IDEA 4.0 and DB2 v8.1. The error message is like this: "java.sql.SQLException: Cannot create JDBC driver of class 'COM.ibm.db2.jdbc.app.DB2Driver' for connect URL 'jdbc:db2:xxxx'.

In server.xml I define the resouce as GlobalNamingResources like this:

factory org.apache.commons.dbcp.BasicDataSourceFactory driverClassName COM.ibm.db2.jdbc.app.DB2Driver url jdbc:db2:stafli Then the context for this webapp is defined like this: ]]>

If I deploy the webapp by placing the app war file in the Tomcat webroot the app works fine. Must be related to my project settings in IDEA.

Really hope somebody can help me out

0
Comment actions Permalink

Probably you already did this but you need to have the package containing "COM.ibm.db2.jdbc.app.DB2Driver" in your Libraries (Classpath) and have it selected to Deploy with Web Module in your Web Module Settings.

0

Please sign in to leave a comment.