Community   SpringSource   Projects    Downloads    Documentation    Forums    Training   Exchange   Blogs

Go Back   Spring Community Forums > Core Spring Projects > Data Access

Reply
 
Thread Tools Display Modes
  #1  
Old Sep 20th, 2007, 11:30 AM
drvillo drvillo is offline
Member
 
Join Date: Jun 2006
Posts: 30
Default NPE in commons.dbcp with Hibernate, AOP and Quartz

Hi all

I'm not sure this is the right place, but I don't quite know to whom this issue might belong (beside me).

I'm using quite a mix of things here: to make it simple I'm creating stateful jobs with Quartz. I'm attaching dynamic aspects to inject an Hibernate session, and to perform transaction demarcation.
Everything goes along pretty well it seems, but I don't know why after some time I begin getting the following trace.

Any comment?

Code:
java.lang.NullPointerException
	at org.apache.commons.dbcp.PoolingConnection.toString(PoolingConnection.java:248)
	at java.lang.String.valueOf(String.java:2615)
	at java.lang.StringBuffer.append(StringBuffer.java:220)
	at org.apache.commons.dbcp.DelegatingConnection.checkOpen(DelegatingConnection.java:354)
	at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:246)
	at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:302)
	at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
	at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
	at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
	at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
	at org.hibernate.loader.Loader.doQuery(Loader.java:673)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
	at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
	at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
	at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
	at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
	at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
	at org.hibernate.collection.PersistentSet.toArray(PersistentSet.java:171)
	at org.atalaya.isec.dashb.db.Hosts.getIp(Hosts.java:53)
	at org.atalaya.isec.appliance.nmap.NmapThread.prepare(NmapThread.java:49)
	at org.atalaya.isec.update.AScanTask.execute(AScanTask.java:62)
	at org.atalaya.isec.update.AScanTask$$FastClassByCGLIB$$f5924b97.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
	at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:695)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
	at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
	at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:54)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
	at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:630)
	at org.atalaya.isec.appliance.nmap.NmapThread$$EnhancerByCGLIB$$4386de9a.execute(<generated>)
	at org.atalaya.isec.update.scheduling.StatefulTaskAdapter.execute(StatefulTaskAdapter.java:32)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:203)

thanks everybody
Francesco
Reply With Quote
  #2  
Old Sep 20th, 2007, 02:33 PM
Jörg Heinicke Jörg Heinicke is offline
Senior Member
 
Join Date: Nov 2005
Location: Reutlingen, Germany
Posts: 2,098
Default

I wonder why it tries to call toString() on the connection. Are you keen enough to look into the code? Maybe it's only an error in the logging (not handling null) AFTER another exception which would be your actual error.

Joerg
__________________
This post can contain insufficient information.
Reply With Quote
  #3  
Old Sep 21st, 2007, 11:08 AM
drvillo drvillo is offline
Member
 
Join Date: Jun 2006
Posts: 30
Default

I've checked and the offending part is in

Code:
    protected void checkOpen() throws SQLException {
        if(_closed) {
            throw new SQLException
                ("Connection " + _conn + " is closed.");
        }
    }
so yes, it was going to throw an exception anyway.
I don't know what was messing up, I've been running the same code since this post without problem. I've a slight feeling that the combination Maven+jetty plugin+debug+all the rest might have screwed up...

Cheers
F
Reply With Quote
  #4  
Old Sep 22nd, 2007, 04:26 PM
Jörg Heinicke Jörg Heinicke is offline
Senior Member
 
Join Date: Nov 2005
Location: Reutlingen, Germany
Posts: 2,098
Default

I have reported the issue regarding the NPE to Apache Commons DBCP Jira.

Joerg
__________________
This post can contain insufficient information.
Reply With Quote
  #5  
Old Sep 22nd, 2007, 04:56 PM
al0 al0 is offline
Senior Member
 
Join Date: Aug 2006
Location: Now Germany, previously Ukraine
Posts: 1,496
Default

Anyway, it was stated many times in this forum that C3P0 produces better results then DBCP (and my own experience confirms it).

Regards,
Oleksandr
Quote:
Originally Posted by drvillo View Post
I've checked and the offending part is in

Code:
    protected void checkOpen() throws SQLException {
        if(_closed) {
            throw new SQLException
                ("Connection " + _conn + " is closed.");
        }
    }
so yes, it was going to throw an exception anyway.
I don't know what was messing up, I've been running the same code since this post without problem. I've a slight feeling that the combination Maven+jetty plugin+debug+all the rest might have screwed up...

Cheers
F

Last edited by al0; Sep 22nd, 2007 at 05:01 PM. Reason: Absolutely invalid statement was removed, sorry
Reply With Quote
  #6  
Old Sep 22nd, 2007, 06:11 PM
drvillo drvillo is offline
Member
 
Join Date: Jun 2006
Posts: 30
Default

Nice, thanks.
I was going to do it myself but you've been more efficient

Cheers
F

Quote:
Originally Posted by Jörg Heinicke View Post
I have reported the issue regarding the NPE to Apache Commons DBCP Jira.

Joerg
Reply With Quote
  #7  
Old Sep 23rd, 2007, 06:57 AM
karldmoore karldmoore is offline
Senior Member
 
Join Date: Sep 2006
Posts: 8,417
Default

Quote:
Originally Posted by al0 View Post
Anyway, it was stated many times in this forum that C3P0 produces better results then DBCP (and my own experience confirms it).
Yeah, I'd go with this one. We made the same change when we experienced problems.
__________________
Senior Java Developer
http://twitter.com/karldmoore
Reply With Quote
  #8  
Old Sep 23rd, 2007, 03:57 PM
Jörg Heinicke Jörg Heinicke is offline
Senior Member
 
Join Date: Nov 2005
Location: Reutlingen, Germany
Posts: 2,098
Default

Quote:
Originally Posted by al0 View Post
Anyway, it was stated many times in this forum that C3P0 produces better results then DBCP
See how fast things get fixed for DBCP. Does this stand for C3P0 as well?

My vein to Apache is obvious

Joerg
__________________
This post can contain insufficient information.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:00 AM.


Contegix provides first-class managed hosting and partial sponsorship of these forums.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.