Re: DataBase connection pooling.

2002-12-16 Thread Mauro Brändle
I use the connection pool  that comes with Tomcat 4.1.12 to connect my servlets
to an IBM DB2 7.1 database and apart an initial problem in configuring Tomcat all
works fine.
Greetings
Mauro Brändle

Andoni wrote:

 Hello,

 Do you all write your own connection pooling code or is there some open
 source software to do this?

 Also has anybody gotten deployment of .war files to work with
 unpackWARs=false?

 Thanks,

 Andoni.

 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Get the IP-Adress in a servlet

2002-12-05 Thread Mauro Brändle
Try to check in the Tomcat Documentation - Servlet/JSP Javadocs - javax.servlet
and javax.servlet.http packages.
For class javax.servlet.ServletRequest there's the getServerPort() method that
returns the port number on which the request was received.
I don't know how to get the server IP address, but you can get the server name
with the getServerName() method.

Hope this helps.
Greetings

Mauro

Patrick Kosiol wrote:

 Hi,

 How do I get the IP - Adress (and port) from my Tomcat-Server in a servlet?

 thx4ur help

 Patrick

 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Problems with Apache 2.0.43 and Tomcat4 on Linux7.3

2002-11-25 Thread Mauro Brändle
Hello everybody,
 i'm new to these topics and i'm in deep trouble trying to integrate
Apache 2.0.43 an Tomcat4. I have done as follows:
- downloaded from the Apache site the mod_jk-2_0_42.so;
- have added the following line in my server.xml file:
Listener className=org.apache.ajp.tomcat4.config.ApacheConfig
modJk=/usr/local/apache2/modules/mod_jk-2_0_42.so
workersConfig=/var/tomcat4/conf/jk/workers.properties jkDebug=info
jkLog=/var/tomcat4/logs/mod_jk.log/
and after the host name=localhost... tags
Listener className=org.apache.ajp.tomcat4.config.ApacheConfig
append=true /
- in ($TOMCAT_HOME)/conf/jk i put a workers.properties file with this
content:

workers.tomcat_home=/var/tomcat4
workers.java_home=$(JAVA_HOME)
ps=\

- restarting Tomcat it creates a new directory :
($TOMCAT_HOME)/conf/auto containing a new file: mod_jk.conf with the
following lines:
IfModule !mod_jk.c
  LoadModule jk_module /usr/local/apache2/modules/mod_jk-2_0_42.so
/IfModule

JkWorkersFile /var/tomcat4/conf/jk/workers.properties
JkLogFile /var/tomcat4/logs/mod_jk.log

JkLogLevel info

VirtualHost localhost
ServerName localhost

JkMount /webdav ajp13
JkMount /webdav/* ajp13

JkMount /admin ajp13
JkMount /admin/* ajp13

JkMount /tomcat-docs ajp13
JkMount /tomcat-docs/* ajp13

JkMount /examples ajp13
JkMount /examples/* ajp13

JkMount /manager ajp13
JkMount /manager/* ajp13

JkMount /CDS ajp13
JkMount /CDS/* ajp13

JkMount /liste ajp13
JkMount /liste/* ajp13

JkMount /liste-1 ajp13
JkMount /liste-1/* ajp13
/VirtualHost

- i copied the lines of this file in the httpd.conf  file after the last
LoadModule line
- i restarted the apache web server and i get the following messages in
the Apache's error_log :
[Mon Nov 25 16:34:33 2002] [notice] caught SIGTERM, shutting down
[Mon Nov 25 16:37:33 2002] [notice] Apache/2.0.43 (Unix)
mod_jk/1.2.0 configured -- resuming normal operations
[Mon Nov 25 16:49:50 2002] [notice] caught SIGTERM, shutting down
[Mon Nov 25 16:50:29 2002] [notice] Apache/2.0.43 (Unix)
mod_jk/1.2.0 configured -- resuming normal operations
[Mon Nov 25 16:51:15 2002] [notice] caught SIGTERM, shutting down
[Mon Nov 25 16:52:40 2002] [notice] Apache/2.0.43 (Unix)
mod_jk/1.2.0 configured -- resuming normal operations
- i also have a file workers2.properties(in the same directory as
mod_jk-2_0_42.so) like this:
[shm]
file=${serverRoot}/logs/shm.file
size=1048576
# Example socket channel, override port and host.
[channel.socket:localhost:8009]
port=8009
host=127.0.0.1
# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
# Uri mapping
[uri:/examples/*]
worker=ajp13:localhost:8009

Is the approach correct or not?
Is there anything right in what i did?  :-)
 I hope that someone will help me, i'm getting mad

Thanks in advance!
Greetings.

Mauro Brandle







--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Connection pooling with Tomcat4 and IBM DB2 7.1

2002-11-19 Thread Mauro Brändle
Thank you very much! Now it works all fine!
Greetings

Mauro Brändle

Kwok Peng Tuck wrote:

 I think the type should be javax.sql.DataSource rather than what you put
 in there.
 And add the dbcp factory name plus value as per docs in 4.1.12

 parameter
 namefactory/name
  valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
 /parameter

 This will use the dbcp connection pool.
 Your web.xml looks about ok as far as the resource-ref is concerned..

 Mauro Brändle wrote:

 Between the tags  Context of my server.xml file (in the proper context of my
 web application) i have:
 
 Resource scope=Shareable type=javax.sql.ConnectionPoolDataSource
 name=jdbc/DBname auth=Container/
   ResourceParams name=jdbc/DBname
 parameter
   namepassword/name
   valuepassword/value
 /parameter
 parameter
   namemaxWait/name
   value5000/value
 /parameter
 parameter
   namemaxIdle/name
   value2/value
 /parameter
 parameter
   namemaxActive/name
   value4/value
 /parameter
 parameter
   nameurl/name
   valuejdbc:db2://db2cpy.bettinelli.it:6789/bettdev/value
 /parameter
 parameter
   namedriverClassName/name
   valueCOM.ibm.db2.jdbc.net.DB2Driver/value
 /parameter
 parameter
   nameusername/name
   valueuser/value
 /parameter
   /ResourceParams
 
 And here is my web.xml file:
 
 !DOCTYPE web-app
 PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
 http://java.sun.com/dtd/web-app_2_3.dtd;
 
 web-app
 
 display-nameProva liste assemblaggio/display-name
 description
  PROVA LASS.
 /description
 
  context-param
   param-nameauthor/param-name
   param-value[EMAIL PROTECTED]/param-value
   description
   MBR
/description
  /context-param
 
 !-- Define example application events listeners --
 listener
 listener-classlisteners.ContextListener/listener-class
 /listener
 listener
 listener-classlisteners.SessionListener/listener-class
 /listener
 
 servlet
 servlet-namelass1/servlet-name
 servlet-classlisteass.lass1/servlet-class
 /servlet
 
  servlet
 servlet-namelass2/servlet-name
 servlet-classlisteass.lass2/servlet-class
 /servlet
 
  servlet
 servlet-nameriepil1/servlet-name
 servlet-classlisteass.riepil1/servlet-class
 /servlet
 
  servlet
 servlet-namemenuAss/servlet-name
 servlet-classlisteass.menuAss/servlet-class
 /servlet
 
servlet-mapping
 servlet-namelass1/servlet-name
 url-pattern/liste/servlet/listeass/url-pattern
 /servlet-mapping
 
 servlet-mapping
 servlet-nameinvoker/servlet-name
 url-pattern/servlet/*/url-pattern
 /servlet-mapping
 
 servlet-mapping
 servlet-namelass2/servlet-name
 url-pattern/listeass/url-pattern
 /servlet-mapping
 
 servlet-mapping
 servlet-nameriepil1/servlet-name
 url-pattern/listeass/url-pattern
 /servlet-mapping
 
servlet-mapping
 servlet-namemenuAss/servlet-name
 url-pattern/listeass/url-pattern
 /servlet-mapping
 
 session-config
   session-timeout60/session-timeout
  /session-config
 
 taglib
 taglib-uri
 http://jakarta.apache.org/tomcat/debug-taglib
 /taglib-uri
 taglib-location
/WEB-INF/jsp/debug-taglib.tld
 /taglib-location
 /taglib
 taglib
  taglib-uri
 http://jakarta.apache.org/tomcat/examples-taglib
 /taglib-uri
 taglib-location
/WEB-INF/jsp/example-taglib.tld
 /taglib-location
 /taglib
 
  resource-ref
   descriptionjdbc/DBname/description
   res-ref-namejdbc/DBname/res-ref-name
   res-typejavax.sql.DataSource/res-type
   res-authContainer/res-auth
  /resource-ref
 /web-app
 
 Thanks.
 Mauro Brändle
 
 
 Kwok Peng Tuck wrote:
 
 
 
 Can you post a sample of your jndi resource declaration plus your web.xml ?
 Looks like it is looking up a nonexistant name.
 
 Mauro Brändle wrote:
 
 
 
 Hello everybody,
I'm asking if anyone has ever used connection pooling to access a
 DB2 database with Tomcat4, since I only have found examples for MySQL
 and Oracle database.
I'm trying to use a connection pool to access a DB2 7.1 database.
 I'm almost sure to have  properly configured Tomcat 4, but still i have
 problems when i perform the context lookup to get the database resource.
 The code is:
 
  javax.naming.InitialContext ctx = new javax.naming.InitialContext();
  javax.naming.Context envCtx = (javax.naming.Context)
 ctx.lookup(java:comp/env);
  javax.sql.DataSource ds = (javax.sql.DataSource)
 envCtx.lookup(jdbc/DBname);
  java.sql.Connection conn = ds.getConnection(user

Connection pooling with Tomcat4 and IBM DB2 7.1

2002-11-18 Thread Mauro Brändle
Hello everybody,
I'm asking if anyone has ever used connection pooling to access a
DB2 database with Tomcat4, since I only have found examples for MySQL
and Oracle database.
I'm trying to use a connection pool to access a DB2 7.1 database.
I'm almost sure to have  properly configured Tomcat 4, but still i have
problems when i perform the context lookup to get the database resource.
The code is:

  javax.naming.InitialContext ctx = new javax.naming.InitialContext();
  javax.naming.Context envCtx = (javax.naming.Context)
ctx.lookup(java:comp/env);
  javax.sql.DataSource ds = (javax.sql.DataSource)
envCtx.lookup(jdbc/DBname);
  java.sql.Connection conn = ds.getConnection(user, password);

   When I perform   javax.sql.DataSource ds = (javax.sql.DataSource)
envCtx.lookup(jdbc/DBname);   I get the following error:

javax.naming.NamingException: Cannot create resource instance
 at org.apache.naming.factory.ResourceFactory.getObjectInstance(Unknown
Source)
 at
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:310)

 at org.apache.naming.NamingContext.lookup(Unknown Source)
 at org.apache.naming.NamingContext.lookup(Unknown Source)
 at org.apache.naming.NamingContext.lookup(Unknown Source) ...

I hope you could please help me with this problem.
Thank you very much!

Mauro Brändle



Re: Connection pooling with Tomcat4 and IBM DB2 7.1

2002-11-18 Thread Mauro Brändle
Between the tags  Context of my server.xml file (in the proper context of my
web application) i have:

Resource scope=Shareable type=javax.sql.ConnectionPoolDataSource
name=jdbc/DBname auth=Container/
  ResourceParams name=jdbc/DBname
parameter
  namepassword/name
  valuepassword/value
/parameter
parameter
  namemaxWait/name
  value5000/value
/parameter
parameter
  namemaxIdle/name
  value2/value
/parameter
parameter
  namemaxActive/name
  value4/value
/parameter
parameter
  nameurl/name
  valuejdbc:db2://db2cpy.bettinelli.it:6789/bettdev/value
/parameter
parameter
  namedriverClassName/name
  valueCOM.ibm.db2.jdbc.net.DB2Driver/value
/parameter
parameter
  nameusername/name
  valueuser/value
/parameter
  /ResourceParams

And here is my web.xml file:

!DOCTYPE web-app
PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
http://java.sun.com/dtd/web-app_2_3.dtd;

web-app

display-nameProva liste assemblaggio/display-name
description
 PROVA LASS.
/description

 context-param
  param-nameauthor/param-name
  param-value[EMAIL PROTECTED]/param-value
  description
  MBR
   /description
 /context-param

!-- Define example application events listeners --
listener
listener-classlisteners.ContextListener/listener-class
/listener
listener
listener-classlisteners.SessionListener/listener-class
/listener

servlet
servlet-namelass1/servlet-name
servlet-classlisteass.lass1/servlet-class
/servlet

 servlet
servlet-namelass2/servlet-name
servlet-classlisteass.lass2/servlet-class
/servlet

 servlet
servlet-nameriepil1/servlet-name
servlet-classlisteass.riepil1/servlet-class
/servlet

 servlet
servlet-namemenuAss/servlet-name
servlet-classlisteass.menuAss/servlet-class
/servlet

   servlet-mapping
servlet-namelass1/servlet-name
url-pattern/liste/servlet/listeass/url-pattern
/servlet-mapping

servlet-mapping
servlet-nameinvoker/servlet-name
url-pattern/servlet/*/url-pattern
/servlet-mapping

servlet-mapping
servlet-namelass2/servlet-name
url-pattern/listeass/url-pattern
/servlet-mapping

servlet-mapping
servlet-nameriepil1/servlet-name
url-pattern/listeass/url-pattern
/servlet-mapping

   servlet-mapping
servlet-namemenuAss/servlet-name
url-pattern/listeass/url-pattern
/servlet-mapping

session-config
  session-timeout60/session-timeout
 /session-config

taglib
taglib-uri
http://jakarta.apache.org/tomcat/debug-taglib
/taglib-uri
taglib-location
   /WEB-INF/jsp/debug-taglib.tld
/taglib-location
/taglib
taglib
 taglib-uri
http://jakarta.apache.org/tomcat/examples-taglib
/taglib-uri
taglib-location
   /WEB-INF/jsp/example-taglib.tld
/taglib-location
/taglib

 resource-ref
  descriptionjdbc/DBname/description
  res-ref-namejdbc/DBname/res-ref-name
  res-typejavax.sql.DataSource/res-type
  res-authContainer/res-auth
 /resource-ref
/web-app

Thanks.
Mauro Brändle


Kwok Peng Tuck wrote:

 Can you post a sample of your jndi resource declaration plus your web.xml ?
 Looks like it is looking up a nonexistant name.

 Mauro Brändle wrote:

 Hello everybody,
 I'm asking if anyone has ever used connection pooling to access a
 DB2 database with Tomcat4, since I only have found examples for MySQL
 and Oracle database.
 I'm trying to use a connection pool to access a DB2 7.1 database.
 I'm almost sure to have  properly configured Tomcat 4, but still i have
 problems when i perform the context lookup to get the database resource.
 The code is:
 
   javax.naming.InitialContext ctx = new javax.naming.InitialContext();
   javax.naming.Context envCtx = (javax.naming.Context)
 ctx.lookup(java:comp/env);
   javax.sql.DataSource ds = (javax.sql.DataSource)
 envCtx.lookup(jdbc/DBname);
   java.sql.Connection conn = ds.getConnection(user, password);
 
When I perform   javax.sql.DataSource ds = (javax.sql.DataSource)
 envCtx.lookup(jdbc/DBname);   I get the following error:
 
 javax.naming.NamingException: Cannot create resource instance
  at org.apache.naming.factory.ResourceFactory.getObjectInstance(Unknown
 Source)
  at
 javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:310)
 
  at org.apache.naming.NamingContext.lookup(Unknown Source)
  at org.apache.naming.NamingContext.lookup(Unknown Source)
  at org.apache.naming.NamingContext.lookup(Unknown Source) ...
 
 I hope you could please help me with this problem.
 Thank you very much