mbeanExporter调用init方法失败UnableToRegisterMBeanException ...是javax.management.InstanceAlreadyExistsException

时间:2016-09-10 04:47:48

标签: spring servlets websphere spring-batch spring-batch-admin

我得到" mbeanExporter调用init方法失败UnableToRegisterMBeanException ... InstanceAlreadyExistsException"尝试在Websphere 8中启动一个非常简单的Spring Batch Admin应用程序。整个应用程序可以从https://examples.javacodegeeks.com/enterprise-java/spring/spring-batch-admin-tutorial/下载。

这是一个非常简单的Spring Batch Admin项目,只有一个非常简单的工作。我可以在Eclipse中成功调试项目,我可以构建战争,成功地将它部署到Websphere Liberty Profile 8.5。通过成功,我的意思是我可以打开Spring Batch管理控制台并正确触发工作。

下面的错误我只有在将此类战争移至Mainframe Websphere 8.5 ND时才会收到。我不认为它与大型机/ unix直接相关。事实上,我想知道下面在我的Pom.xml和Websphere中描述的库之间是否存在冲突。任何想法检查的东西都会非常欣赏。最近,我在使用Hibernate / JPA时遇到了一些问题,只需降级一下该版本即可修复错误。这有点类似的情况:在Websphere Liberty Profile中工作,但在我的pom.xml中降级hibernate版本之前,它在Websphere 8.5 ND中不起作用。好吧,这一次根本没有休眠,但是我在这里输入的是什么时候修复的,也许它可以帮助别人给我一些想法检查。我有一个临时的想法,认为这是图书馆冲突,但我不知道该检查或调查什么。

我看到很少有人使用Spring Boot得到类似的错误,但这根本不是我的情况。特别是在Getting exception while refreshing Spring ApplicationContext in Spring Boot application中,有人在添加

后得到与我完全相同的错误
@EnableIntegrationMBeanExport(registration = RegistrationPolicy.REPLACE_EXISTING)

尽管如此,我在这样的项目中没有任何anotation,我至少没有明确地使用EnableIntegrationMBeanExport。也许它已被用在幕后但我并不是那么专家所以如果有人能给我机会检查它将是一个很好的北方。另外,我没有使用Spring MVC。

启动应用程序时出错

Trace: 2016/09/09 22:49:17.049 02 t=9BDE88 c=UNK key=P8 tag= (13007004)

  SourceId: com.ibm.ws.webcontainer.webapp.WebApp.logServletError

  ExtendedMessage: BBOO0220E: SRVE0293E: ÝServlet Error¨-ÝBatch Servlet¨: org.springframework.beans.factory.BeanCreationException: E

rror creating bean with name 'mbeanExporter': Invocation of init method failed; nested exception is org.springframework.jmx.export.U

nableToRegisterMBeanException: Unable to register MBean Ýorg.springframework.integration.monitor.IntegrationMBeanExporter@4ed60bcf¨

with key 'integrationMBeanExporter'; nested exception is javax.management.InstanceAlreadyExistsException: spring.application:cell=dt

l85cel,name=integrationMBeanExporter,type=IntegrationMBeanExporter,node=wlemyAppa,process=WLEmyApp

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.j

ava:1553)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.jav

a:539)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:

475)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:70

3)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:7

60)

...

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanSe

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:814)

at com.ibm.ws390.management.connector.corba.CorbaConnectorImpl.invoke(CorbaCon

at com.ibm.ws390.management.connector.corba._CorbaConnectorImplBase._invoke(_C

at com.ibm.ws390.orb.CommonBridge.invoke(CommonBridge.java:1898)

at com.ibm.ws390.orb.CommonBridge.getAndProcessWork(CommonBridge.java:725)

at com.ibm.ws390.orb.CommonBridge.runApplicationThread(CommonBridge.java:614)

at com.ibm.ws390.management.connector.corba.CorbaConnectorImpl.invoke(CorbaCon

at com.ibm.ws390.management.connector.corba._CorbaConnectorImplBase._invoke(_C

at com.ibm.ws390.orb.CommonBridge.invoke(CommonBridge.java:1898)

at com.ibm.ws390.orb.CommonBridge.getAndProcessWork(CommonBridge.java:725)

at com.ibm.ws390.orb.CommonBridge.runApplicationThread(CommonBridge.java:614)

at com.ibm.ws.util.ThreadPool$ZOSWorker.run(ThreadPool.java:2116)

Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean Ýorg.springframework.integration.

monitor.IntegrationMBeanExporter@4ed60bcf¨ with key 'integrationMBeanExporter';nested exception is javax.management.InstanceAlready

ExistsException: spring.application:cell=mycel,name=integrationMBeanExporter,type=IntegrationMBeanExporter,node=wlemyAppa,process=

WLEmyApp

的pom.xml
           

              <spring.version>4.0.5.RELEASE</spring.version>

              <spring.batch.version>3.0.4.RELEASE</spring.batch.version>

              <spring.jdbc.version>4.0.5.RELEASE</spring.jdbc.version>

              <hsql.version>1.8.0.7</hsql.version>

              <commons.version>1.4</commons.version>

              <spring.oxm.version>4.0.5.RELEASE</spring.oxm.version>

              <spring.batch.admin>1.3.1.RELEASE</spring.batch.admin>

       </properties>

       <dependencies>

              <dependency>

                     <groupId>org.springframework.batch</groupId>

                     <artifactId>spring-batch-core</artifactId>

                     <version>${spring.batch.version}</version>

              </dependency>



              <dependency>

                     <groupId>org.springframework</groupId>

                     <artifactId>spring-context-support</artifactId>

                     <version>${spring.version}</version>

              </dependency>

              <dependency>

                     <groupId>hsqldb</groupId>

                     <artifactId>hsqldb</artifactId>

                     <version>${hsql.version}</version>

              </dependency>

              <dependency>

                     <groupId>org.springframework</groupId>

                     <artifactId>spring-jdbc</artifactId>

                     <version>${spring.jdbc.version}</version>

              </dependency>

              <dependency>

                     <groupId>commons-dbcp</groupId>

                     <artifactId>commons-dbcp</artifactId>

                     <version>${commons.version}</version>

              </dependency>

              <dependency>

                     <groupId>org.springframework</groupId>

                     <artifactId>spring-oxm</artifactId>

                     <version>${spring.oxm.version}</version>

              </dependency>

              <dependency>

                     <groupId>junit</groupId>

                     <artifactId>junit</artifactId>

                     <version>3.8.1</version>

                     <scope>test</scope>

              </dependency>

              <dependency>

                     <groupId>org.springframework.batch</groupId>

                     <artifactId>spring-batch-admin-manager</artifactId>

                     <version>${spring.batch.admin}</version>

                     <exclusions>

                           <exclusion>

                                  <groupId>org.springframework.batch</groupId>

                                  <artifactId>spring-context-support</artifactId>

                           </exclusion>

                     </exclusions>

              </dependency>

              <dependency>

                     <groupId>org.springframework.batch</groupId>

                     <artifactId>spring-batch-admin-resources</artifactId>

                     <version>${spring.batch.admin}</version>

                     <exclusions>

                           <exclusion>

                                  <groupId>org.springframework.batch</groupId>

                                  <artifactId>spring-context-support</artifactId>

                           </exclusion>

                     </exclusions>

              </dependency>



       </dependencies>

       <build>

              <finalName>SpringBatchAdmin</finalName>

              <plugins>

                     <plugin>

                           <groupId>org.apache.maven.plugins</groupId>

                           <artifactId>maven-compiler-plugin</artifactId>

                           <version>2.2</version>

                           <configuration>

                                  <source>1.7</source>

                                  <target>1.7</target>

                           </configuration>

                     </plugin>

              </plugins>

       </build>

</project>

作业-config.xml中

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

       xmlns:batch="http://www.springframework.org/schema/batch" xmlns:util="http://www.springframework.org/schema/util"

       xmlns:task="http://www.springframework.org/schema/task" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xsi:schemaLocation="http://www.springframework.org/schema/batch

       http://www.springframework.org/schema/batch/spring-batch-3.0.xsd

       http://www.springframework.org/schema/beans

       http://www.springframework.org/schema/beans/spring-beans-4.0.xsd

       http://www.springframework.org/schema/util

       http://www.springframework.org/schema/util/spring-util-4.0.xsd">





       <bean

              class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

              <property name="locations">

                     <list>

                           <value>classpath:batch-default.properties

                           </value>

                     </list>

              </property>

              <property name="searchSystemEnvironment" value="true" />

              <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />

              <property name="ignoreUnresolvablePlaceholders" value="true" />

       </bean>





       <job id="myjob" xmlns="http://www.springframework.org/schema/batch"

              restartable="true">

              <step id="myStep" allow-start-if-complete="true">

                     <tasklet>

                           <chunk reader="cvsFileItemReader" writer="itemWriter"

                                  commit-interval="1000" />

                     </tasklet>

              </step>

       </job>



       <bean id="cvsFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">

              <!-- property name="resource" value="${INPUT_FILE_LOCATION}"></property-->

              <property name="resource" value="file:/C:/temp/sampleData.csv"></property>

              <property name="linesToSkip" value="1"></property>

              <property name="lineMapper">

                     <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">

                           <property name="lineTokenizer">

                                  <bean

                                         class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">

                                         <!-- <property name="names" value="${INCOMING_COLUMN_MAPPING}"></property> -->

                                         <property name="names" value="firstName,lastName,city,id"></property>



                                  </bean>

                           </property>

                           <property name="fieldSetMapper">

                                  <bean

                                         class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">

                                         <property name="prototypeBeanName" value="userModel"></property>

                                  </bean>

                           </property>

                     </bean>

              </property>



       </bean>





       <bean id="itemWriter"

              class="org.springframework.batch.item.database.JdbcBatchItemWriter">

              <property name="dataSource" ref="dataSource"></property>

              <property name="sql" value="${INSERT_QUERY}">

              </property>

              <property name="itemSqlParameterSourceProvider">

                     <bean

                            class="org.springframework.batch.item.database.BeanPropertyItemSqlParameterSourceProvider" />

              </property>

       </bean>



       <bean id="userModel" class="com.javacodegeeks.example.util.UserModel"

              scope="prototype" />





</beans>

Contex的-config.xml中

<beans xmlns="http://www.springframework.org/schema/beans"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xmlns:jdbc="http://www.springframework.org/schema/jdbc"      

       xsi:schemaLocation="

              http://www.springframework.org/schema/beans

              http://www.springframework.org/schema/beans/spring-beans-3.2.xsd

              http://www.springframework.org/schema/jdbc

           http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">



       <!-- using in-memory store for batch meta-data -->

       <bean id="jobRepository"

              class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">

              <property name="dataSource" ref="dataSource" />

              <property name="transactionManager" ref="transactionManager" />

              <property name="databaseType" value="hsql" />

       </bean>



       <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

              <property name="dataSource" ref="dataSource"></property>     

       </bean>



       <bean id="jobLauncher"

              class="org.springframework.batch.core.launch.support.SimpleJobLauncher">

              <property name="jobRepository" ref="jobRepository" />

       </bean>



       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"

              lazy-init="true" destroy-method="close">

              <property name="driverClassName" value="org.hsqldb.jdbcDriver" />

              <property name="url"

                     value="jdbc:hsqldb:file:src/main/resources/hsqldb/batchcore.db;shutdown=true;" />       

              <property name="username" value="sa" />

              <property name="password" value="" />

       </bean>


</beans>

Project Tree

****编辑:

我正在阅读Deploying two Spring batch applications in same cluster in a single Weblogic Domain?,它解释了如何在Weblogic中运行两个Spring Batch Admin。 我可以看到这个人正面临着同样的问题。之后我创建了另一个Spring Batch Admin并部署到我的本地Websphere Liberty Profile然后我得到了与我在大型机中提取的完全相同的错误。

首先它很高兴因为我认为我终于找到了问题和解决方案。

我通过添加/META-INF/spring/batch/override/jmx-context.xml修复了我的本地websphere:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:int-jmx="http://www.springframework.org/schema/integration/jmx" xmlns:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="http://www.springframework.org/schema/integration/jmx http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd

    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd

    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">



    <int-jmx:mbean-export id="integrationMBeanExporter" default-domain="SpringBatchAdmin" server="mbeanServer" />

    <context:mbean-export default-domain="SpringBatchAdmin" server="mbeanServer" />

</beans>

这是个好消息,直到我在大型机上运行的Websphere 8.5 ND中尝试了相同的方法。完全相同的问题仍然存在。拜托,我正在寻找其他任何我至少可以尝试的东西。

1 个答案:

答案 0 :(得分:0)

有同样的问题。

我在使用spring集成的同一台机器上进行虚拟托管。一旦部署了测试系统,一切都很好。过了一会儿,我部署了prod系统,一切都出了问题。

我在Application.class中指定了以下内容:

@EnableIntegrationMBeanExport(defaultDomain =&#34; $ {managed.domain}&#34;)

并在application.properties文件中我定义了managed.domain的名称。

我在这里找到的解决方案:

Tutorial