2015-02-03 20:44 GMT+09:00 Konstantin Kolinko <knst.koli...@gmail.com>: > > 2015-02-03 14:13 GMT+03:00 Vadzim Radchykau <v_radchy...@adamantium.net>: > > > > 1. Attached file stack.txt > > 2. version 8.0.18 > > > > 2015-02-03 14:01 GMT+03:00 Konstantin Kolinko <knst.koli...@gmail.com>: > >> > >> 2015-02-03 12:44 GMT+03:00 Vadzim Radchykau <v_radchy...@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&characterEncoding=UTF-8&profileSQL=false&autoSlowLog=false&slowQueryThresholdMillis=100&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-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org >
It is not a solution of the problem, maxActive has changed to maxTotal in DBCP2. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org