Hi David,
On Tue, 31 Oct 2006, David Smith wrote:
A couple of thoughts:
1. There should only be one mysql driver .jar file and it should be in
common/lib. Please remove the one in your WEB-INF/lib directory
2. The driver org.gjt.mm.mysql.Driver is depricated (has been for a VERY long
time). Update it to com.mysql.jdbc.Driver.
OK thanks.
3. You might want to consider obscuring your database password when posting
to the list.
Somewhere between composing the e-mail and sending I forgot the
obfuscation step.
mike
Not sure about the bean factories or the value resources as I don't work with
them.
--David
Mike Jackson wrote:
Hi folks,
I have been trying to get to grips with JNDI but cannot get data sources or
bean factories - using the standard examples in the Tomcat user doc - but
cannot get hardly anything to work.
I have the following declared in TOMCAT/webapps/axis/WEB-INF/web.xml after
the <session-mapping/> element and before the <mime-mapping/> element.
<resource-ref>
<description>Data Source Example</description>
<res-ref-name>jdbc/mikeDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-env-ref>
<resource-env-ref-name>simpleValue</resource-env-ref-name>
<resource-env-ref-type>java.lang.Integer</resource-env-ref-type>
</resource-env-ref>
<resource-env-ref>
<resource-env-ref-name>value/someValue</resource-env-ref-name>
<resource-env-ref-type>java.lang.String</resource-env-ref-type>
</resource-env-ref>
<env-entry>
<env-entry-name>value/someDirectValue</env-entry-name>
<env-entry-value>10</env-entry-value>
<env-entry-type>java.lang.Integer</env-entry-type>
</env-entry>
<resource-env-ref>
<description>Object factory for MyBean instances</description>
<resource-env-ref-name>bean/MyBeanFactory</resource-env-ref-name>
<resource-env-ref-type>com.mycompany.MyBean</resource-env-ref-type>
</resource-env-ref>
In TOMCAT/conf/server.xml there is...
<Server...>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
I have the following TOMCAT/webapps/axis/META-INF/context.xml file:
<Context debug="0" docBase="/home/michaelj/test/tomcatAxis/webapps/axis"
reloadable="true">
<Resource name="jdbc/mikeDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/mikeDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>username</name>
<value>daitester</value>
</parameter>
<parameter>
<name>password</name>
<value>It35tda1</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://coal.epcc.ed.ac.uk:3306/daitest</value>
</parameter>
</ResourceParams>
<Environment name="value/someValue"
value="10"
type="java.lang.String"
override="true"/>
<ResourceLink name="simpleValue"
global="simpleValue"
type="java.lang.Integer"/>
<Resource name="bean/MyBeanFactory" auth="Container"
type="com.mycompany.MyBean"/>
<ResourceParams name="bean/MyBeanFactory">
<parameter>
<name>factory</name>
<value>org.apache.naming.factory.BeanFactory</value>
</parameter>
<parameter>
<name>bar</name>
<value>23</value>
</parameter>
</ResourceParams>
</Context>
I have my database driver in both TOMCAT/common/lib and
TOMCAT/webapps/axis/WEB-INF/lib and my example bean in
TOMCAT/common/classes and TOMCAT/webapps/axis/WEB-INF/classes.
Now when I run the following within a web service
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
the context is accessed fine. But when I then do ctx.lookup() for each
of my declared resources:
jdbc/mikeDB
bean/MyBeanFactory
value/someValue
value/someDirectValue
simpleValue
Then I get the following
-For jdbc/mikeDB I get
object [EMAIL PROTECTED] as expected.
-However running getConnection() on this throws
"Cannot create JDBC driver of class '' for connect URL 'null'"
-For bean/MyBeanFactory
value/someValue
simpleValue
I get:
Cannot create resource instance
-The only one that works is value/someDirectValue for which
I get "10" as expected.
Can anyone offer any clue as to why this is going wrong? Is there some
piece of configuration I'm missing or have done wrong? Most of these
examples were cut and paste from the user doc so I'm suprised that
virtually nothing is returned from lookup() sucessfully.
Thanks,
mike
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-------------------------------------------------------------------
Dr. Michael (Mike) Jackson E-mail: [EMAIL PROTECTED]
EPCC Tel: +(44)-0131-650-5141
WWW: http://www.epcc.ed.ac.uk Fax: +(44)-0131-650-6555
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]