›
› 分享
Unable to create a KernelInitializer based on the specified KernelConfig问题解决办法
放大字体
缩小字体
有一段时间jboss启动出现如下的问题:
20:59:31,843 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
--- MBeans waiting for other MBeans ---
ObjectName: jboss.beans:service=JBossBeanDeployment,name='jbossws.sar#jbossws.beans' State: FAILED
Reason: org.jboss.deployment.DeploymentException: Unable to boot kernel; - nested throwable: (java.lang.RuntimeException: Unable to create a KernelInitializer based on the specified KernelConfig)
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM --- ObjectName: jboss.beans:service=JBossBeanDeployment,name='jbossws.sar#jbossws.beans' State: FAILED
Reason: org.jboss.deployment.DeploymentException: Unable to boot kernel; - nested throwable: (java.lang.RuntimeException: Unable to create a KernelInitializer based on the specified KernelConfig)
想想是安装的aop后出现的问题,并且后来安装jbpm也出现这个问题
ObjectName: jboss.beans:service=JBossBeanDeployment,name='jbpm.deployer#jbpm.beans' State: FAILED
Reason: org.jboss.deployment.DeploymentException: Unable to boot kernel; - nested throwable: (java.lang.RuntimeException: Unable to create a KernelInitializer based on the specified KernelConfig)
而且看异常都有:
Caused by: java.lang.NoSuchMethodError: org.jboss.beans.info.spi.BeanInfoFactory.getBeanInfo(Ljava/lang/ClassLoader;Lorg/jboss/classadapter/spi/ClassAdapter;)Lorg/jboss/beans/info/spi/BeanInfo; at org.jboss.kernel.plugins.config.AbstractKernelConfig.getBeanInfo(AbstractKernelConfig.java:60) at org.jboss.kernel.plugins.config.property.PropertyKernelConfig.getImplementation(PropertyKernelConfig.java:155) at org.jboss.kernel.plugins.config.property.PropertyKernelConfig.createKernelInitializer(PropertyKernelConfig.java:123) at org.jboss.kernel.KernelFactory.createKernelInitializer(KernelFactory.java:150) ... 101 more
而org.jboss.beans.info.spi.BeanInfoFactory.getBeanInfo在是jboss-reflect.jar包中,该包是在jboss-aop-jdk50.deployer里面,想想自己安装过aop,版本是2.0.0.GA,把之前jboss自带的aop覆盖了,会不会是这个问题呢?
后来在jboss的问题报告里果然看到一条该问题的报告:https://jira.jboss.org/jira/browse/JBAOP-693
其中说了Fix Version/s: 2.1.0.CR1, 2.0.1.GA
所以只好重新下载aop 2.0.1GA, 下载下来后BeanInfoFactory仍然没有getBeanInfo(Ljava/lang/ClassLoader;Lorg/jboss/classadapter/spi/ClassAdapter;)Lorg/jboss/beans/info/spi/BeanInfo方法,只是多了个包jarjar.jar。对于jarjar不了解,大概的印象是用来解决包与包之间的依赖关系发生的冲突(比如A.jar包使用B.jar包的1.0版本,但同时C又要使用B.jar包的2.o版本,B.jar在系统中只能安装一个,要么是1.0,要么是2.0,jarjar通过重命名类,字节码修改等等来解决问题)。我们这里遇到的问题就如同jboss的问题报告中说的:
AS 4.2.x jboss-beans.deployer bundles MC 1.0.x, we have classes from MC 2.0.x in the aop deployer. The clashing classnames causes problems on startup on AS 4.2.x
关于jarjar的信息请看这里:http://code.google.com/p/jarjar/
所以安装aop的时候,最好使用jboss-XX-install/jboss-aop-jdk50.deployer下面的ant脚本,并不是像网上大多数文章所说的,直接拷贝文件那么简单, 设置好jboss.properties,运行ant install就可以了,它会拷贝该拷贝的,删除该删除的,使用jarjar修改该修改的jar包。运行脚本后的文件如下: 
直接拷贝文件肯定是不行的 记得修改META-INF中的jboss-service.xml文件,允许动态织入:<attribute name="EnableLoadtimeWeaving">true</attribute>