Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1005
  • Last Modified:

ubutuntu tomcat db connection pool

I have a struts 2, hibernate, spring, tomcat 5, Mysql test application. After I deploy it in Linxu unbuntu, I got following waring in the catalina.log file:

WARNING: Failed to register in JMX: javax.naming.NamingException: Could not load
 resource factory class [Root exception is java.lang.ClassNotFoundException: org
.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory]

Tomcat is installed by apt-get install tomcat...
I have put mysql-connector-java-3.1.10-bin, commons-dbcp-1.2.2.jar  into /usr/share/tomcat5.5/common/lib/. I also change access right two both jars as 777 (Wow, it is too much!).

Though tomcat is installed /var/lib/tomcat5.5.

Why do I get warning message since I have put jars in the lib directory? Isn't tomcat will automatically load all jars in usr/share/tomcat5.5/common/lib/ directory?
0
JianJunShen
Asked:
JianJunShen
  • 17
  • 15
  • 11
  • +2
10 Solutions
 
CEHJCommented:
>>usr/share/tomcat5.5/common/lib/

Shouldn't that be

usr/share/tomcat5.5/lib/  ?
0
 
CEHJCommented:
No - i think that should be OK. Make sure that class is actually in the dbcp jar
0
 
objectsCommented:
try putting dbcp it in WEB_INF/lib

0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
objectsCommented:
>  I also change access right two both jars as 777

stop doing that ;)

0
 
CEHJCommented:
You need to get it working in a common lib. There's no point in filling up your HD by copying dbcp into every webapp
0
 
ai_ja_naiCommented:
put dbcp.jar into /usr/share/tomcat-5/lib
http://bugs.gentoo.org/show_bug.cgi?id=144276
0
 
JianJunShenAuthor Commented:
there is no /usr/share/tomcat-5/lib directory. Do I need to create it?
0
 
ai_ja_naiCommented:
/common/lib/ failed. try. even if it's weird, since the installation should have created the right dirs for it to search for libs
0
 
JianJunShenAuthor Commented:
I got same error.

Feb 10, 2009 12:53:08 PM org.apache.catalina.core.NamingContextListener addResou
rce
WARNING: Failed to register in JMX: javax.naming.NamingException: Could not load
 resource factory class [Root exception is java.lang.ClassNotFoundException: org
.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory]

As you see, I have put dbcp jar into lib. Does that enough?
:/usr/share/tomcat5.5/lib$ ls -al
total 548
drwxr-xr-x 2 juhanishen juhanishen   4096 2009-02-10 12:51 .
drwxrwxrwx 6 root       root         4096 2009-02-10 12:47 ..
-rwxrwxrwx 1 root       root       121757 2009-02-10 12:51 commons-dbcp-1.2.2.jar
-rwxrwxrwx 1 root       root       418698 2009-02-10 12:51 mysql-connector-java-3.1.10-bin.jar
0
 
objectsCommented:
your mysql driver should be in common/lib
and try dbcp in <webapp>/WEB-INF/lib

0
 
JianJunShenAuthor Commented:
Those two jars are located both in <webapp>/WEB-INF/lib and /usr/share/tomcat5.5/lib/.
0
 
objectsCommented:
just have them in each in one place
0
 
objectsCommented:
actually it (dbcp) should have already been in place. So put it back in common/lib
And put mysql driver also in common/lib
and put back anything else you have moved :)

0
 
JianJunShenAuthor Commented:
same error:

Feb 10, 2009 1:13:29 PM org.apache.catalina.core.NamingContextListener addResource
WARNING: Failed to register in JMX: javax.naming.NamingException: Could not load res
ource factory class [Root exception is java.lang.ClassNotFoundException: org.apache.
tomcat.dbcp.dbcp.BasicDataSourceFactory]


0
 
objectsCommented:
> .apache.tomcat.dbcp.dbcp.BasicDataSourceFactory]

try changing your context to use:

.apache.tomcat.dbcp.BasicDataSourceFactory
0
 
CEHJCommented:
Please post result of
jar tf /usr/share/tomcat5.5/common/lib/commons-dbcp-1.2.2.jar | grep BasicDataSourceFactory

Open in new window

0
 
JianJunShenAuthor Commented:
Same error:

Feb 10, 2009 1:44:56 PM org.apache.catalina.core.NamingContextListener addResource
WARNING: Failed to register in JMX: javax.naming.NamingException: Could not load resource factory class [Root exception is java.lang.ClassNotFoundException:
org.apache.tomcat.dbcp.BasicDataSourceFactory]

Does this matter:I notice following two jars in /usr/share/tomcat5.5/common/lib has no executable rights.

-rw-r--r-- 1 root root  36774 2008-10-20 18:02 naming-factory.jar
-rw-r--r-- 1 root root  47692 2008-10-20 18:02 naming-resources.jar
0
 
CEHJCommented:
>>Does this matter:I notice following two jars in /usr/share/tomcat5.5/common/lib has no executable rights.

No

What was the result of the command i posted?
0
 
objectsCommented:
try:

org.apache.commons.dbcp.BasicDataSourceFactory

0
 
JianJunShenAuthor Commented:
CEHJ:

It is org/apache/commons/dbcp/BasicDataSourceFactory.class

0
 
JianJunShenAuthor Commented:
Objects:

Same error:

Feb 10, 2009 2:10:40 PM org.apache.catalina.core.NamingContextListener addResource
WARNING: Failed to register in JMX: javax.naming.NamingException: Could not load resource factory clas
s [Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.BasicDataSourceFactory]

I am afraid this is tomcat ubuntu bug.
0
 
CEHJCommented:
There still could be something wrong with perms though. Could you post the result of the following please?
ls -l /usr/share/tomcat5.5/common

Open in new window

0
 
objectsCommented:
don't think so we use tomcat + ubuntu with many clients

0
 
JianJunShenAuthor Commented:
CEHJ:

Here comes the log:

/usr/share/tomcat5.5/logs$ ls -l /usr/share/tomcat5.5/common/
total 16
drwxr-xr-x 2 root root 4096 2008-10-20 18:02 classes
drwxr-xr-x 2 root root 4096 2008-10-20 18:02 endorsed
drwxr-xr-x 2 root root 4096 2009-02-07 01:04 i18n
drwxr-xr-x 2 root root 4096 2009-02-10 14:04 lib
0
 
CEHJCommented:
Hmm. If those are all owned by root, i suspect that other parts of the tree are too. If you're not running as root (not a good idea to run as root), that could cause problems down the line, though i'm not sure how it could cause the classloading problem you have currently.
0
 
JianJunShenAuthor Commented:
How to run as a root?
0
 
JianJunShenAuthor Commented:
When I install tomcat5.5, I am using command
sudo apt-get install tomcat5.5

What's the other way around? Now How could I uninstall tomcat5.5 and use command:
apt-get install tomcat5.5 to install tomcat5.5 or simply download tomcat5.5 package by myself?

0
 
CEHJCommented:
You need to see how your system starts up Tomcat and set the user to root. You could try first by starting Tomcat as root, but it might still run as another user - see if it does
0
 
CEHJCommented:
You can't install software as anyone other than root. Anyway on your system, the Tomcat tree is not owned by root - you've changed it.

You could uninstall and start again
0
 
JianJunShenAuthor Commented:
I use sudo /etc/init.d/tomcat5.5 start to start tomcat. I donot know how to set the user as root. Could you please guide me? I am new to Linux.

0
 
CEHJCommented:
Personally i would reinstall it - the tree has been too disturbed
0
 
JianJunShenAuthor Commented:
Are there straightforward way to uninstall it? In windows, there is Add/Remove program.
0
 
CEHJCommented:
sudo apt-get remove tomcat
0
 
JianJunShenAuthor Commented:
I used command sudo apt-get remove tomcat5.5, initially it does not remove all directory, for example, /etc/tomcat5.5, /etc/init.d/tomcat5.5, I manually delete them. Then I installed tomcat again by command sudo apt-get install tomcat5.5, now there is no tomcat5.5 under /etc/init.d/directory. There is no common directory under /usr/share/tomcat5.5/ directory. What happens?
0
 
CEHJCommented:
Try it again with


sudo apt-get remove --purge tomcat5.5

Open in new window

0
 
JianJunShenAuthor Commented:
I reinstalled tomcat5.5, and I am now could start tomcat from /usr/share/tomcat5.5/bin.
Just by call ./startup.sh.
The log is as follows:

:/usr/share/tomcat5.5/bin$ ./startup.sh
classpath is :/usr/share/tomcat5.5/bin/bootstrap.jar:/usr/share/tomcat5.5/bin/commons-logging-api.jar:/usr/share/tomcat5.5/common/lib/commons-dbcp.jar:/usr/share/tomcat5.5/common/lib/mysql-connector-java-3.1.10-bin.jar
Using CATALINA_BASE:   /usr/share/tomcat5.5
Using CATALINA_HOME:   /usr/share/tomcat5.5
Using CATALINA_TMPDIR: /usr/share/tomcat5.5/temp
Using JRE_HOME:       /usr/lib/jvm/java-6-openjdk

Same warning info:
Feb 10, 2009 11:49:04 PM org.apache.catalina.core.NamingContextListener addResource
WARNING: Failed to register in JMX: javax.naming.NamingException: Could not load resource factory class [Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory]

I also tried org.apache.tomcat.dbcp.BasicDataSourceFactory. it has similar warning message.

0
 
objectsCommented:
> How to run as a root?

do *not* run tomcat as root
0
 
objectsCommented:
> I used command sudo apt-get remove tomcat5.5

there is no need to remove a package


could you try removing the factory name from your context definition and let me know how it goes

0
 
objectsCommented:
and check the config of all your listeners to make sure they are starting up ok

0
 
vahanaCommented:
Morning , I think , org.apache.tomcat.dbcp.BasicDataSourceFactory is not in  mysql-connector-java-3.1.10-bin or commons-dbcp-1.2.2.jar libs,  it is specific tomcat resource factory and u need see it in tomcat default env.
I'd strongly suggest you remove that one and use a real Tomcat download:
http://tomcat.apache.org/download-55.cgi
http://tomcat.apache.org/download-60.cgi
0
 
CEHJCommented:
>>it is specific tomcat resource factory

Doh! I didn't notice that in my request for a Java listing before!
0
 
JianJunShenAuthor Commented:
Yes. Objects has the same idea as vahana. And I tested it works now. Thanks a lot for all of your contribution.
0
 
JianJunShenAuthor Commented:
The problem is only 500 points. I wish I could give you 5000 points. Wow!
0
 
CEHJCommented:
:-)
0
 
CEHJCommented:
JianJunShen, this suggests the package could be broken. What exactly did you do to fix it - did you download Tomcat from elsewhere?
0
 
JianJunShenAuthor Commented:
CEHJ:

There is one point that package is broken. Objects help me fixed it. It is spring xml, bean definition. You are right!!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 17
  • 15
  • 11
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now