You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2012/11/23 15:35:58 UTC
[Bug 54194] New: NPE in DataSource.registerJmx() although DataSource
is created with setJmxEnabled(false)
https://issues.apache.org/bugzilla/show_bug.cgi?id=54194
Bug ID: 54194
Summary: NPE in DataSource.registerJmx() although DataSource is
created with setJmxEnabled(false)
Product: Tomcat Modules
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: jdbc-pool
Assignee: dev@tomcat.apache.org
Reporter: tobias.gierke@voipfuture.com
Classification: Unclassified
Created attachment 29626
--> https://issues.apache.org/bugzilla/attachment.cgi?id=29626&action=edit
Patch against DataSource.java (rev 1412899) from /tomcat/tc7.0.x/trunk
The exception does not seem to have any impact (at least not for my
application) on the connection pools functionality , it's merely a minor
annoyance.
The attached patch fixed the problem for me.
OS: Ubuntu 12.04 64-bit
JDK:
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
Version of tomcat-jdbc.jar: 7.0.33
I create the datasource inside a custom ObjectFactory (because I need to
retrieve JDBC URL/username/password from a config file on the classpath):
Resources are configured inside tomcat/conf/context.xml as follows:
------------------------------------
<Resource name="jdbc/db0"
database="db0"
auth="Container"
type="javax.sql.DataSource"
factory="my.DatasourceResourceFactory" />
<Resource name="jdbc/db1"
database="db1"
auth="Container"
type="javax.sql.DataSource"
factory="my.DatasourceResourceFactory" />
------------------------------------
I'm creating the datasource like so:
------------------------------------
private DataSource createDataSource(String jdbcUrl,String username,String
password)
{
final PoolProperties p = new PoolProperties();
p.setUrl( jdbcUrl );
p.setDriverClassName("org.postgresql.Driver");
p.setUsername( username );
p.setPassword( password );
p.setJmxEnabled(false); // JMX disabled
p.setTestWhileIdle(false);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setInitialSize(5);
p.setMaxActive(25);
p.setMinIdle(0);
p.setMaxIdle(8);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMinEvictableIdleTimeMillis(30000);
p.setRemoveAbandonedTimeout(60);
p.setLogAbandoned(false);
p.setRemoveAbandoned(false);
p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
final DataSource datasource = new DataSource();
datasource.setPoolProperties(p);
return datasource;
}
------------------------------------
This is the exception showing up in the log file:
------------------------------------
2012-11-23 14:53:48,109 [pool-2-thread-1] ERROR
org.apache.tomcat.jdbc.pool.DataSource - Unable to register JDBC pool with JMX
java.lang.NullPointerException
at
org.apache.tomcat.jdbc.pool.DataSource.registerJmx(DataSource.java:135)
at
org.apache.tomcat.jdbc.pool.DataSource.preRegister(DataSource.java:102)
at
org.apache.tomcat.util.modeler.BaseModelMBean.preRegister(BaseModelMBean.java:1132)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.preRegister(DefaultMBeanServerInterceptor.java:1007)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:919)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:512)
at
org.apache.tomcat.util.modeler.Registry.registerComponent(Registry.java:742)
at
org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1062)
at
org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:671)
at
org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:270)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5161)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 54194] NPE in DataSource.registerJmx() although DataSource is
created with setJmxEnabled(false)
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54194
tobias.gierke@voipfuture.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tobias.gierke@voipfuture.co
| |m
Severity|normal |minor
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 54194] NPE in DataSource.registerJmx() although DataSource is
created with setJmxEnabled(false)
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54194
Keiichi Fujino <kf...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #1 from Keiichi Fujino <kf...@apache.org> ---
Thanks for the report.
The cause of this NPE is not initializing connection pool.
You can avoid this problem by calling dataSource.createPool().
Anyway, I am going to apply your patch.
And it will be included in 7.0.34 onwards.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org