-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: C3p0 null pointer exception
PostPosted: Thu Mar 15, 2007 10:05 am 
Newbie

Joined: Wed Mar 14, 2007 3:36 pm
Posts: 2
Hello,
My name is Lourival and I am getting the following error
when I try to start up the Tomcat webserver:

org.hibernate.HibernateException: Could not instantiate C3P0 connection pool
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:163)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:410)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at br.atech.cos.server.persistencia.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:38)
at br.atech.cos.server.startup.CosStartupServlet.<clinit>(CosStartupServlet.java:31)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1055)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3917)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4201)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:809)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:698)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at com.mchange.v2.c3p0.DataSources.pooledDataSource(DataSources.java:314)
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:159)
... 40 more

The c3p0 is configured as showed below:

<!-- Configuração do c3p0 -->
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">10</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.c3p0.acquire_increment">2</property>

I am using apache-activemq-4.1.0-incubator, apache-tomcat-5.5.17 and hibernate-3.2.2.ga.

I tracked this problem and what I figured out is that The ActiveMq adds a
org.apache.activeio.journal.active.lockMap property with null value in the
java list properties. The Hibernate reads the properties values about Cp30
defined in the configuration file and adds to the java list properties
after that hibernate calls the Cp30 routines passing the properties list. The
Cp30 is not prepared to receive properties that are not in its properties list
neither read null property values so the exception pops up (see the
Caused by clause at the bottom of the exception inserted at
the top of this document).

I'm not so sure If I´ve got a bug or I am doing something wrong.

Could you please help me?

Thanks in advance,
Lourival Silva


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 25, 2007 7:05 am 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
Lourival,

Sorry for the delayed response.

c3p0 would have a problem if passed a Properties object that included a null value. The code could easily be modified to defend against this. But I don't understand, I thought Properties objects and Hashtables are unable to accept null values. How did the upstream code manage to create a situation where an iterable key is associated with a null value in a Properties object?

Thanks for your help. I'm afraid I must be missing something basic.

smiles,
Steve


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 3:17 pm 
Newbie

Joined: Wed Mar 14, 2007 3:36 pm
Posts: 2
Hi Steve,

I agree with you 100%.

I going to keep diggin up this problem more carefully.
If I find out new evidences or a solution to this problem
I'll let you know.

Thank you very much for your help.
Lourival


Top
 Profile  
 
 Post subject: Fix for c3p0 + hibernate
PostPosted: Fri Jun 13, 2008 1:02 pm 
Newbie

Joined: Fri Jun 13, 2008 1:00 pm
Posts: 1
Just ran over this problem in my development, and posted a fix here:

http://code.google.com/p/emcode/wiki/C3 ... rException


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 2:55 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Awesome save!

Solution 1

Quote:
Geronimo-specific workaround

There is probably a better way, but we chose to edit geronimo.sh to add the activeio argument, since we have already edited that file to allocate more memory for Geronimo in general. Since we always start Geronimo with the start option, a quick fix for us was to edit the code here:


Solution 2

Quote:
A Better Way

A better way around this is to include a case for null property values in c3p0 itself. It really behooves ActiveIO/ActiveMQ to do the right thing (and apparently this is fixed in a future version, but given the Geronimo mix we have, we aren't interested in upgrading right now).

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: C3p0 null pointer exception
PostPosted: Thu Feb 02, 2012 9:46 am 
Newbie

Joined: Thu Feb 02, 2012 9:16 am
Posts: 1
I was getting the same exception for Glassfish connected to Oracle and could solve it by defining missing properties in c3p0.properties and putting this file in classpath. Basically it expects all the properties from C3P0ConnectionProviderto be defined somewhere., They are following,
private static final java.lang.String C3P0_STYLE_MIN_POOL_SIZE = "c3p0.minPoolSize";
private static final java.lang.String C3P0_STYLE_MAX_POOL_SIZE = "c3p0.maxPoolSize";
private static final java.lang.String C3P0_STYLE_MAX_IDLE_TIME = "c3p0.maxIdleTime";
private static final java.lang.String C3P0_STYLE_MAX_STATEMENTS = "c3p0.maxStatements";
private static final java.lang.String C3P0_STYLE_ACQUIRE_INCREMENT = "c3p0.acquireIncrement";
private static final java.lang.String C3P0_STYLE_IDLE_CONNECTION_TEST_PERIOD = "c3p0.idleConnectionTestPeriod";
private static final java.lang.String C3P0_STYLE_TEST_CONNECTION_ON_CHECKOUT = "c3p0.testConnectionOnCheckout";
private static final java.lang.String C3P0_STYLE_INITIAL_POOL_SIZE = "c3p0.initialPoolSize"


Top
 Profile  
 
 Post subject: Re: C3p0 null pointer exception
PostPosted: Thu Apr 04, 2013 9:06 am 
Newbie

Joined: Thu Apr 04, 2013 9:03 am
Posts: 1
I am facing the same issue but, it occurs occasionally.I have multiple applications that are deployed and redeployed.The nullpointer exception does not occur on first deployment.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.