相关疑难解决方法(0)

迁移到Tomcat 8:InstanceAlreadyExistsException数据源

我在Tomcat 8中有关于上下文配置的问题.我将项目从Tomcat 7迁移到8并且有异常问题:如果配置中没有任何更改我发现了一个错误:

    "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"
Run Code Online (Sandbox Code Playgroud)

上下文的一部分:

<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"/>
Run Code Online (Sandbox Code Playgroud)

所以,它在tomcat 7中运行没有任何问题.在Tomcat 8中,我可以通过两种方式解决这个问题:

  1. 通过添加到资源: singleton = "false";
  2. 通过添加到资源: factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"

如果我清楚地了解tomcat为我的应用程序和jmx创建数据源,但在Tomcat 7中它是单个对象,在Tomcat 8中它必须是不同的.所以我的问题是为什么会出现这种情况?我在文档中找不到任何有关此更改的信息.我觉得更好的是:创建单个数据源(我想是这样)或者按工厂创建几个.

java configuration tomcat context.xml

25
推荐指数
3
解决办法
1万
查看次数

Deploying two Spring batch applications in same cluster in a single Weblogic Domain?

BackGround -

I am trying to deploy two spring batch applications as .war in same cluster in a single Weblogic Domain & each of them have spring batch admin console configured in servlet.xml like below -

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

  <!-- Spring Batch Admin -->  
  <import resource="classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml"/>
  <import resource="classpath*:/org/springframework/batch/admin/web/resources/webapp-config.xml"/>

  <bean id="resourceService" class="org.springframework.batch.admin.web.resources.DefaultResourceService">
    <property name="servletPath" value="/batch" />
  </bean>  

</beans>
Run Code Online (Sandbox Code Playgroud)

Its a maven project & spring-batch-admin-manager 1.2.2 is pulled in as dependency.

Problem -
I am struggling …

java weblogic spring-batch spring-batch-admin

1
推荐指数
1
解决办法
4332
查看次数