Page 1 of 1

[BLC-4.0] - Tomcat Server Issue - URGENT -[RESOLVED]

Posted: Wed Feb 03, 2016 2:42 am
by sumit784
I am setting up the latest version of BLc and setting up the application on "Standalone Tomcat 7" server and using MySql server. I have setup the server in my eclipse itself.

I have done the following changes :-

- Followed all the steps from here and updated all the files (as needed) :- http://www.broadleafcommerce.com/docs/c ... figuration

- Updated the Dialects to org.hibernate.dialect.MySQL5InnoDBDialect in common-shared.properties file.
- removed all the dependencies to HSQL database in the pom.xml files and replaced them with mysql maven dependencies
- Added mysql-connector-java-5.1.26 to tomcat lib directory.


These are my context.xml configs in site project:-

<Resource name="jdbc/web" auth="Container" type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/motrss_shop"
username="root" password="test"
maxActive="30" maxIdle="60" maxWait="10000"
connectionProperties="useUnicode=true;characterEncoding=utf8;"
/>

<Resource name="jdbc/secure" auth="Container" type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/motrss_shop"
username="root" password="test"
maxActive="30" maxIdle="60" maxWait="10000"
connectionProperties="useUnicode=true;characterEncoding=utf8;"
/>

<Resource name="jdbc/storage" auth="Container" type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/motrss_shop"
username="root" password="test"
maxActive="30" maxIdle="60" maxWait="10000"
connectionProperties="useUnicode=true;characterEncoding=utf8;"
/>

On starting the server with these configs , all the tables are being created, but then the server throws this error :-

Hibernate: create table SEQUENCE_GENERATOR ( ID_NAME varchar(255) not null , ID_VAL bigint, primary key ( ID_NAME ) )
[SUPPORT] 03:25:39 ModuleLifecycleLoggingBean - Menu - LOADING
[ERROR] 03:25:40 ContextLoader - Context initialization failed
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.apache.tomcat.dbcp.dbcp2.BasicDataSource@47d3af33] with key 'webStorageDS'; nested exception is javax.management.InstanceAlreadyExistsException: Catalina:type=DataSource,host=localhost,context=/mycompany,class=javax.sql.DataSource,name="jdbc/storage"
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:625)
at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:550)
at org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:432)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.broadleafcommerce.common.web.extensibility.MergeContextLoader.contextInitialized(MergeContextLoader.java:148)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.management.InstanceAlreadyExistsException: Catalina:type=DataSource,host=localhost,context=/mycompany,class=javax.sql.DataSource,name="jdbc/storage"
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
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:522)




Am I missing something here.
Any info , anyone.

Thanks in Advance.

- Sumit Rathore

Re: [BLC-4.0] - Tomcat Server Issue - URGENT -[updated]

Posted: Fri Feb 05, 2016 1:17 am
by sumit784
Issue resolved.

Solution :-

I have been missing some configuration on site/context.xml , Here is the complete configthat works for me.

<Resource name="jdbc/web"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
testWhileIdle="true"
testOnBorrow="true"
testOnReturn="false"
validationQuery="SELECT 1"
timeBetweenEvictionRunsMillis="30000"
maxActive="15"
maxIdle="10"
minIdle="5"
removeAbandonedTimeout="60"
removeAbandoned="false"
logAbandoned="true"
minEvictableIdleTimeMillis="30000"
jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
username="user"
password="pass"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/YOUR_DB_HERE"/>