tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Blackburn" <rwblackb...@gmail.com>
Subject Re: "java.lang.NullPointerException" with JDBC connection from InitialContext
Date Sat, 03 Jan 2009 15:43:28 GMT
Hi Chuck,
Thanks for responding – here are the answer to your questions...

>>       <Realm className="org.apache.catalina.realm.JDBCRealm"
>> connectionName="username" connectionPassword="password"
>> connectionURL="jdbc:mysql://localhost:3306/db_name?
>> autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF8"
>> driverName="com.mysql.jdbc.Driver" roleNameCol="roleNameCol"
>> userCredCol="userCredCol" userNameCol="userNameCol"
>> userRoleTable="userRoleTable" userTable="userTable"/>
>
> The above indicates the database for the realm is on "localhost"; is that true for both
your test (Windows) system and the server (Linux) box?  Is localhost defined in the Linux
box /etc/hosts file?
>
Yes, both the test machine and server have a localhost DB that are
identical form one another. The test machine works with the localhost,
but I can also point the test machine to the DB on the server (using
the URL instead of "localhost") and that work fine as well.


>> And I put this in the /conf/Catalina/webapps/ROOT.xml ...
>
> Unless you have a <Host> named "webapps" defined in server.xml, that doesn't do
anything.  Also, any <Resource> would have to be nested inside a <Context> element,
and you haven't indicated that's the case.
Yes, there is a <Host> defined with that name, and the <Resource> is
inside a <Context>. I appologize if I removed too much from the
information I sent.

>>     <Resource name="jdbc/tranzzle" auth="Container"
>> type="javax.sql.DataSource"  username="username" password="password"
>> driverClassName="com.mysql.jdbc.Driver"
>> url="jdbc:mysql://localhost:3306/db_name?autoReconnect=true
>> &amp;useUnicode=true&amp;characterEncoding=UTF8"
>> validationQuery="select 1"/>
>
> Again, this is using localhost; is that correct?  Are you using the same database for
both application data and authentication/authorization?  (If so, that's a bit unusual.)
>
Yes both are using the the same DB.


>> (I've tried puting this in my /conf/context.xml too, hoping that would
>> help, but it didn't)
>
> That would make it available to all webapps, not just the one you're interested in.
>
Correct, I was doing this just as a test, but it still did not work.


> Where did you put the jar containing the MySQL driver classes?  Make sure you don't have
it in more than one place.
>
The JAR is in the [tomcat]/lib folder. The
authentication/authorization works, but the  application data does
not. I would assume this means the DB driver classes are loading
successfully, or else not even the authentication/authorization would
work.


On Tue, Dec 30, 2008 at 10:31 PM, Caldarale, Charles R
<Chuck.Caldarale@unisys.com> wrote:
>> From: Robert Blackburn [mailto:rwblackburn@gmail.com]
>> Subject: "java.lang.NullPointerException" with JDBC
>> connection from InitialContext
>>
>>       <Realm className="org.apache.catalina.realm.JDBCRealm"
>> connectionName="username" connectionPassword="password"
>> connectionURL="jdbc:mysql://localhost:3306/db_name?
>> autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF8"
>> driverName="com.mysql.jdbc.Driver" roleNameCol="roleNameCol"
>> userCredCol="userCredCol" userNameCol="userNameCol"
>> userRoleTable="userRoleTable" userTable="userTable"/>
>
> The above indicates the database for the realm is on "localhost"; is that true for both
your test (Windows) system and the server (Linux) box?  Is localhost defined in the Linux
box /etc/hosts file?
>
>> And I put this in the /conf/Catalina/webapps/ROOT.xml ...
>
> Unless you have a <Host> named "webapps" defined in server.xml, that doesn't do
anything.  Also, any <Resource> would have to be nested inside a <Context> element,
and you haven't indicated that's the case.
>
>>     <Resource name="jdbc/tranzzle" auth="Container"
>> type="javax.sql.DataSource"  username="username" password="password"
>> driverClassName="com.mysql.jdbc.Driver"
>> url="jdbc:mysql://localhost:3306/db_name?autoReconnect=true
>> &amp;useUnicode=true&amp;characterEncoding=UTF8"
>> validationQuery="select 1"/>
>
> Again, this is using localhost; is that correct?  Are you using the same database for
both application data and authentication/authorization?  (If so, that's a bit unusual.)
>
>> (I've tried puting this in my /conf/context.xml too, hoping that would
>> help, but it didn't)
>
> That would make it available to all webapps, not just the one you're interested in.
>
> Where did you put the jar containing the MySQL driver classes?  Make sure you don't have
it in more than one place.
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and
is thus for use only by the intended recipient. If you received this in error, please contact
the sender and delete the e-mail and its attachments from all computers.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>



-- 
Rob Blackburn

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message