facebook

Tomcat Mysql Jndi PLEASE HELP

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #229053 Reply

    good4evil
    Member

    I am having trouble with my web app.

    I have created a datasource using tomcats admin page. The datasource information was automatically inserted into the server.xml. I then added a refrence to the datasource into the application’s web.xml file.

    I get the following error when trying to get a connection from the datasource

    Cannot create JDBC driver of class ” for connect URL ‘null’.

    The .jar for mysql is in tomcat’s classpath. I made sure of that by setting it up in the myeclipse prefrences of the application server.

    Please help,
    Marc

    #229059 Reply

    kyrylkov
    Member

    Having JNDI config in server.xml is a bad idea.

    If you are using Tomcat 5.5.x restore the old server.xml and create context.xml in META-INF directory with the following example contents:

    
     <Context>
    
        <Resource name="jdbc/resourcename" auth="Container"
                  type="javax.sql.DataSource" 
             maxActive="100" 
               maxIdle="30"
               maxWait="10000" 
              username="user" 
              password="pass"
       driverClassName="com.mysql.jdbc.Driver"
                   url="jdbc:mysql://server.com:3306/database?autoReconnect=true" />
    
    </Context>
    

    You don’t need to have anything in web.xml for this to work.

    #229073 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev, this is not ME related.

    Additionally Marc, kyrylkov’s advice is a good one, makes your app very portable, easy to deploy. The context.xml file is also valid for Tomcat 5.0.x, but the format is a little different. For future compatibility I suggest using kyry’s suggestion and Tomcat 5.5.x

    #229105 Reply

    good4evil
    Member

    Do i name the file context.xml?

    also what is the syntax of the file for tomcat 5.0?

    thanks,
    marc

    #229109 Reply

    Riyad Kalla
    Member

    Do i name the file context.xml?

    yes

    also what is the syntax of the file for tomcat 5.0?

    This is why god invented documentation: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html

    #229513 Reply

    wendal
    Member

    @support-rkalla wrote:

    Moving to OT > Soft Dev, this is not ME related.

    Additionally Marc, kyrylkov’s advice is a good one, makes your app very portable, easy to deploy. The context.xml file is also valid for Tomcat 5.0.x, but the format is a little different. For future compatibility I suggest using kyry’s suggestion and Tomcat 5.5.x

    Is this really portable to other Servlet Engines and Application Servers ?

    (i.e. Resin, Jetty, JBoss, ..)

    #229519 Reply

    kyrylkov
    Member

    Of course each engine and AS has its own deployment/configuration rules/settings, but still it is better to keep the config files separate, rather than mix general server configs with your application settings.

    Having context.xml for Tomcat allows you to delpoy your web application even if you don’t have permissions to edit server.xml on the server.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Tomcat Mysql Jndi PLEASE HELP

You must be logged in to post in the forum log in