You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Vadzim Radchykau <v_...@adamantium.net> on 2015/02/03 10:44:33 UTC

Tomcat 8

Hello, everybody! I have a question about context config in Tomcat 8. I
migrating project from Tomcat 7 to 8 and have unusual problem: if nothing
change in cofig I catched an error:
"2015-02-03 12:05:48,310 FIRST_ADMIN ERROR web.context.ContextLoader:331
 -> Context initialization failed
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to
register MBean [org.apache.tomcat.dbcp.dbcp2.BasicDataSource@434990dd] with
key 'dataSource'; nested exception is
javax.management.InstanceAlreadyExistsException:
 Catalina:type=DataSource,host=localhost,context=/first-admin,class=javax.sql.DataSource,name="jdbc/datasource/first"

Part of context:
<Resource name="jdbc/datasource/first"
              auth="Container"
              type="javax.sql.DataSource"
              poolPreparedStatements="true"
              initialSize="25"
              maxActive="100"
              maxIdle="100"
              minIdle="25"
              username="us"
              password="pa"
              driverClassName="com.mysql.jdbc.Driver"
              validationQuery="select 1"
              testOnBorrow="true"

 url="jdbc:mysql://localhost:3306/firstproject?useUnicode=true&amp;characterEncoding=UTF-8&amp;profileSQL=false&amp;autoSlowLog=false&amp;slowQueryThresholdMillis=100&amp;autoReconnect=true"/>

So, it's works in tomcat 7 without any proble. In Tomcat 8 I can solve this
problem in 2 ways:
1. By adding to resource: singleton = "false";
2. By adding to resource:
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"

If I clearly understand tomcat creates datasource for my app and for jmx,
but in Tomcat 7 it was single object, in Tomcat 8 it must be differents. So
my question is why that situation is happend? I coudn't find any
information of this change in documentation. And I'm interesting what is
better: create single datasource (I think so) or create several by factory.
Thanks a lot for help!

-- 


[image: Adamantium]

*Vadim Radchikov | Software Engineer*
*mob:* +375 29 3300032   *skype:* vadzimik
*email:* *v_radchykau@adamantium.net* <na...@adamantium.net>

Re: Tomcat 8

Posted by Vadzim Radchykau <v_...@adamantium.net>.
This logic was before me on the project. It mean in Tomcat 7 everything
works with Spring registred pool and Tomcat registered pool - 2 instances?
03.02.2015 14:45 пользователь "Konstantin Kolinko" <kn...@gmail.com>
написал:

> 2015-02-03 14:13 GMT+03:00 Vadzim Radchykau <v_...@adamantium.net>:
> >
> > 1. Attached file stack.txt
> > 2. version 8.0.18
> >
> > 2015-02-03 14:01 GMT+03:00 Konstantin Kolinko <kn...@gmail.com>:
> >>
> >> 2015-02-03 12:44 GMT+03:00 Vadzim Radchykau <v_radchykau@adamantium.net
> >:
> >> > Hello, everybody! I have a question about context config in Tomcat 8.
> I
> >> > migrating project from Tomcat 7 to 8 and have unusual problem: if
> nothing
> >> > change in cofig I catched an error:
> >> > "2015-02-03 12:05:48,310 FIRST_ADMIN ERROR
> web.context.ContextLoader:331
> >> >  -> Context initialization failed
> >> > org.springframework.jmx.export.UnableToRegisterMBeanException: Unable
> to
> >> > register MBean [org.apache.tomcat.dbcp.dbcp2.BasicDataSource@434990dd]
> with
> >> > key 'dataSource'; nested exception is
> >> > javax.management.InstanceAlreadyExistsException:
> >> >
> Catalina:type=DataSource,host=localhost,context=/first-admin,class=javax.sql.DataSource,name="jdbc/datasource/first"
> >> >
> >> > Part of context:
> >> > <Resource name="jdbc/datasource/first"
> >> >               auth="Container"
> >> >               type="javax.sql.DataSource"
> >> >               poolPreparedStatements="true"
> >> >               initialSize="25"
> >> >               maxActive="100"
> >> >               maxIdle="100"
> >> >               minIdle="25"
> >> >               username="us"
> >> >               password="pa"
> >> >               driverClassName="com.mysql.jdbc.Driver"
> >> >               validationQuery="select 1"
> >> >               testOnBorrow="true"
> >> >
> >> >
> url="jdbc:mysql://localhost:3306/firstproject?useUnicode=true&amp;characterEncoding=UTF-8&amp;profileSQL=false&amp;autoSlowLog=false&amp;slowQueryThresholdMillis=100&amp;autoReconnect=true"/>
> >> >
> >> > So, it's works in tomcat 7 without any proble. In Tomcat 8 I can
> solve this
> >> > problem in 2 ways:
> >> > 1. By adding to resource: singleton = "false";
> >> > 2. By adding to resource:
> >> > factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
> >> >
> >> > If I clearly understand tomcat creates datasource for my app and for
> jmx,
> >> > but in Tomcat 7 it was single object, in Tomcat 8 it must be
> differents. So
> >> > my question is why that situation is happend? I coudn't find any
> >> > information of this change in documentation. And I'm interesting what
> is
> >> > better: create single datasource (I think so) or create several by
> factory.
> >> > Thanks a lot for help!
> >>
> >>
> >> 1. Full stacktrace of javax.management.InstanceAlreadyExistsException =?
> >>
> >> 2. Exact version of Tomcat 8.0.x = ?  I suspect that you are using
> >> some old version, as the last time I remember hearing about similar
> >> issues was ~2 years ago.
> >>
>
>
> Read the "Important" part here:
> http://tomcat.apache.org/lists.html#tomcat-users
>
> (no top-posting, use plain text, no attachments).
>
>
> Your stacktrace:
> [[[
> 2015-02-03 14:09:26,471 first-ADMIN ERROR web.context.ContextLoader:331
> -> Co
> ntext initialization failed
> org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to
> registe
> r MBean [org.apache.tomcat.dbcp.dbcp2.BasicDataSource@481a5a10] with key
> 'dataSo
> urce'; nested exception is
> javax.management.InstanceAlreadyExistsException: Cata
>
> lina:type=DataSource,host=localhost,context=/first-admin,class=javax.sql.DataS
> ource,name="jdbc/datasource/first"
>         at
> org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstan
> ce(MBeanExporter.java:613)
>         at
> org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExpor
> ter.java:538)
>         at
> org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantia
> ted(MBeanExporter.java:420)
>         at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.
> preInstantiateSingletons(DefaultListableBeanFactory.java:745)
>         at
> org.springframework.context.support.AbstractApplicationContext.finish
> BeanFactoryInitialization(AbstractApplicationContext.java:757)
>         at
> org.springframework.context.support.AbstractApplicationContext.refres
> h(AbstractApplicationContext.java:480)
>         at
> org.springframework.web.context.ContextLoader.configureAndRefreshWebA
> pplicationContext(ContextLoader.java:403)
>         at
> org.springframework.web.context.ContextLoader.initWebApplicationConte
> xt(ContextLoader.java:306)
>         at
> org.springframework.web.context.ContextLoaderListener.contextInitiali
> zed(ContextLoaderListener.java:106)
>         at
> org.apache.catalina.core.StandardContext.listenerStart(StandardContex
> t.java:4720)
>         at
> org.apache.catalina.core.StandardContext.startInternal(StandardContex
> t.java:5154)
>         at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>         at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
> .java:725)
>         at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:70
> 1)
>         at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
>
>         at
> org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.ja
> va:581)
>         at
> org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfi
> g.java:1683)
> ]]]
>
>
> So Spring tries to register the pool with JMX. You should turn off
> that feature in Spring. The pool you are using is owned and managed by
> Tomcat, not by Spring. Why is Spring registering anything for that
> pool?
>
> Generally web applications should not use JMX, unless it is a known
> "administration" webapp like Tomcat Manager. If you were running with
> SecurityManager enabled, you would have been stopped.
>
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Tomcat 8

Posted by 別所辰哉 <t....@gmail.com>.
2015-02-03 20:44 GMT+09:00 Konstantin Kolinko <kn...@gmail.com>:
>
> 2015-02-03 14:13 GMT+03:00 Vadzim Radchykau <v_...@adamantium.net>:
> >
> > 1. Attached file stack.txt
> > 2. version 8.0.18
> >
> > 2015-02-03 14:01 GMT+03:00 Konstantin Kolinko <kn...@gmail.com>:
> >>
> >> 2015-02-03 12:44 GMT+03:00 Vadzim Radchykau <v_...@adamantium.net>:
> >> > Hello, everybody! I have a question about context config in Tomcat 8. I
> >> > migrating project from Tomcat 7 to 8 and have unusual problem: if nothing
> >> > change in cofig I catched an error:
> >> > "2015-02-03 12:05:48,310 FIRST_ADMIN ERROR web.context.ContextLoader:331
> >> >  -> Context initialization failed
> >> > org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to
> >> > register MBean [org.apache.tomcat.dbcp.dbcp2.BasicDataSource@434990dd] with
> >> > key 'dataSource'; nested exception is
> >> > javax.management.InstanceAlreadyExistsException:
> >> >  Catalina:type=DataSource,host=localhost,context=/first-admin,class=javax.sql.DataSource,name="jdbc/datasource/first"
> >> >
> >> > Part of context:
> >> > <Resource name="jdbc/datasource/first"
> >> >               auth="Container"
> >> >               type="javax.sql.DataSource"
> >> >               poolPreparedStatements="true"
> >> >               initialSize="25"
> >> >               maxActive="100"
> >> >               maxIdle="100"
> >> >               minIdle="25"
> >> >               username="us"
> >> >               password="pa"
> >> >               driverClassName="com.mysql.jdbc.Driver"
> >> >               validationQuery="select 1"
> >> >               testOnBorrow="true"
> >> >
> >> >  url="jdbc:mysql://localhost:3306/firstproject?useUnicode=true&amp;characterEncoding=UTF-8&amp;profileSQL=false&amp;autoSlowLog=false&amp;slowQueryThresholdMillis=100&amp;autoReconnect=true"/>
> >> >
> >> > So, it's works in tomcat 7 without any proble. In Tomcat 8 I can solve this
> >> > problem in 2 ways:
> >> > 1. By adding to resource: singleton = "false";
> >> > 2. By adding to resource:
> >> > factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
> >> >
> >> > If I clearly understand tomcat creates datasource for my app and for jmx,
> >> > but in Tomcat 7 it was single object, in Tomcat 8 it must be differents. So
> >> > my question is why that situation is happend? I coudn't find any
> >> > information of this change in documentation. And I'm interesting what is
> >> > better: create single datasource (I think so) or create several by factory.
> >> > Thanks a lot for help!
> >>
> >>
> >> 1. Full stacktrace of javax.management.InstanceAlreadyExistsException =?
> >>
> >> 2. Exact version of Tomcat 8.0.x = ?  I suspect that you are using
> >> some old version, as the last time I remember hearing about similar
> >> issues was ~2 years ago.
> >>
>
>
> Read the "Important" part here:
> http://tomcat.apache.org/lists.html#tomcat-users
>
> (no top-posting, use plain text, no attachments).
>
>
> Your stacktrace:
> [[[
> 2015-02-03 14:09:26,471 first-ADMIN ERROR web.context.ContextLoader:331  -> Co
> ntext initialization failed
> org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to registe
> r MBean [org.apache.tomcat.dbcp.dbcp2.BasicDataSource@481a5a10] with key 'dataSo
> urce'; nested exception is javax.management.InstanceAlreadyExistsException: Cata
> lina:type=DataSource,host=localhost,context=/first-admin,class=javax.sql.DataS
> ource,name="jdbc/datasource/first"
>         at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstan
> ce(MBeanExporter.java:613)
>         at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExpor
> ter.java:538)
>         at org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantia
> ted(MBeanExporter.java:420)
>         at org.springframework.beans.factory.support.DefaultListableBeanFactory.
> preInstantiateSingletons(DefaultListableBeanFactory.java:745)
>         at org.springframework.context.support.AbstractApplicationContext.finish
> BeanFactoryInitialization(AbstractApplicationContext.java:757)
>         at org.springframework.context.support.AbstractApplicationContext.refres
> h(AbstractApplicationContext.java:480)
>         at org.springframework.web.context.ContextLoader.configureAndRefreshWebA
> pplicationContext(ContextLoader.java:403)
>         at org.springframework.web.context.ContextLoader.initWebApplicationConte
> xt(ContextLoader.java:306)
>         at org.springframework.web.context.ContextLoaderListener.contextInitiali
> zed(ContextLoaderListener.java:106)
>         at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
> t.java:4720)
>         at org.apache.catalina.core.StandardContext.startInternal(StandardContex
> t.java:5154)
>         at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>         at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
> .java:725)
>         at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:70
> 1)
>         at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
>
>         at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.ja
> va:581)
>         at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfi
> g.java:1683)
> ]]]
>
>
> So Spring tries to register the pool with JMX. You should turn off
> that feature in Spring. The pool you are using is owned and managed by
> Tomcat, not by Spring. Why is Spring registering anything for that
> pool?
>
> Generally web applications should not use JMX, unless it is a known
> "administration" webapp like Tomcat Manager. If you were running with
> SecurityManager enabled, you would have been stopped.
>
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

It is not a solution of the problem, maxActive has changed to maxTotal in DBCP2.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 8

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-02-03 14:13 GMT+03:00 Vadzim Radchykau <v_...@adamantium.net>:
>
> 1. Attached file stack.txt
> 2. version 8.0.18
>
> 2015-02-03 14:01 GMT+03:00 Konstantin Kolinko <kn...@gmail.com>:
>>
>> 2015-02-03 12:44 GMT+03:00 Vadzim Radchykau <v_...@adamantium.net>:
>> > Hello, everybody! I have a question about context config in Tomcat 8. I
>> > migrating project from Tomcat 7 to 8 and have unusual problem: if nothing
>> > change in cofig I catched an error:
>> > "2015-02-03 12:05:48,310 FIRST_ADMIN ERROR web.context.ContextLoader:331
>> >  -> Context initialization failed
>> > org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to
>> > register MBean [org.apache.tomcat.dbcp.dbcp2.BasicDataSource@434990dd] with
>> > key 'dataSource'; nested exception is
>> > javax.management.InstanceAlreadyExistsException:
>> >  Catalina:type=DataSource,host=localhost,context=/first-admin,class=javax.sql.DataSource,name="jdbc/datasource/first"
>> >
>> > Part of context:
>> > <Resource name="jdbc/datasource/first"
>> >               auth="Container"
>> >               type="javax.sql.DataSource"
>> >               poolPreparedStatements="true"
>> >               initialSize="25"
>> >               maxActive="100"
>> >               maxIdle="100"
>> >               minIdle="25"
>> >               username="us"
>> >               password="pa"
>> >               driverClassName="com.mysql.jdbc.Driver"
>> >               validationQuery="select 1"
>> >               testOnBorrow="true"
>> >
>> >  url="jdbc:mysql://localhost:3306/firstproject?useUnicode=true&amp;characterEncoding=UTF-8&amp;profileSQL=false&amp;autoSlowLog=false&amp;slowQueryThresholdMillis=100&amp;autoReconnect=true"/>
>> >
>> > So, it's works in tomcat 7 without any proble. In Tomcat 8 I can solve this
>> > problem in 2 ways:
>> > 1. By adding to resource: singleton = "false";
>> > 2. By adding to resource:
>> > factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
>> >
>> > If I clearly understand tomcat creates datasource for my app and for jmx,
>> > but in Tomcat 7 it was single object, in Tomcat 8 it must be differents. So
>> > my question is why that situation is happend? I coudn't find any
>> > information of this change in documentation. And I'm interesting what is
>> > better: create single datasource (I think so) or create several by factory.
>> > Thanks a lot for help!
>>
>>
>> 1. Full stacktrace of javax.management.InstanceAlreadyExistsException =?
>>
>> 2. Exact version of Tomcat 8.0.x = ?  I suspect that you are using
>> some old version, as the last time I remember hearing about similar
>> issues was ~2 years ago.
>>


Read the "Important" part here:
http://tomcat.apache.org/lists.html#tomcat-users

(no top-posting, use plain text, no attachments).


Your stacktrace:
[[[
2015-02-03 14:09:26,471 first-ADMIN ERROR web.context.ContextLoader:331  -> Co
ntext initialization failed
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to registe
r MBean [org.apache.tomcat.dbcp.dbcp2.BasicDataSource@481a5a10] with key 'dataSo
urce'; nested exception is javax.management.InstanceAlreadyExistsException: Cata
lina:type=DataSource,host=localhost,context=/first-admin,class=javax.sql.DataS
ource,name="jdbc/datasource/first"
        at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstan
ce(MBeanExporter.java:613)
        at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExpor
ter.java:538)
        at org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantia
ted(MBeanExporter.java:420)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:745)
        at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:757)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:480)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebA
pplicationContext(ContextLoader.java:403)
        at org.springframework.web.context.ContextLoader.initWebApplicationConte
xt(ContextLoader.java:306)
        at org.springframework.web.context.ContextLoaderListener.contextInitiali
zed(ContextLoaderListener.java:106)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
t.java:4720)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContex
t.java:5154)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:70
1)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)

        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.ja
va:581)
        at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfi
g.java:1683)
]]]


So Spring tries to register the pool with JMX. You should turn off
that feature in Spring. The pool you are using is owned and managed by
Tomcat, not by Spring. Why is Spring registering anything for that
pool?

Generally web applications should not use JMX, unless it is a known
"administration" webapp like Tomcat Manager. If you were running with
SecurityManager enabled, you would have been stopped.


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 8

Posted by Vadzim Radchykau <v_...@adamantium.net>.
1. Attached file stack.txt
2. version 8.0.18

2015-02-03 14:01 GMT+03:00 Konstantin Kolinko <kn...@gmail.com>:

> 2015-02-03 12:44 GMT+03:00 Vadzim Radchykau <v_...@adamantium.net>:
> > Hello, everybody! I have a question about context config in Tomcat 8. I
> > migrating project from Tomcat 7 to 8 and have unusual problem: if nothing
> > change in cofig I catched an error:
> > "2015-02-03 12:05:48,310 FIRST_ADMIN ERROR web.context.ContextLoader:331
> >  -> Context initialization failed
> > org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to
> > register MBean [org.apache.tomcat.dbcp.dbcp2.BasicDataSource@434990dd]
> with
> > key 'dataSource'; nested exception is
> > javax.management.InstanceAlreadyExistsException:
> >
> Catalina:type=DataSource,host=localhost,context=/first-admin,class=javax.sql.DataSource,name="jdbc/datasource/first"
> >
> > Part of context:
> > <Resource name="jdbc/datasource/first"
> >               auth="Container"
> >               type="javax.sql.DataSource"
> >               poolPreparedStatements="true"
> >               initialSize="25"
> >               maxActive="100"
> >               maxIdle="100"
> >               minIdle="25"
> >               username="us"
> >               password="pa"
> >               driverClassName="com.mysql.jdbc.Driver"
> >               validationQuery="select 1"
> >               testOnBorrow="true"
> >
> >
> url="jdbc:mysql://localhost:3306/firstproject?useUnicode=true&amp;characterEncoding=UTF-8&amp;profileSQL=false&amp;autoSlowLog=false&amp;slowQueryThresholdMillis=100&amp;autoReconnect=true"/>
> >
> > So, it's works in tomcat 7 without any proble. In Tomcat 8 I can solve
> this
> > problem in 2 ways:
> > 1. By adding to resource: singleton = "false";
> > 2. By adding to resource:
> > factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
> >
> > If I clearly understand tomcat creates datasource for my app and for jmx,
> > but in Tomcat 7 it was single object, in Tomcat 8 it must be differents.
> So
> > my question is why that situation is happend? I coudn't find any
> > information of this change in documentation. And I'm interesting what is
> > better: create single datasource (I think so) or create several by
> factory.
> > Thanks a lot for help!
>
>
> 1. Full stacktrace of javax.management.InstanceAlreadyExistsException =?
>
> 2. Exact version of Tomcat 8.0.x = ?  I suspect that you are using
> some old version, as the last time I remember hearing about similar
> issues was ~2 years ago.
>
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 


[image: Adamantium]

*Vadim Radchikov | Software Engineer*
*mob:* +375 29 3300032   *skype:* vadzimik
*email:* *v_radchykau@adamantium.net* <na...@adamantium.net>

Re: Tomcat 8

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-02-03 12:44 GMT+03:00 Vadzim Radchykau <v_...@adamantium.net>:
> Hello, everybody! I have a question about context config in Tomcat 8. I
> migrating project from Tomcat 7 to 8 and have unusual problem: if nothing
> change in cofig I catched an error:
> "2015-02-03 12:05:48,310 FIRST_ADMIN ERROR web.context.ContextLoader:331
>  -> Context initialization failed
> org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to
> register MBean [org.apache.tomcat.dbcp.dbcp2.BasicDataSource@434990dd] with
> key 'dataSource'; nested exception is
> javax.management.InstanceAlreadyExistsException:
>  Catalina:type=DataSource,host=localhost,context=/first-admin,class=javax.sql.DataSource,name="jdbc/datasource/first"
>
> Part of context:
> <Resource name="jdbc/datasource/first"
>               auth="Container"
>               type="javax.sql.DataSource"
>               poolPreparedStatements="true"
>               initialSize="25"
>               maxActive="100"
>               maxIdle="100"
>               minIdle="25"
>               username="us"
>               password="pa"
>               driverClassName="com.mysql.jdbc.Driver"
>               validationQuery="select 1"
>               testOnBorrow="true"
>
>  url="jdbc:mysql://localhost:3306/firstproject?useUnicode=true&amp;characterEncoding=UTF-8&amp;profileSQL=false&amp;autoSlowLog=false&amp;slowQueryThresholdMillis=100&amp;autoReconnect=true"/>
>
> So, it's works in tomcat 7 without any proble. In Tomcat 8 I can solve this
> problem in 2 ways:
> 1. By adding to resource: singleton = "false";
> 2. By adding to resource:
> factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
>
> If I clearly understand tomcat creates datasource for my app and for jmx,
> but in Tomcat 7 it was single object, in Tomcat 8 it must be differents. So
> my question is why that situation is happend? I coudn't find any
> information of this change in documentation. And I'm interesting what is
> better: create single datasource (I think so) or create several by factory.
> Thanks a lot for help!


1. Full stacktrace of javax.management.InstanceAlreadyExistsException =?

2. Exact version of Tomcat 8.0.x = ?  I suspect that you are using
some old version, as the last time I remember hearing about similar
issues was ~2 years ago.


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org