Ok ... I'll bite. What's a realm got to do with the original post? The
OP is just trying to setup a database pool via tomcat's built-in JNDI.
OP -- Your code didn't match completely with the example code on the
tomcat website. Here it is matched up with what's in the docs:
InitialContext initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/Library");
The only two real changes here are 1) a missing / mark in between java:
and comp and 2) the return of new InitialContext() is of type
InitialContext. The second difference is probably not affecting your
situation. Everything else looked really good.
--David
Martin Gainty wrote:
>Ray-
>
>You will need to supply JDBC parameters as in this example Realm specification
>in server.xml
>
> <Realm className="org.apache.catalina.realm.JDBCRealm"
> driverName="org.gjt.mm.mysql.Driver"
> connectionURL="jdbc:mysql://localhost/authority"
> connectionName="D" connectionPassword="******"
> userTable="users" userNameCol="user_name" userCredCol="user_pass"
> userRoleTable="user_roles" roleNameCol="role_name" />
>
>M-
>---------------------------------------------------------------------------
>This e-mail message (including attachments, if any) is intended for the use of
>the individual or entity to which it is addressed and may contain information
>that is privileged, proprietary , confidential and exempt from disclosure. If
>you are not the intended recipient, you are notified that any dissemination,
>distribution or copying of this communication is strictly prohibited.
>---------------------------------------------------------------------------
>Le présent message électronique (y compris les pièces qui y sont annexées, le
>cas échéant) s'adresse au destinataire indiqué et peut contenir des
>renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le
>destinataire de ce document, nous vous signalons qu'il est strictement
>interdit de le diffuser, de le distribuer ou de le reproduire.
>----- Original Message -----
>From: "Ray Madigan" <[EMAIL PROTECTED]>
>To: "Tomcat Users List" <[email protected]>
>Sent: Tuesday, January 16, 2007 7:02 PM
>Subject: RE: Cannot create JDBC driver
>
>
>
>
>>Well,
>>
>>I have to apologize, I was unsure of how much information on the setup
>>environment was needed?
>>
>>I deploy the application from a war file. When I delete the war file from
>>the webapps directory and leave only the previously extracted directory the
>>servlet can create the DataSource. If I leave the war file in place the
>>servlet cannot create the DataSource.
>>
>>Thanks
>>
>>-----Original Message-----
>>From: Caldarale, Charles R [mailto:[EMAIL PROTECTED]
>>Sent: Tuesday, January 16, 2007 2:00 PM
>>To: Tomcat Users List
>>Subject: RE: Cannot create JDBC driver
>>
>>
>>
>>
>>>From: Ray Madigan [mailto:[EMAIL PROTECTED]
>>>Subject: RE: Cannot create JDBC driver
>>>
>>>An interesting twist to the situation is that if I delete
>>>the war file in webapps the Exception does not occur and
>>>the application works.
>>>
>>>
>>What war file? You did not mention any in the first message.
>>
>>
>>
>>>Also, the context.xml is not copied, so I suspect it doesn't
>>>need to be.
>>>
>>>
>>The context.xml file is only copied when a .war is expanded; if you have
>>both [appname].war and an [appname] directory, things might be a bit
>>confused.
>>
>>
>>
>>>What causes the application to operate differently when the
>>>war file is present then when it isn't?
>>>
>>>
>>Sounds like you had both the .war and the expanded app under your
>>appBase directory. If they weren't identical, there may have been some
>>kind of conflict between them.
>>
>>
>>
>>><Context path="/Library" docBase="Library"
>>>
>>>
>>It's an error to specifiy the path or docBase attributes when your
>><Context> element is in META-INF/context.xml; doing so has been known to
>>result in erratic behavior in some levels of Tomcat.
>>
>>- 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 start a new topic, e-mail: [email protected]
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>---------------------------------------------------------------------
>>To start a new topic, e-mail: [email protected]
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>
>
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]