使用DeltaSpike Security时ClassCastException?

时间:2013-10-14 17:31:14

标签: java exception java-ee cdi deltaspike

我已经编写了一个简单的Web应用程序来使用Apache Deltaspike 0.5,但遇到了问题。该应用程序是一个简单的JavaEE 6应用程序,作为JBoss EAP 6.1上的EAR的一部分进行部署。我在我的beans.xml文件中声明了Apache Deltaspike Security模块拦截器,但是当我部署我的应用程序时,我看到以下异常:

[0m[0m12:41:52,798 INFO  [org.apache.deltaspike.core.util.ClassDeactivationUtils] (MSC service thread 1-2) class: org.apache.deltaspike.jsf.impl.config.view.ViewConfigExtension activated=true
[0m[31m12:41:52,806 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."MyTestApp.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."MyTestApp.ear".WeldStartService: Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]
Caused by: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
Exception 0 :
javax.enterprise.event.ObserverException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at java.lang.Class.newInstance0(Class.java:372)
    at java.lang.Class.newInstance(Class.java:325)
    at org.jboss.weld.util.reflection.SecureReflections$16.work(SecureReflections.java:344)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInstantiation(SecureReflectionAccess.java:173)
    at org.jboss.weld.util.reflection.SecureReflections.newInstance(SecureReflections.java:341)
    at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:33)
    at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:73)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:162)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:245)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:233)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:213)
    at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:75)
    at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:46)
    at org.jboss.weld.bootstrap.events.BeforeBeanDiscoveryImpl.fire(BeforeBeanDiscoveryImpl.java:46)
    at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:335)
    at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:62)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.util.ServiceConfigurationError: org.apache.deltaspike.core.spi.config.ConfigSourceProvider: Provider org.apache.deltaspike.core.impl.config.DefaultConfigSourceProvider could not be instantiated: java.lang.ClassCastException: Cannot cast org.apache.deltaspike.core.impl.config.DefaultConfigSourceProvider to org.apache.deltaspike.core.spi.config.ConfigSourceProvider
    at java.util.ServiceLoader.fail(ServiceLoader.java:224)
    at java.util.ServiceLoader.access$100(ServiceLoader.java:181)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:370)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:438)
    at org.apache.deltaspike.core.util.ServiceUtils.loadServiceImplementations(ServiceUtils.java:53)
    at org.apache.deltaspike.core.api.config.ConfigResolver.resolveConfigSources(ConfigResolver.java:374)
    at org.apache.deltaspike.core.api.config.ConfigResolver.getConfigSources(ConfigResolver.java:353)
    at org.apache.deltaspike.core.api.config.ConfigResolver.getAllPropertyValues(ConfigResolver.java:306)
    at org.apache.deltaspike.core.util.ClassDeactivationUtils.initConfiguredClassDeactivators(ClassDeactivationUtils.java:152)
    at org.apache.deltaspike.core.util.ClassDeactivationUtils.getClassDeactivators(ClassDeactivationUtils.java:143)
    at org.apache.deltaspike.core.util.ClassDeactivationUtils.initDeactivatableCacheFor(ClassDeactivationUtils.java:88)
    at org.apache.deltaspike.core.util.ClassDeactivationUtils.isActivated(ClassDeactivationUtils.java:73)
    at org.apache.deltaspike.core.impl.config.ConfigurationExtension.init(ConfigurationExtension.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
    at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
    at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)
    at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
    ... 13 more
Caused by: java.lang.ClassCastException: Cannot cast org.apache.deltaspike.core.impl.config.DefaultConfigSourceProvider to org.apache.deltaspike.core.spi.config.ConfigSourceProvider
    at java.lang.Class.cast(Class.java:3005)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:362)
    ... 34 more

    at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:48)
    at org.jboss.weld.bootstrap.events.BeforeBeanDiscoveryImpl.fire(BeforeBeanDiscoveryImpl.java:46)
    at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:335)
    at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:62)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
    ... 3 more

[0m[0m12:41:52,817 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.unit."MyTestApp.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."MyTestApp.ear".WeldStartService: Failed to start service

我用Google搜索过,但找不到类似的错误。该应用程序本身基于我在PicketLink 2.5.1发行版中找到的一个简单的示例应用程序,因此它并不像我正在做任何非常复杂的事情。知道是什么导致了这个或我可以开始寻找答案吗?

1 个答案:

答案 0 :(得分:1)

添加我的评论作为答案

这是教科书类加载器错误。您可以在类路径中多次使用相同的jar,或者您的应用程序至少有两个类加载器,每个类加载一个类的不同副本