WELD-001519为抽象类'xxx'创建了一个InjectionTarget实现。不可能生成这种类型的实例

时间:2013-12-04 10:11:25

标签: jsf glassfish cdi omnifaces weld

我正在以下环境中运行应用程序。

  • GlassFish Server 4.0
  • Mojarra 2.2.4
  • PrimeFaces 4.0 final
  • PrimeFaces Extension 1.1.0
  • OmniFaces 1.6.3

添加OmniFaces后,服务器终端上会出现以下警告。

WARNING:   WELD-001519 An InjectionTarget implementation is created for an abstract class org.omnifaces.eventlistener.DefaultServletContextListener. It will not be possible to produce instances of this type!    
WARNING:   WELD-001519 An InjectionTarget implementation is created for an abstract class org.omnifaces.filter.HttpFilter. It will not be possible to produce instances of this type!

//WARNING:   Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
//WARNING:   Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled
INFO:   Initializing Mojarra 2.2.4 ( 20131003-1354 https://svn.java.net/svn/mojarra~svn/tags/2.2.4@12574) for context '/Project-war'

WARNING:   WELD-001529 An InjectionTarget implementation is created for a class org.omnifaces.application.OmniApplicationFactory which does not have any appropriate constructor.
WARNING:   WELD-001529 An InjectionTarget implementation is created for a class org.primefaces.context.PrimeFacesContextFactory which does not have any appropriate constructor.
WARNING:   WELD-001529 An InjectionTarget implementation is created for a class org.omnifaces.context.OmniPartialViewContextFactory which does not have any appropriate constructor.
WARNING:   WELD-001529 An InjectionTarget implementation is created for a class org.primefaces.context.PrimePartialViewContextFactory which does not have any appropriate constructor.

INFO:   Running on PrimeFaces 4.0
INFO:   Running on PrimeFaces Extensions null
INFO:   Using OmniFaces version null

INFO:   Loading application [Project#Project-war.war] at [Project-war]
INFO:   Project was successfully deployed in 22,734 milliseconds.

在给定环境中OmniFaces有任何问题吗?

1 个答案:

答案 0 :(得分:5)

不,这些只是警告,而不是错误。 Weld无法为没有默认构造函数的抽象类或类创建注入目标。注射目标需要能够毫无困难地进行Class.forName(className).newInstance()

记录中的这种干扰已经报告为Weld issue 1547,因此,自Weld 2.1.1 / 2.2.0起,警告级别降低到DEBUG级别。

注意到应该存在另一个错误,很可能与GlassFish类加载有关。 OmniFaces有一个VetoAnnotatedTypeExtension,它应该排除所有那些OmniFaces类被不必要地扫描为CDI托管bean。当在Tomcat 7和JBoss 6/7/8中使用Weld时,这可以正常工作。即对于OmniFaces类,这些警告根本没有出现。