Hi,

I'm kind of new to TomEE & App servers in general.  I Apologize in advance
if I use some incorrect terminology.

I have set up a web application that connects to a database.
To connect to the database, I'm defining a resource in a context.xml file.
I'm not modifying server.xml.
I'm using the PSI-probe to manage/monitor things.

My problem is that I keep getting duplicate database connection pools.  Or,
I think that I'm getting duplicate pools.
The probe app seems to list 3 Application Resources. but I think that 2 of
them might be linked  I can see some logging around the linking. (I see
lines with "Auto-linking resource-ref" in the log file)

To tried to divide & conquor, I think that narrowed it down to my
context.xml.  I created a hello world web app, that has 2 files.  One file
extends javax.ws.rs.core.Application, and the other file has a single
jax.ws.rs resource with a single hello world method in it.  So, the app
doesn't use the database.  it just has 1 method with a one line "hello
world" method.

Then I created a context file, that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/foobar"
  jtaManaged="true"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
            url="jdbc:oracle:thin:@HHHHHHHH:1521:ORCL"
            username="XXXXXXXXX"
            password="ZZZZZZZZZZZ"
            maxTotal="10"
            maxIdle="5"
            minIdle="0"
            initialSize="2"
            maxWaitMillis="1"
            />
</Context>
and put it in META-INF

I grabbed a clean download of apache-tomee-7.0.3-plus, so that the config
files are all at their default.
I added by helloworld.jar.  I added the probe.war, for management.  I added
ojdbc8.jar to the libs directory.
I modified tomcat-users.xml so that I could log into the manager & the
probe app.

When Tomee is not running, and I look at my database, there are no session
from my development machine.  When I start the app, there are 4
connections.  (initial size is 2, I have 4 connections, so I think that I
have 2 dbcp pools).

If I increase my initialSize to 3 & restart the app, then I can see in the
database that I have 6 sessions.  (It is an oracle database, so I can see
the connections with the command "select count(*) from v$session where
machine = 'developmentmachine';")

When I look in the probe, I can see 3 application resources:

APP              RESOURCE                                 USAGE   M   E   B
  USER      URL                                  DESCRIPTION   TYPE
 LNK   AUTH
/helloWorld openejb/Resource/jdbc/foobar                     10  2   0
XXXXXXXXX jdbc:oracle:thin:@HHHHHHHH:1521:ORCL               tomcat-dbcp2
     CONTAINER
/helloWorld jdbc/foobar                                      10  2   0
XXXXXXXXX jdbc:oracle:thin:@HHHHHHHH:1521:ORCL               tomcat-dbcp2
     Container
/helloWorld openejb/Resource/helloWorld/jdbc/foobar          10  2   0
XXXXXXXXX jdbc:oracle:thin:@HHHHHHHH:1521:ORCL               tomcat-dbcp2
     CONTAINER

the "E" column is "the number of established connections that can be
reused".  so, it's reporting 6 (2 for each resource) but I think that I
have 4, since that's what the database tells me.  The AUTH column isn't
exactly the same, 2 are "CONTAINER" and 1 is "Container".  so maybe that's
a clue to the linking?

So - I'm hoping that since this is such a minimal config, someone can tell
me what I'm doing wrong.  Do I really have 2 different dbcp pools?  or do I
have 1 or 3?  Why is the number of session in the database always double
the initialSize number, even though my app is never using the database.

I'll attach the snippet of the log file.  The logging is all at the
defaults, since I just grabbed this install.  I can repeat it with
additional logging if that would help.

Thanks!

Doug


catalina.log.txt (14K) 
<http://tomee-openejb.979440.n4.nabble.com/attachment/4682413/0/catalina.log.txt>




--
View this message in context: 
http://tomee-openejb.979440.n4.nabble.com/datasource-duplication-in-tomee-tp4682413.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Reply via email to