2016-04-07 80 views
0

雖然我創建的調度程序,我發現它不可能在其中使用CDI注入,經過一些研究,我發現了一個有趣的解決方案,通過使用API​​ deltaSpike的調度程序模塊。集成Apache deltaSpike調度程序模塊

我跟着官方文檔中描述的所有步驟所以我說我的pom.xml

<dependencyManagement> 
    <dependencies> 

     <dependency> 
      <groupId>org.apache.deltaspike.distribution</groupId> 
      <artifactId>distributions-bom</artifactId> 
      <version>${deltaspike.version}</version> 
      <type>pom</type> 
      <scope>import</scope> 
     </dependency> 
    </dependencies> 
</dependencyManagement> 

    <dependency> 
     <groupId>org.quartz-scheduler</groupId> 
     <artifactId>quartz</artifactId> 
     <version>2.2.1</version> 
    </dependency> 



    <dependency> 
     <groupId>org.apache.deltaspike.cdictrl</groupId> 
     <artifactId>deltaspike-cdictrl-api</artifactId> 
     <version>${deltaspike.version}</version> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.weld.se</groupId> 
     <artifactId>weld-se</artifactId> 
     <version>2.3.3.Final</version> 
     <scope>runtime</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.deltaspike.cdictrl</groupId> 
     <artifactId>deltaspike-cdictrl-weld</artifactId> 
     <version>${deltaspike.version}</version> 
    </dependency> 




    <dependency> 
     <groupId>org.apache.deltaspike.core</groupId> 
     <artifactId>deltaspike-core-api</artifactId> 
     <version>${deltaspike.version}</version> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.deltaspike.core</groupId> 
     <artifactId>deltaspike-core-impl</artifactId> 
     <version>${deltaspike.version}</version> 
     <scope>runtime</scope> 
    </dependency> 



    <dependency> 
     <groupId>org.apache.deltaspike.modules</groupId> 
     <artifactId>deltaspike-scheduler-module-api</artifactId> 
     <version>${deltaspike.version}</version> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.deltaspike.modules</groupId> 
     <artifactId>deltaspike-scheduler-module-impl</artifactId> 
     <version>${deltaspike.version}</version> 
     <scope>runtime</scope> 
    </dependency> 

但每一次以下depencies一開始我的JBoss服務器時拋出此異常

javax.enterprise.event.ObserverException 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
at java.lang.reflect.Constructor.newInstance(Unknown Source) 
at java.lang.Class.newInstance(Unknown Source) 
at org.jboss.weld.util.reflection.SecureReflections$16.work(SecureReflections.java:343) 
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:340) 
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:241) 
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:229) 
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:207) 
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:322) 
at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:81) 
at org.jboss.as.weld.services.WeldService.start(WeldService.java:76) 
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(Unknown Source) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
at java.lang.Thread.run(Unknown Source) 
    Caused by: java.lang.AbstractMethodError 
at org.apache.deltaspike.core.api.config.ConfigResolver.getAllProperties(ConfigResolver.java:383) 
at org.apache.deltaspike.core.impl.exclude.extension.ExcludeExtension.init(ExcludeExtension.java:98) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264) 
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:260) 
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) 
... 14 more 
"}}}} 

關於我錯過了關於deltaspike配置的例外情況,但是我沒有在stackoverflow或任何其他網站上找到任何東西,請幫助

+0

您使用的是哪種版本的deltaspike以及您要部署哪個容器? –

+0

我使用的deltaSpike版本是1.6.0,我在Jboss 7.1 A.S中部署 – youssef

回答

0

嗯,問題解決了,我對deltaSpike感興趣,因爲我試圖弄清楚如何在CDI上下文中使用Quartz。

經過一番研究,我發現EJB Timer對我來說非常完美,因爲我們使用JBOSS A.S,實際上它是一個ejb Container。