DataSources in Tomcat 4 / Windows XP

2002-03-20 Thread Martin Miranda

Hello

Im having problems creating a DataSource in a StandAlone Tomcat 4.0.1
with Windows XP. The InitialContext find the DataSource but it cames
null

This is the Code:

%
InitialContext ctxinit = new InitialContext();  
%
%= ctxinit.lookup(java:/comp/env/jdbc/testDB) %  NULL

In the web application deployment descriptor (web.xml) i have this code:

  resource-ref
descriptionResource 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-namejdbc/testDB/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
  /resource-ref

In the server.xml file:

Context path=/test docBase=test/ debug=1 privileged=true
reloadable=true useNaming=true

Resource name=jdbc/testDB auth=Container
type=javax.sql.DataSource description=Default Database for
Applications /

ResourceParams name=jdbc/testDB
parameter
namedriverClassName/name
valueoracle.jdbc.driver.OracleDriver/value
/parameter
parameter
namedriverName/name
valuejdbc:oracle:thin:@dir/value
/parameter
parameter
nameuser/name
valueusuario1/value
/parameter
parameter
namepassword/name
valuepassword1/value
/parameter
/ResourceParams  
/Context

When i use debug level 1 in the context the logs seems normal:

XmlMapper: org.apache.catalina.core.StandardContext.setSessionTimeout(
30)
XmlMapper: org.apache.catalina.core.StandardContext.addMimeMapping(
html, text/html)
XmlMapper: org.apache.catalina.core.StandardContext.addMimeMapping( txt,
text/plain)
XmlMapper: org.apache.catalina.core.StandardContext.addWelcomeFile(
index.jsp)
XmlMapper: org.apache.catalina.core.StandardContext.addWelcomeFile(
index.html)
XmlMapper: new null org.apache.catalina.deploy.ContextResource
resource-ref ContextResource[name=null, scope=Shareable]
XmlMapper: org.apache.catalina.deploy.ContextResource.setDescription(
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.)
XmlMapper: org.apache.catalina.deploy.ContextResource.setName(
jdbc/testDB)
XmlMapper: org.apache.catalina.deploy.ContextResource.setType(
javax.sql.DataSource)
XmlMapper: org.apache.catalina.deploy.ContextResource.setAuth(
Container)
XmlMapper: Calling org.apache.catalina.core.StandardContext.addResource
ContextResource[name=jdbc/testDB, 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.,
type=javax.sql.DataSource, auth=Container, scope=Shareable]
XmlMapper: pop resource-ref org.apache.catalina.deploy.ContextResource:
ContextResource[name=jdbc/testDB, 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.,
type=javax.sql.DataSource, auth=Container, scope=Shareable]

 



--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: DataSources in Tomcat 4 / Windows XP

2002-03-20 Thread Lev Assinovsky

Is Oracle driver (classes111.zip) visible to Tomcat.
I had to modify (in Linux) catalina.sh script to add driver's path to
the internal
CLASSPATH used by catalina. 

Martin Miranda wrote:
 
 Hello
 
 Im having problems creating a DataSource in a StandAlone Tomcat 4.0.1
 with Windows XP. The InitialContext find the DataSource but it cames
 null
 
 This is the Code:
 
 %
 InitialContext ctxinit = new InitialContext();
 %
 %= ctxinit.lookup(java:/comp/env/jdbc/testDB) %  NULL
 

You get EnabledDataSource instance above so you have to cast.
May it's be better like this:
% DataSource ds = (DataSource)
ctxinit.lookup(java:/comp/env/jdbc/testDB) %
%= ds %

Also all examples doing this way:
Context ctx  = new InitialContext();
Context envCtx = (Context)ctx.lookup(java:comp/env);
ds = (DataSource)envCtx.lookup(jdbc/testDB);

Try that just in case.

So your case must work!!
Though I don't advise you to use EnabledDataSource (Tyrex stuff) for
production - it doesn't provide
connection pool.
Use commons/dbcp.
I tested it - it works fine (besides Tomcat 4.0.4-b1 - nothing work
there).

 In the web application deployment descriptor (web.xml) i have this code:
 
   resource-ref
 descriptionResource 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-namejdbc/testDB/res-ref-name
 res-typejavax.sql.DataSource/res-type
 res-authContainer/res-auth
   /resource-ref
 
 In the server.xml file:
 
 Context path=/test docBase=test/ debug=1 privileged=true
 reloadable=true useNaming=true
 
 Resource name=jdbc/testDB auth=Container
 type=javax.sql.DataSource description=Default Database for
 Applications /
 
 ResourceParams name=jdbc/testDB
 parameter
 namedriverClassName/name
 valueoracle.jdbc.driver.OracleDriver/value
 /parameter
 parameter
 namedriverName/name
 valuejdbc:oracle:thin:@dir/value
 /parameter
 parameter
 nameuser/name
 valueusuario1/value
 /parameter
 parameter
 namepassword/name
 valuepassword1/value
 /parameter
 /ResourceParams
 /Context
 
 When i use debug level 1 in the context the logs seems normal:
 
 XmlMapper: org.apache.catalina.core.StandardContext.setSessionTimeout(
 30)
 XmlMapper: org.apache.catalina.core.StandardContext.addMimeMapping(
 html, text/html)
 XmlMapper: org.apache.catalina.core.StandardContext.addMimeMapping( txt,
 text/plain)
 XmlMapper: org.apache.catalina.core.StandardContext.addWelcomeFile(
 index.jsp)
 XmlMapper: org.apache.catalina.core.StandardContext.addWelcomeFile(
 index.html)
 XmlMapper: new null org.apache.catalina.deploy.ContextResource
 resource-ref ContextResource[name=null, scope=Shareable]
 XmlMapper: org.apache.catalina.deploy.ContextResource.setDescription(
 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.)
 XmlMapper: org.apache.catalina.deploy.ContextResource.setName(
 jdbc/testDB)
 XmlMapper: org.apache.catalina.deploy.ContextResource.setType(
 javax.sql.DataSource)
 XmlMapper: org.apache.catalina.deploy.ContextResource.setAuth(
 Container)
 XmlMapper: Calling org.apache.catalina.core.StandardContext.addResource
 ContextResource[name=jdbc/testDB, 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.,
 type=javax.sql.DataSource, auth=Container, scope=Shareable]
 XmlMapper: pop resource-ref org.apache.catalina.deploy.ContextResource:
 ContextResource[name=jdbc/testDB, 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.,
 type=javax.sql.DataSource, auth=Container, scope=Shareable]
 
 
 
 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]

-- 
Lev AssinovskyPeterlink Web
ProgrammerSt. Petersburg, Russia
Tel/Fax: +7 812 3275343   197022 ul.Chapigina 7Á
E-mail: [EMAIL PROTECTED]

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]