我希望在 JBoss Application Server 7.1 中运行 Apache Karaf 运行时。理论上它可以工作,但是按照这些步骤,它无法找到一些依赖项并且控制台不是完全可操作的。
基本上,前面提到的步骤修改了standalone.xml
配置文件,添加了一个 OSGi 子系统:
<subsystem xmlns="urn:jboss:domain:osgi:1.2" activation="eager">
<properties>
<property name="org.osgi.framework.startlevel.beginning">
1
</property>
<property name="org.osgi.framework.system.packages.extra">
org.apache.karaf.jaas.boot;version=2.2.9
</property>
</properties>
<capabilities>
<capability name="javax.servlet.api:v25"/>
<capability name="javax.transaction.api"/>
<capability name="org.apache.felix.log" startlevel="1"/>
<capability name="org.jboss.osgi.logging" startlevel="1"/>
<capability name="org.apache.felix.configadmin" startlevel="1"/>
<capability name="org.jboss.as.osgi.configadmin" startlevel="1"/>
<capability name="org.apache.servicemix.bundles:org.apache.servicemix.bundles.asm:3.3.1_1" startlevel="1"/>
<capability name="org.apache.aries:org.apache.aries.util:0.3.1" startlevel="1"/>
<capability name="org.apache.aries.proxy:org.apache.aries.proxy:0.3.1" startlevel="1"/>
<capability name="org.apache.aries.blueprint:org.apache.aries.blueprint:0.3.2" startlevel="1"/>
<capability name="org.apache.karaf.jaas:org.apache.karaf.jaas.config:2.2.9" startlevel="1"/>
<capability name="org.apache.karaf.jaas:org.apache.karaf.jaas.modules:2.2.9" startlevel="1"/>
<capability name="org.apache.karaf.shell:org.apache.karaf.shell.console:2.2.9" startlevel="1"/>
<capability name="org.apache.karaf.shell:org.apache.karaf.shell.commands:2.2.9" startlevel="1"/>
<capability name="org.apache.karaf.shell:org.apache.karaf.shell.osgi:2.2.9" startlevel="1"/>
<capability name="org.apache.mina:mina-core:2.0.1" startlevel="1"/>
<capability name="org.apache.sshd:sshd-core:0.7.0" startlevel="1"/>
<capability name="org.apache.karaf.shell:org.apache.karaf.shell.ssh:2.2.9" startlevel="1"/>
</capabilities>
</subsystem>
但 JBoss 日志显示以下异常:
14:30:29,220 ERROR [org.apache.aries.blueprint.container.BlueprintContainerImpl] (Blueprint Extender: 3) Unable to start blueprint container for bundle org.apache.karaf.jaas.config: org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to intialize bean proxyLoginModuleInitializer
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:640)
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:726)
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:219)
at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:147)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:631)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:337)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:230)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) [rt.jar:1.6.0_39]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_39]
at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_39]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) [rt.jar:1.6.0_39]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206) [rt.jar:1.6.0_39]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [rt.jar:1.6.0_39]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [rt.jar:1.6.0_39]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_39]
Caused by: java.lang.NoClassDefFoundError: org/apache/karaf/jaas/boot/ProxyLoginModule
at org.apache.karaf.jaas.config.impl.ProxyLoginModuleInitializer.init(ProxyLoginModuleInitializer.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_39]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_39]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_39]
at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_39]
at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)
at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:638)
... 15 more
Caused by: java.lang.ClassNotFoundException: org.apache.karaf.jaas.boot.ProxyLoginModule from [Module "deployment.org.apache.karaf.jaas.config:2.2.9" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 23 more
14:30:29,455 WARN [org.jboss.modules] (Blueprint Extender: 1) Failed to define class org.apache.karaf.shell.osgi.SpringStateListenerFactory$SpringApplicationListener in Module "deployment.org.apache.karaf.shell.osgi:2.2.9" from Service Module Loader: java.lang.LinkageError: Failed to link org/apache/karaf/shell/osgi/SpringStateListenerFactory$SpringApplicationListener (Module "deployment.org.apache.karaf.shell.osgi:2.2.9" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)
at org.jboss.modules.FilteredLocalLoader.loadClassLocal(FilteredLocalLoader.java:46)
at org.jboss.modules.Module.loadModuleClass(Module.java:517)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at org.apache.karaf.shell.osgi.SpringStateListenerFactory.createListener(SpringStateListenerFactory.java:69)
at org.apache.karaf.shell.osgi.SpringStateListenerFactory.getListener(SpringStateListenerFactory.java:60)
at org.apache.karaf.shell.osgi.SpringStateListenerFactory.init(SpringStateListenerFactory.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_39]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_39]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_39]
at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_39]
at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:225)
at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:638)
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:726)
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:219)
at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:147)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:631)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:337)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:230)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) [rt.jar:1.6.0_39]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_39]
at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_39]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) [rt.jar:1.6.0_39]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206) [rt.jar:1.6.0_39]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [rt.jar:1.6.0_39]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [rt.jar:1.6.0_39]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_39]
Caused by: java.lang.NoClassDefFoundError: org/springframework/osgi/context/event/OsgiBundleApplicationContextListener
at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.6.0_39]
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) [rt.jar:1.6.0_39]
at java.lang.ClassLoader.defineClass(ClassLoader.java:615) [rt.jar:1.6.0_39]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [rt.jar:1.6.0_39]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)
... 34 more
Caused by: java.lang.ClassNotFoundException: org.springframework.osgi.context.event.OsgiBundleApplicationContextListener from [Module "deployment.org.apache.karaf.shell.osgi:2.2.9" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 40 more
14:30:29,518 INFO [org.apache.sshd.common.util.SecurityUtils] (Blueprint Extender: 3) BouncyCastle not registered, using the default JCE provider
然后连接到 Karaf 控制台,得到一个错误的配置。获取 OSGi 包列表:
START LEVEL 1 , List Threshold: -1
ID State Blueprint Level Name
[ 0] [Active ] [ ] [ 0] system.bundle (0.0.0)
[ 2] [Active ] [ ] [ 1] JBossOSGi Http API (1.0.5)
[ 4] [Active ] [ ] [ 1] Apache Felix Log Service (1.0.0)
[ 8] [Active ] [ ] [ 1] Apache ServiceMix :: Bundles :: asm (3.3.1.1)
[ 10] [Active ] [ ] [ 1] Apache Aries Proxy Bundle (0.3.1)
[ 14] [Active ] [Created ] [ 1] Apache Karaf :: Shell :: Console (2.2.9)
[ 6] [Active ] [ ] [ 1] Apache Felix Configuration Admin Service (1.2.8)
[ 16] [Active ] [Created ] [ 1] Apache Karaf :: Shell :: OSGi Commands (2.2.9)
[ 12] [Active ] [Failure ] [ 1] Apache Karaf :: JAAS :: Config (2.2.9)
[ 18] [Active ] [ ] [ 1] Apache Mina SSHD :: Core (0.7.0)
[ 1] [Active ] [ ] [ 1] osgi.enterprise (4.2.0.201003190513)
[ 3] [Active ] [ ] [ 1] javax.transaction.api
[ 5] [Active ] [ ] [ 1] JBossOSGi Logging (1.0.0)
[ 7] [Active ] [ ] [ 1] JBoss Application Server: OSGi ConfigurationAdmin (7.1.1.Final)
[ 19] [Active ] [Created ] [ 1] Apache Karaf :: Shell :: SSH (2.2.9)
[ 17] [Active ] [ ] [ 1] Apache MINA Core (2.0.1)
[ 9] [Active ] [ ] [ 1] Apache Aries Util (0.3.1)
[ 11] [Active ] [Created ] [ 1] Apache Aries Blueprint Bundle (0.3.2)
[ 15] [Active ] [Created ] [ 1] Apache Karaf :: Shell :: Various Commands (2.2.9)
[ 13] [Active ] [GracePeriod ] [ 1] Apache Karaf :: JAAS :: Modules (2.2.9)
如何获得配置良好的 Karaf 控制台?我尝试将所有依赖项添加到子系统中,但这是一场噩梦。