The mysteries of JDBC, JNDI, and Tomcat 5.5.4

Like thousands beforefore, I can't get connection pooling to work in Tomcat. I followed all the steps:
- put jar file for MySQL JDBC driver in TOMCAT_HOME/common/lib
- put the Jakarta Commons libs in the same location
- put resource declaration in META-INF/context.xml, per the Tomcat 5.5 docs like so:
<Context docbase="C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\commutercorps"
    path="\commutercorps" >
    <Resource name="jdbc/commutercorpsds"
        auth="Container"
        type="javax.sql.DataSource"
        maxActive="100"
        maxIdle="30"
        maxWait="10000"
        username="myusername"
        password="mypassword"
        driverClassName="com.mysql.jdbc.Driver"
        url="jdbc:mysql://localhost:3306/commuter_corps_signup"/>
</Context>- added resource ref in web.xml
    <resource-ref>
        <description>DB Connection</description>
        <res-ref-name>jdbc/commutercorpsds</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>I also double checked my connection URL and found that it does work fine when do this in my Java code:
Class.forName("com.mysql.jdbc.Driver");
Connection con =
    DriverManager.getConnection
    ("jdbc:mysql://localhost:3306/commuter_corps_signup", "...", "...");When I try to use Tomcat 5.5.4, JNDI like this...
                try
                    InitialContext initialContext = new InitialContext();
                    DataSource dataSource =
                            (DataSource) initialContext.lookup
                            ("java:comp/env/jdbc/commutercorpsds");
                    Connection con = dataSource.getConnection();
                    Statement stmt = con.createStatement();
                    stmt.executeUpdate(SQLMaker.getInsert(request,
                            request.getParameter("table")));
                    con.close();
                    stmt.close();
                } catch (NamingException e)
                    System.out.println(e.getMessage());
                    e.printStackTrace();
                }...I get...
Cannot create JDBC driver of class '' for connect URL 'null'
Caused by: java.sql.SQLException: No suitable driver
Any help would be greatly appreciated.
Thanks,
E

I used to get the message
Cannot create JDBC driver of class '' for
connect URL 'null'
No suitable driverError.
I was running, jakarta-tomcat-5.0.14.exe on windows.
I had it installed on a path without spaces
d:\tomcat5\Good.
I wanted to use Hibernate. So i used, extensiontools.What's that?
First create a env var: HIBERNATE_HOME pointing to
the hibernate extracted dir.No need for this.
Modify setenv.bat to correct %CP% for
commons-logging, commons-collection and anything
else: the version string at the end of the jar
changes.Wrong. You shouldn't be doing this.
Then run ddl2hbm, straightforward, fill info in all
tabs and hit generate. Will show some error message,
but still creates xmls.I don't see what any of this has to do with Tomcat deployment.
Then run hbm2java, and hand over each xml file as
parameter. Creates some java files in generated dir.
Modify the toString method to something simpler and
remove the import for apache class.All great, but still has nothing to do with Tomcat deployment.
move them over to webapp classes.You should create a WAR file or a separate context directory for your application under /webapps. If you're doing anything else, it's wrong.
Create JNDI in sever.xml as mentioned.Nope. Shouldn't be editing server.xml. Put that stuff in an application-specific context.xml, which goes in the META-INF of your WAR file.
Create reference in web.xml as mentioned.Good.
Goto conf/catalina/localhost/<webappname>.xmlNo need for this. Don't know what you're doing here.
add the line
<ResourceLink name="jdbc/Oracle"
type="javax.sql.DataSource" global="jdbc/Oracle"/>
replace Oracle with your datasource name.
and i got me workingMight be working, but it's not really correct.
%

Similar Messages

  • JNDI and Tomcat

    Alright. I'm new using JNDI, but i get all the Context, Binding, lookup operations and rellated issues.
    But, I need to connect to a server who has Tomcat using JNDI. (A high-school homework)
    In a manner of fact, I need to create 2 subcontext an in the last one I need to bind a name with a reference to cmd.exe (it seems that I need to execute it), all of it using Tomcat's JNDI connection capabilities.
    but when I'm trying to Construct the Initial Context reference, I'm not doing it in the right way... this is my Hashtable:
    Hashtable env = new Hastable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, //I don't know what the hell goes hereApparentntly from web examples I have seen, It's the Implementation of the JNDI SPI from the Service Provider I want to connect... I really don't know which one to put when using Tomcat, or find other one.
    I read in the HOW-TO section in the apache site, but find nothing...
    or didn't get the idea, I saw they only get the container like this:
    Context ct = new InitialContext();
    with no arguments... but I also tryed to do it that way, but the same NamingException is thrown, with the message that I need to psecify the context factory. Well. I hope it's clear my trouble, and any of you would help me.
    Not reporting anything else. Thanks.

    Hello,
    have you check the following link
    http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html
    excerpts
    Tomcat 5 provides a JNDI InitialContext implementation instance to web applications running under it, in a manner that is compatible with those provided by a Java2 Enterprise Edition application server. Entries in this InitialContext are configured in the $CATALINA_HOME/conf/server.xml file, and may be referenced by the following elements in the web application deployment descriptor (/WEB-INF/web.xml) of your web application:
    used the resource file <resource-env-ref> , do not harcdode your jndi.properties
    basic data source factory
    <org.apache.commons.dbcp.BasicDataSourceFactory>
    and bean factory
    org.apache.naming.factory.BeanFactory
    thaks

  • JDBC(JNDI):Connection dinamically managed

    Hi all,
    I'm using
    1) Crystal Reports 2008 for the reports' design,
    2) Java Reporting Component (version 18.8.4.1094) for the integration in java environment,
    3) JBoss (version 4.2.3) as Application Server
    4) Oracle 11 as DBMS
    in a web application.
    When I create a report using JDBC (JNDI) and specify as the "Connection Name (optional)" the following string "java:jdbc/name_data_source",
    How is managed the connection of the report and any sottoreports? In other words are the connections dynamically managed by the container web or ejb?
    Thank you very much.

    Hi, Andrea,
    I'm gonna' make a few guesses here:
    2) Java Reporting Component (version 18.8.4.1094)
    I think you mean Crystal Reports for Java (CRJ) 2.8 version 12.2.209.1094. Neither the JRC (the name for the 1.x series) nor the CRJ (the 2.x series) has any version number in the 18.x range.
    sottoreports
    I think that means "subreports."
    are the connections dynamically managed by the container web or ejb?
    There are two ways the connections can be managed. If you've created a JNDI connection (a named connection), then you can base a report off of it, then at a later date change where the JNDI connection itself points to and the report should still work correctly, as long as the new target database shares the same schema as the original.
    The other way you can manage the connection is to use code to change the database connection information inside the report itself. In this way, you could change it from one JNDI connection to another or even to another type of connection altogether. Again, however, the schemas between the old and the new connections must match.
    Regards,
    Bryan

  • Problem loading jdbc driver in Tomcat

    Hi,
    I have got a connection to MySQL5.0 from TomCat 5.5.13, that was test correctly in development (JSC Upd 1) but I encounter the following deployment error :
    com.sun.rave.web.ui.appbase.ApplicationException: org.apache.jasper.JasperException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
    When I verify, I found that if I put the mysql Connector JDBC driver in <tomcat>/common/lib, there is no error.
    But when the MySql Connector JDBC driver resides in <tomcat>/shared/lib, the error persists.
    What's the difference ? shouldn't it work for both ?
    Thanks in advance for any pointers and advise.

    hmm... i guess that it's a must to include the lib at /common/lib instead of shared/lib .
    Is there a Tomcat resource that I can read up on ?
    rgds

  • JDBC thin and thick clients

    What is the difference between JDBC thin and JDBC thick clients and their usage ?

    hi,
    in sort tearms,
    Oracle has a thin client driver which mean you can connect to a oracle database without the Oracle client installed on your machine.
    Thick client would need the Oracle Client database drivers etc.. Drivers include JDBC-ODBC bridge drivers JDBC drivers depending on tns resolution.
    thanks

  • How to Install and Configure Java and Tomcat

    Hi Everybody,
    I am using the following versions of java and tomcat:
    JAVA: j2sdk-1_4_2_13
    Tomcat: jakarta-tomcat-5.0.5
    I tried to configure several times both but everytime the result is the same. I am setting the following variables:
    PATH: .;D:\j2sdk1.4.2_13\bin;D:\Tomcat 5.0\bin
    CLASSPATH: .;D:\j2sdk1.4.2_13\lib;D:\Tomcat 5.0\common\lib\servlet-api.jar
    JAVA_HOME: D:\j2sdk1.4.2_13
    Please correct what mistake i am doing again and again. I appreciate your effort.
    Thanks in advance.
    Himanshu

    Fine sir, I will tell evrything in detail what steps i am following during installation and configuring java and Tomcat.
    1) I am using the following versions(exe) of java and tomcat:
    JAVA: j2sdk-1_4_2_13-windows-i586-p
    Tomcat: jakarta-tomcat-5.0.5
    2) Then, i follow exactly the same variable names and values to configure java as mentioned below to make java work under User variables header:
    PATH: .;D:\j2sdk1.4.2_13\bin
    CLASSPATH: .;D:\j2sdk1.4.2_13\lib
    JAVA_HOME: D:\j2sdk1.4.2_13
    Above steps i follow only for installing java. And it also not working properly. If i run my .java file from the destination of the file then it will be execulted but if i try to execute from any other location then it doesn't, it shows the following message in the DOS prompt:
    error: cannot read: Hello.java
    1 error
    Now, please correct what mistake i am doing.
    Thanks
    Himanshu

  • Directory Editor and Tomcat

    Hey all,
    I am installing Directory Editor 6.0, and following the install documentation, I added some lines to the 'catalina.policy' file in the Tomcat configuration to allow DE to work properly.
    grant codeBase "file:${catalina.home}/webapps/de/-" {
      permission java.security.AllPermission;
    grant codeBase "file:${catalina.home}/webapps/de/-" {
      permission javax.security.auth.AuthPermission "getLoginConfiguration";
      permission javax.security.auth.AuthPermission "setLoginConfiguration";
      permission javax.security.auth.AuthPermission "createLoginContext.SunDirectoryLogin";
      permission javax.security.auth.AuthPermission "modifyPrincipals";
      permission java.util.PropertyPermission "*", "read,write";
      permission java.net.SocketPermission "*", "connect,resolve";
      permission java.io.FilePermission "*", "read, write";
      permission java.util.PropertyPermission "Debug.enable", "read";
    grant {
      permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      permission java.lang.RuntimePermission "accessClassInPackage.sun.beans.*";
      permission java.lang.RuntimePermission "accessClassInPackage.sun.io";
      permission java.lang.RuntimePermission "accessDeclaredMembers";
    };I deployed the WAR file, and was able to perform the initial configuration of DE (location of the config directory, what suffix to configure, what credentials to connect to the DS as...). Once those steps finish, I can see data in the DS under the newly created "Services" OU for DE, but when I try to login to DE as either a regular user or as an administrative user, I get an error. The catalina.out log show the following:
    2007-06-25 16:00:14,398 [TP-Processor11] WARN  org.apache.struts.action.RequestProcessor - Unhandled Exception thrown: class java.lang.SecurityException
    2007-06-25 16:00:14,398 [TP-Processor11] ERROR com.sun.dml.web.DmlRequestProcessor - No exception handler for java.lang.SecurityException: Unable to locate a login configuration.  Forwarding to error page.
    java.lang.SecurityException: Unable to locate a login configuration
            at com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:97)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
            at java.lang.Class.newInstance0(Class.java:350)
            at java.lang.Class.newInstance(Class.java:303)
            at javax.security.auth.login.Configuration$3.run(Configuration.java:216)
            at java.security.AccessController.doPrivileged(Native Method)
            at javax.security.auth.login.Configuration.getConfiguration(Configuration.java:210)
            at com.sun.dml.web.LoginAction.execute(LoginAction.java:113)
            at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
            at com.sun.dml.web.DmlRequestProcessor.processActionPerform(DmlRequestProcessor.java:180)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
            at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
            at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
            at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
            at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)
            at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:876)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
            at java.lang.Thread.run(Thread.java:595)
    Caused by: java.io.IOException: Unable to locate a login configuration
            at com.sun.security.auth.login.ConfigFile.init(ConfigFile.java:206)
            at com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:95)
            ... 32 moreIs there anything else that needs to be done to allow access for DE when using Tomcat?
    TIA, Mark

    here is the info re: Directory Editor and Tomcat 5.5:
    http://docs.sun.com/app/docs/doc/820-2487/de-bugs-fixed-known
    6397929
    When deploying on Tomcat 5.5, login fails due to a missing JAAS configuration file
    To work around this issue, first create tomcat-install-path/bin/setenv.sh containing the following line:
    JAVA_OPTS="-Djava.security.auth.login.config=$CATALINA_HOME/conf/jaas.conf"
    Next create tomcat-install-path/conf/jaas.conf. Edit the file to contain the following lines:
    SunDirectoryLogin {
    com.sun.dml.auth.SunDirectoryLoginModule required;
    };

  • Difference between Tomcat4.X and Tomcat 5.X ?

    Hi,
    Can any body tell me what is the difference between Tomcat4.X and Tomcat 5.X ?
    Thanks

    corlettk wrote:
    difference between Tomcat4.X and Tomcat 5.X ? 1for a given value of 1.

  • Problem with JNDI and JSP in Tomcat

    Hi,
    Basically, what I've done is to use the Tomcat administration web
    application to create the DataSource, which looks like it populated the
    server.xml (see below). I then try to access the testconn.jsp, and am
    getting that "Name java:comp is not bound in this Context" error.
    I was wondering if anyone could tell me what I'm doing wrong?
    Thanks,
    Feri
    My Configuration:
    - Tomcat 5.0.19
    - MySQL 4.0.18-nt
    - mysql-connector-java-3.0.15-ga-bin.jar
    server.xml:
    <GlobalNamingResources>
    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    <!-- Editable user database that can also be used by
    UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
    type="org.apache.catalina.UserDatabase"
    description="User database that can be updated and saved">
    </Resource>
    <ResourceParams name="UserDatabase">
    <parameter>
    <name>factory</name>
    <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
    </parameter>
    <parameter>
    <name>pathname</name>
    <value>conf/tomcat-users.xml</value>
    </parameter>
    </ResourceParams>
    <!--Feri test JNDI-->
         <Context crossContext="true" debug="5" docBase="injury" path="/injury" reloadable="true">
         <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_injury_log." suffix=".txt" timestamp="true"/>
              <Resource name="jdbc/injury" auth="Container"
    type="javax.sql.DataSource">
    </Resource>
    <ResourceParams name="jdbc/injury">
         <parameter>
              <name>factory</name>
              <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
         </parameter>
    <parameter>
    <name>username</name>
    <value>root</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>root</value>
    </parameter>
         <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
    </parameter>
         <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/injury</value>
    </parameter>
         <parameter>
              <name>maxIdle</name>
              <value>30</value>
         </parameter>
         <parameter>
              <name>maxActive</name>
              <value>10</value>
         </parameter>
         <parameter>
              <name>maxWait</name>
              <value>10000</value>
         </parameter>
    </ResourceParams>
         </Context>
    <!--Feri test JNDI end-->
    </GlobalNamingResources>
    \webapps\injury\WEB-INF\web.xml:
    <resource-ref>
    <description>Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file.</description>
    <res-ref-name>jdbc/injury</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    \webapps\injury\testconn.jsp
    <%@ page import="java.sql.*" %>
    <%@ page import="javax.sql.*" %>
    <%@ taglib prefix="ct" uri="/injury" %>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
    <h1>Connection test</h1>
    <ct:connection name="jdbc/injury">
    <%
    Statement stmt= conn.createStatement();
    ResultSet rs;
    rs = stmt.executeQuery("select * from user");
    while (rs.next()){
    %><%=rs.getString(1)%><%=rs.getInt(2) %><br><%
    rs.close();
    stmt.close();
    %>
    </ct:connection>
    ConnectionTag.java
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import javax.naming.*;
    import javax.sql.*;
    import javax.sql.DataSource;
    public class ConnectionTag extends TagSupport implements TryCatchFinally {
    private Connection conn;
    // JNDI name of the connection
    private String name;
    public void setName(String name)
         this.name = name;
    public int doStartTag()
         throws JspException
         try {
         Context env = (Context) new InitialContext().lookup("java:comp/env");
         DataSource ds = (DataSource) env.lookup(name);
         if (ds != null)
              conn = ds.getConnection();
         } catch (Exception e) {
         throw new JspException(e);
         if (conn == null)
         throw new JspException("can't open connection " + name);
         pageContext.setAttribute("conn", conn);
         return EVAL_BODY_INCLUDE;
    public void doCatch(Throwable t)
         throws Throwable
         throw t;
    public void doFinally()
         try {
         Connection conn = this.conn;
         this.conn = null;
         pageContext.removeAttribute("conn");
         conn.close();
         } catch (Exception e) {
    Tomcat 5.0\conf\Catalina\localhost\injury.xml
    <?xml version='1.0' encoding='utf-8'?>
    <Context displayName="Injury" docBase="E:\Tomcat 5.0\webapps\injury" path="/injury" className="org.apache.catalina.core.StandardContext"
    cachingAllowed="true" charsetMapperClass="org.apache.catalina .util.CharsetMapper" cookies="true" crossContext="false" debug="0"
    mapperClass="org.apache.catalina.core.StandardContextMapper" useNaming="true" wrapperClass="org.apache.catalina.core.StandardWrapper" >
    <Resource auth="Container" description="Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file." name="jdbc/injury" type="javax.sql.DataSource"/>
    <ResourceLink global="jdbc/injury" name="injury" type="javax.sql.DataSource"/>
    </Context>

    Hi,
    First of all, you can find alot of information about this in the forum about jsp's.
    I think a good thing to do is not to put your context tag directly into the server.xml file.
    What you should do is create a context.xml file with the context-tag in it, and put it in the META-INF directory of your .war file. Upon deployment to tomcat5 this file will be extracted from the war, copied to the conf\enginename\hostname directory, and it will be renamed to contextName.xml.
    I think you are developing directly into the webapps directory, and I believe you should avoid that and use the deployment feature of the manager web-app or you should use the deployertool from you ide or standalone ant.
    anyway, for starters try to remove the context tag from the server.xml file as described above, and check out the jsp / jdbc forums for simular problems and answers.
    good luck

  • JNDI, Data Source and Tomcat

    Hi,
    I am using Tomcat 4.1
    I am using JDBC to connect to to SQL 2000.
    In the past I use JDBC 2.0 standsrd package to connect to it and it was fine.
    Now, for some reason, I need to use DataSource via JNDI.
    Here is my server.xml
    <Resource name="jdbc/SQLNorthwind" scope="Shareable" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/SQLNorthwind">
    <parameter>
    <name>validationQuery</name>
    <value>select * from Products</value>
    </parameter>
    <parameter>
    <name>url</name> <value>jdbc:microsoft:sqlserver://W2KSERVER1:1433;DatabaseName=Northwind</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>george</value>
    </parameter>
    <parameter>
    <name>maxActive</name>
    <value>20</value>
    </parameter>
    <parameter>
    <name>maxWait</name>
    <value>5000</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>com.microsoft.jdbcx.sqlserver.SQLServerDataSource</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>george</value>
    </parameter>
    <parameter>
    <name>maxIdle</name>
    <value>2</value>
    </parameter>
    </ResourceParams>
    It was generated by the Tomcat admin tools via the web browser.
    It is my web.xml
    <servlet>
    <servlet-name>JNDIDatabase</servlet-name>
    <display-name>JNDIDatabase</display-name>
    <description>JNDIDatabase</description>
    <servlet-class>com.testing.servlet.jdbc.jndi.JNDIDatabase</servlet-class>
    </servlet>
    Now here is my servlet source code for connection testing
    private Connection conn;
    private Statement stmt;
    private ResultSet rs;
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {
    Context ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup("jdbc/SQLNorthwind");
    conn = ds.getConnection("george", "george");
    } catch(NamingException e) {
    this.log("Naming exception in JNDIDatabase init", e);
    e.printStackTrace();
    } catch(SQLException e) {
    this.log("SQL exception in JNDIDatabase init", e);
    e.printStackTrace();
    The problem is no connection is obtained in init(). So what's wrong with my setting/code? Please help me to fix my setting/code.
    Thank you in advance.

    Follow what you said, no more NamingException. Thanks, Dave.
    now I receive another error.....
    2002-10-18 00:34:12 JNDIDatabase: SQL exception in JNDIDatabase init
    java.sql.SQLException: Cannot load JDBC driver class 'com.microsoft.jdbcx.sqlserver.SQLServerDataSource'
         at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:529)
         at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:329)
         at hk.com.scope.servlet.jdbc.jndi.JNDIDatabase.init(JNDIDatabase.java:37)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:924)
         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:658)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2388)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
         at java.lang.Thread.run(Thread.java:536)
    I am sure msutil.jar, mssqlserver.jar and msbase.jar are stored in /WEB-INF/lib directory and using them in standard JDBC is OK!
    This is an extraction from MS JDBC help file.....
    The data source class for the SQL Server driver is:
    com.microsoft.jdbcx.sqlserver.SQLServerDataSource
    For information on SQL Server 2000 Driver for JDBC data sources, see "Connecting Through Data Sources".
    The driver class for the SQL Server driver is:
    com.microsoft.jdbc.sqlserver.SQLServerDriver
    com.microsoft.jdbc.sqlserver.SQLServerDriver is working properly, I am sure.

  • JNLP and Tomcat JNDI DataSource

    Software
    JDK 1.5 Update 6
    Tomcat 5.5.4
    Requirements
    I have a Client Side requirement and this project is going to be deployed to 5 users initially all in a lan but there are very chances of adding more users simultaneously.
    I am thinking of deploying in JNLP Environment.
    At present the Swing application though in development phase is running a little slow and therefore I required the way by which I could store the references of the Object in some server.Getting Connection Object is also a major time consumer and so I needed some way by which I can use the Tomcat DataSource and use the JNDI facility to store certain intermediate values in the server.
    Can I use the JNDI in the JNLP Application.
    Please provide me the way by which I can do this stuff
    Thanks in advance
    CSJakharia

    .> I am using tomcat 5.5.9 and oracle 9i. I am hosting a
    portal which uses connection pooling.
    I have decided to use the connection pooling through
    tomcat's JNDI naming lookup.Excellent idea.
    for this i have used the following steps --
    1) made entry of <resource-ref> in webapp's web.xml
    2) made relevant and corresponding entry in tomcat's
    ${TOMCAT_HOME}/conf/context.xml (for JNDI
    JDBC-datasource)No, don't do it that way.
    .> my problems are--
    1) making the entry for context.xml in tomcats
    conf folder makes the application war dependent
    on web server which i dont want to make.Yes, it does.
    2) i have to put classes12.jar in tomcats
    ${TOMCAT_HOME}/common/lib folder and only then the
    application connection pooling works else the
    exception coming on tomcat console is --
    org.apache.tomcat.dbcp.dbcp.SQLNestedException.
    Why aren't you using the latest JDBC driver from Oracle? That's in ojdbc14.jar.
    .> I dont want to put classes12.jar in web server i want
    the web server's JNDI lookup to pick the driver frm
    my webapps' internal lib folder. please help me on
    these very pressing and immediate issues. all the
    help coming from anyone in this regard is very much
    welcome.
    thanks in advance!
    VaivYour instinct is correct.
    (1) Put ojdbc14.jar in WEB-INF/lib of your WAR file.
    (2) Edit the <Context> XML into a file named context.xml and put it in META-INF of your WAR. Tomcat should pick up the context information for the JNDI data source from that.
    Everything is in the WAR, and you don't have any dependence on the server that way.
    %

  • Problem with JDBC and Tomcat

    I don't know where the problem originate, the only thing in my memory is that the program worked very well on my PC yesterday, but today, without even slightest change, it doesn't work anymore. As to debug it, I simplified the codes to the least, but it still refuse to work. I was beaten down by this problem totally, and cannot make out any solution for it, so, I come here, hoping to find a warrior to kill this damned bug for me.
    My program is a Servlet, but for the purpose of debugging, I have recode it to an Application/Servlet. When run as a application, I can get the result expected, but as a Servlet, :-(, maybe you should see it by yourself. My server software is Tomcat 4.1.15, and the JDK version is 1.4.0. To excute this program, you should add Data Source "Test" to ODBC.
    ///////////////////////code begins/////////////////////////
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class Ex extends HttpServlet
         int ErrorType = 0;
         String err = new String("");
         public static void main(String args[]) throws Exception{
              Ex cEx = new Ex();
              cEx.init();     
              System.out.println(cEx.ErrorType);     
         public void init() {
              String url = "jdbc:odbc:Test";
              ErrorType = 3;     //passed
              try{
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              } catch (ClassNotFoundException e) {
                   e.printStackTrace();
                   ErrorType = 1; //trapped in Class.forName
              try{
                   Connection c = DriverManager.getConnection(url);
              } catch (SQLException e) {
                   e.printStackTrace();
                   ErrorType = 2; //trapped in DriverManager.getConnection
                   err = e.getMessage();
         public void service(HttpServletRequest req, HttpServletResponse res)
                   throws IOException {
              res.setContentType("text/html; charset=GB2312");
              PrintWriter out = res.getWriter();
              out.println("Success " + "<p>" + ErrorType + "<p>" +err);
              out.close();
    //////////////////////////code ends///////////////////////////////
    The result from the Servlet tell me that the problem occurred within the connection process, I don't know who should be responsible to this - Tomcat or JDBC?

    If you could print the exception that you got then that would help :) In the mean time, I could make a guess. It is unlikely that your application server (in this case, Tomcat) is blocking connections from your servlet. So the problem is either with JDBC directly or with the underlying datasource. It seems unlikely that it is JDBC given that you have stated that the code has not changed and it works in application form.
    My guess would be that you are coming up against some sort of security constraint (eg: your DBMS is letting you log in from one IP but not another?, your Java plug-in security policy is disallowing the connection?). It's hard to say.
    But if it works as an application but not via a servlet then you could try putting this in your java.policy file, which is located in the directory where your plug-ins are installed (eg: "C:\Program Files\Java\<version>\lib\security\") on Windows systems;
    permission java.net.SocketPermission "bend xp:1099", "listen,connect,accept";
    Try that, see if it works :)
    Ben

  • Java and Tomcat: Why do I need the port number when accessing Tomcat?

    My ultimate goal is to setup a website that displays data from a database. I will use Java, Apache, Oracle, and whatever else I need to create a website the uses servlets, JavaServer Pages, and JDBC.
    I�ve got four Pentium III computers:
    1. Windows 2000 Server to be the web server (MyWebServer, IP = 10.10.1.1).
    2. Windows 2000 Professional to be the database server (MyDatabaseServer, IP = 10.10.1.2).
    3. Windows 2000 Professional that I use to develop and test (MyDeveloperPC, IP = 10.10.1.3).
    4. Windows 2000 Professional that I use as a client to connect to the website (MyClientPC, IP = 10.10.1.4).
    I installed Java Web Services Developer Pack on MyWebServer. It requires Java 2 Standard Edition (J2SE), so I installed that first. The files I downloaded and installed are as follows:
    J2SE: j2sdk-1_4_0-rc-win.exe
    JWSDP: jwsdp-1_0-ea1-win.exe
    After installing these products, I set the environment variables as follows:
    JAVA_HOME = c:\j2se
    JWSDP_HOME = c:\jwsdp
    Path = c:\j2se\bin;c:\jwsdp\bin; [and other previous statements]
    On MyWebServer I start Tomcat (from the JWSDP menu option). It starts properly (as far as I can tell).
    Then, from MyClientPC I open Internet Explorer and in the address box I type:
    http://10.10.1.1
    �The page cannot be displayed�.
    I then try again and add the port number:
    http://10.10.1.1:8080
    This displays the page c:\jwsdp\webapps\root\index.html.
    Here�s my question: Why do I have to enter the port number to get a page displayed? Do I have to have Apache HTTP Server running on MyWebServer to display pages without entering the port number?
    Thanks for your help.

    When you web server is running at the default Http Port, then you do not have to specify the port yourself.(The browser does it automatically)
    So if you run your web server at port 80, then you will not have to specify the port explicitlyin the url.
    If you want to use tomcat only as a jsp/servlet processing engine then install a web server (either IIS, or apache web server) and run it on port 80. (so that you dont have to specify the port)
    Now configure tomcat to run as a servlet engine for this web server. for this refer to the tomcat documentation.
    If you do not want to have an external webserver then you can configure tomcat itself to run at port 80 (in this case tomcat would do the work of both the web server as well as jsp/servlet engine... but this is not the setup for a production site). this can be done by changing the server.xml file in the conf directory of tomcat installation.
    hope this helps.
    regards,
    Abhishek.

  • Problem using JDBC (JNDI) DataSource and data-sources.xml w/ OC4J

    I have a JClient application developed in JDev X. It works fine when using a JDBC URL for the connection (which then writes the connection into the BC4J.xcfg files, one for each application module). However, I would like the app to retrieve the data source from the server's data-sources.xml file. However, when, on the configurations tab of the application module I set the connection type to JDBC DataSource, and give it the JNDI name, it does not work, either with the embedded OC4J or the stand-alone OC4J. Any suggestions???
    In the stand alone OC4J I verified that the data source exists (using java -jar admin.jar ormi://nemethzoltan3 admin welcome -application adatklinika -testDataSource -location jdbc/adatklinikaCoreDS) ... so the data source is defined in the data-sources.xml. Of course the error I get is JBO-30003.
    If I just try to "test" the data source in Jdeveloper (using the context menu of the app module, and setting it to use the adatklinikaCoreDS) I get a JNDI error: unable to lookup data source and at level 3 a "javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial". I checked, the data source is defined under tools->embedded OC4J properties->data sources.
    If I try to run the main form, simply nothing happens.
    Please help!!!

    Ok, figured out why running from jdeveloper wasn't working: the embedded OC4J server wasn't started (start it by running an html page from your project or something...and make sure you don't have a stand-alone oc4j running). AND more importantly it didn't have the library "embedded oc4j client" library included (project properties -> profiles -> development -> libraries)...which is needed for whatever reason.
    Now to try and get it working with the stand-alone OC4J...

  • Error while retriving the connection uisng JNDI and DATASOURCE

    hi guys,
    i had a specifed data source in the the data-sources.xml of CONFIG folder of my application
    <data-source class="oracle.jdbc.pool.OracleConnectionCacheImpl"
    connection-driver="oracle.jdbc.driver.OracleDriver" location="jdbc/OracleDS_native"
    name="OracleDS"
    password="abc"
    url="jdbc:oracle:thin:@BC354321:1521:CRADV1"
    username="xyz"/>
    Here is the program i had written to retrive the datasource
    package javaapplication1;
    import javax.naming.InitialContext;
    import java.sql.*;
    import javax.naming.Context;
    import javax.sql.DataSource;
    public class Main {
    public Main() {
    public static void main(String[] args) {
    Connection con =null;
    try {
    InitialContext context = new InitialContext();
    System.out.println("##########context********"+context);
    DataSource ds = (DataSource)context.lookup("jdbc/OracleDS_native");
    System.out.println("##########DataSource********"+ds);
    con = ds.getConnection();
    catch( Exception exception ) {
    // process exception
    exception.printStackTrace();
    if(con!=null)
    try{ con.close(); }
    catch(SQLException e)
    { e.printStackTrace();}
    ERROR:
    ##########context********javax.naming.InitialContext@2bbd86
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at javaapplication1.Main.main(Main.java:35)
    what might be the problem??
    regards
    Phani

    Phani,
    From the contents of your "data-sources.xml" file that you posted, it looks like you are using a pre-10.1.3.x version of OC4J (stand-alone?), so Jason's link may not be helpful.
    Nonetheless, as Jason mentions, you do need to set some properties that need to be passed to the "InitialContext" class constructor. Probably something like the following.
    [Note that the code is uncompiled and untested.]
    Properties prp = new Properties();
    prp.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.evermind.server.rmi.RMIInitialContextFactory");
    prp.put(Context.PROVIDER_URL, "ormi://oc4j_host");
    prp.put(Context.SECURITY_PRINCIPAL, "user");
    prp.put(Context.SECURITY_CREDENTIALS, "password");
    Context ctx = new InitialContext(prp);
    DataSource ds = (DataSource) context.lookup("jdbc/OracleDS_native");And replace "oc4j_host" with the name of your OC4J host machine as well as "user" and "password" with the appropriate values.
    Note that you can probably use the OC4J admin user's details.
    Good Luck,
    Avi.

Maybe you are looking for

  • Adhoc Query Join Problem

    Hi All, I have created a query on PNP logical database which looks very simple, Lets say it has pernr, first name, last name, and Mailing ZIP on the output. P0006-SUBTY = 'MAIL' Now, the problem is .... if someone do not have mailing address subtype

  • Why is my iphone saying invalid security code in my billing information?

    i am trying to download a free app and it keep saying verification required. then i click okay and it says secuity code is invalid, it is correct and i keep retyping it in and it wont go through? how do i fix this?

  • OTL Dual & Parallel Approval - Is it possible ??

    Hi, We have following requirements from the client on timesheet approval for single application Payroll. 1. Can we have multiple approval using supervisor hierarchy for n level of supervisor? 2. Can parallel approval is possible. Where timesheet of u

  • After upgrade, graphic doesn't work more

    This morning after having upgraded Archlinux with pacman -Syu with different errors, at reboot graphic doesn't start more, it arrive ad text login. Today afternoon pacman -Syu has found new updates on linux and nvidia, but this time, without errors.

  • Problems in Replication over a dialup ISDN link

    We have a Multimaster Replication setup with a Remote Database connecting to the MDS site over a dial up ISDN line at pre determined intervals. At the time of initial setting up of the two Masters the remote machine was physically located on the LAN