抽象类中的抽象方法使用CDI" Inject"抛出焊缝异常

时间:2016-04-14 13:44:53

标签: xml maven java-ee jboss cdi

我有一个相对普通的类层次结构,其父类可以获得注入CDI的实用程序类。阅读Java EE文档,我知道必须在类中注释一个@Decorator和委托,即注入的类是@Delegate,如下所示:

@Getter
@Setter
@Decorator
public abstract class BetGroup {

    public abstract List<OBCouponDTO> buildDTO();

    @Inject
    @Delegate
    OBInstanceFactory obInstanceFactory;

//..

}

当我启动服务器(Wildfly 10)时,它会抱怨所包含的抽象方法签名,即buildDTO()。

子类只是在它们的实现方法中提供了trival处理。无论如何,它输出抽象方法应该由给定的装饰类型声明。

将异常消息(即&#34; WELD-000090:装饰者......&#34;)复制/粘贴到谷歌中打开在线Weld文档第10章,其中解释了cdi注入如何在抽象类中工作,但不是当抽象类包含声明为abstract的方法(=我面临的挑战)时,可以做什么。

任何人都知道我在这里做错了什么?

15:11:45,177 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."obrmsexposer-1.0-SNAPSHOT.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."obrmsexposer-1.0-SNAPSHOT.war".WeldStartService: Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-000090: A decorator has an abstract method that is not declared by any decorated type
  Method: [EnhancedAnnotatedMethodImpl] public abstract dk.danskespil.domain.BetGroup.buildDTO()
    at dk.danskespil.domain.BetGroup.buildDTO(BetGroup.java:0)
  StackTrace:
    at org.jboss.weld.util.Decorators.checkAbstractMethods(Decorators.java:174)
    at org.jboss.weld.injection.producer.DecoratorInjectionTarget.checkAbstractMethods(DecoratorInjectionTarget.java:134)
    at org.jboss.weld.injection.producer.DecoratorInjectionTarget.<init>(DecoratorInjectionTarget.java:66)
    at org.jboss.weld.manager.InjectionTargetFactoryImpl.chooseInjectionTarget(InjectionTargetFactoryImpl.java:98)
    at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:86)
    at org.jboss.weld.bean.ManagedBean.<init>(ManagedBean.java:100)
    at org.jboss.weld.bean.DecoratorImpl.<init>(DecoratorImpl.java:61)
    at org.jboss.weld.bean.DecoratorImpl.of(DecoratorImpl.java:50)
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.createDecorator(AbstractBeanDeployer.java:274)
    at org.jboss.weld.bootstrap.BeanDeployer.createClassBean(BeanDeployer.java:221)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:78)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:75)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)

其他相关信息:

在Windows 7上进行测试 Wildfly 10.0.0从Idea 14.0.4开始 jdk1.8.0_40

http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">              dk.danskespil.domain.BetGroup     

0 个答案:

没有答案