带 Jetty 6.1.26 的接缝边门,Weld 1.1.1

发布于 2024-11-06 05:41:14 字数 6023 浏览 3 评论 0原文

我正在尝试使用嵌入式 Jetty 6.1.26、Weld 1.1.1、seam-wicket 3.0.0、Wicket 1.4.17

修复了阻止 BeanManager 被发现的 seam-wicket bug(JNDI 不起作用,需要拉取)来自 ServletContext - 我为此使用了某人的类)。

  SLF4J: Class path contains multiple SLF4J bindings.
  SLF4J: Found binding in [jar:file:/mnt/ssd1/data/.m2/repository/org/jboss/weld/servlet/weld-servlet/1.1.1.Final/weld-servlet-1.1.1.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: Found binding in [jar:file:/mnt/ssd1/data/.m2/repository/org/slf4j/slf4j-log4j12/1.5.11/slf4j-log4j12-1.5.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  May 08, 2011 9:16:11 AM org.mortbay.log.Slf4jLog info
  INFO: Logging to org.slf4j.impl.JDK14LoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
  May 08, 2011 9:16:11 AM org.jboss.jawabot.web.RunInJetty run
  INFO: Static files are in:
          /mnt/ssd1/_projekty/GoogleCode-ondrazizka/svn-whole/trunk/bots/JawaBot/branches/2.0/web/workdir/../src/main/java/org/jboss/jawabot/web/files
     == /mnt/ssd1/_projekty/GoogleCode-ondrazizka/svn-whole/trunk/bots/JawaBot/branches/2.0/web/src/main/java/org/jboss/jawabot/web/files
    @@@@@@@ _: org.mortbay.naming.NamingContext
    @@@@@@@ env: org.mortbay.naming.NamingContext
    @@@@@@@ BeanManager: javax.naming.Reference
    @@@@@@@ org.mortbay.jetty.servlet.Context@15d3ddab{_,null}: org.mortbay.naming.NamingContext
  May 08, 2011 9:16:11 AM org.jboss.weld.bootstrap.WeldBootstrap <clinit>
  INFO: WELD-000900 1.1.1 (Final)
  May 08, 2011 9:16:11 AM org.mortbay.log.Slf4jLog info
  INFO: jetty-6.1.26
  May 08, 2011 9:16:12 AM org.jboss.weld.bootstrap.WeldBootstrap startContainer
  INFO: WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
  09:16:12.490 INFO [main] org.jboss.seam.solder.Version Seam Solder 3.0.0.Final (build id: 3.0.0.Final)
  May 08, 2011 9:16:12 AM org.jboss.weld.environment.jetty.AbstractJettyPre72Container initialize
  INFO: Jetty detected, JSR-299 injection will be available in Servlets and Filters. Injection into Listeners is not supported.
  09:16:12.972 INFO [main] org.jboss.seam.solder.core.CoreExtension Preventing class org.jboss.seam.solder.core.VersionLoggerUtil from being installed as bean due to @Veto annotation
  09:16:13.233 INFO [main] org.jboss.seam.solder.core.CoreExtension Preventing class org.jboss.seam.solder.resourceLoader.ResourceProvider from being installed as bean due to @Veto annotation
  May 08, 2011 9:16:13 AM org.jboss.interceptor.util.InterceptionTypeRegistry <clinit>
  WARNING: Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
  May 08, 2011 9:16:13 AM org.jboss.interceptor.util.InterceptionTypeRegistry <clinit>
  WARNING: Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled
  09:16:13.632 DEBUG [main] org.jboss.seam.solder.bean.defaultbean.DefaultBeanExtension Installing default managed bean Default Bean with types [class java.lang.Object, class javax.el.VariableMapper] and qualifiers [@org.jboss.seam.solder.el.Mapper()]
  09:16:13.635 DEBUG [main] org.jboss.seam.solder.bean.defaultbean.DefaultBeanExtension Installing default managed bean Default Bean with types [class java.lang.Object, class javax.el.FunctionMapper] and qualifiers [@org.jboss.seam.solder.el.Mapper()]
  ---- Wicket init() ----

然后我尝试了 RandomNumber 示例
http://docs.jboss.org/ weld/reference/1.1.0.Final/en-US/html_single/#d0e948

  @ApplicationScoped
  public class RandomNumberGenerator {
     private Random random = new Random(System.currentTimeMillis());
     @Produces @Named int getRandomNumber() {
        return random.nextInt(100);
     }
  }// class

并尝试在 Wicket 组件中 @Inject 它

  public class CdiTestPanel extends Panel
  {
     //@Inject String user;
     //@Inject Logger log;
     @Inject int randomNumber;
     ...
  }

没有任何效果,我得到了每次都是这样:

  Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [int] with qualifiers [@Default] at injection point [[field] @Inject org.jboss.jawabot.web._co.ReservationListPanel.randomNumber]
   at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:270)
   at org.jboss.weld.bootstrap.Validator.validateInjectionTarget(Validator.java:299)
   at org.jboss.weld.manager.InjectionTargetValidator.addInjectionTarget(InjectionTargetValidator.java:34)
   at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:1052)
   at org.jboss.seam.wicket.util.NonContextual.<init>(NonContextual.java:56)
   at org.jboss.seam.wicket.util.NonContextual.of(NonContextual.java:31)
   at org.jboss.seam.wicket.SeamComponentInstantiationListener.onInstantiation(SeamComponentInstantiationListener.java:28)
   at org.apache.wicket.Application.notifyComponentInstantiationListeners(Application.java:1093)
   at org.apache.wicket.Component.<init>(Component.java:923)
   at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:113)
   at org.apache.wicket.markup.html.WebMarkupContainer.<init>(WebMarkupContainer.java:49)
   at org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup.<init>(WebMarkupContainerWithAssociatedMarkup.java:51)
   at org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup.<init>(WebMarkupContainerWithAssociatedMarkup.java:43)
   at org.apache.wicket.markup.html.panel.Panel.<init>(Panel.java:76)
   at org.jboss.jawabot.web._co.ReservationListPanel.<init>(ReservationListPanel.java:51)
   at org.jboss.jawabot.web._pg.TakePage.<init>(TakePage.java:94)
   ... 31 more

那么,我如何让 CDI 发挥作用? 感谢您的任何想法。

I am trying seam-wicket with embedded Jetty 6.1.26, Weld 1.1.1, seam-wicket 3.0.0, Wicket 1.4.17

After I fixed seam-wicket bug which prevents BeanManager being found (JNDI does not work, needs to pull from ServletContext - I used someone's classes for that).

  SLF4J: Class path contains multiple SLF4J bindings.
  SLF4J: Found binding in [jar:file:/mnt/ssd1/data/.m2/repository/org/jboss/weld/servlet/weld-servlet/1.1.1.Final/weld-servlet-1.1.1.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: Found binding in [jar:file:/mnt/ssd1/data/.m2/repository/org/slf4j/slf4j-log4j12/1.5.11/slf4j-log4j12-1.5.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  May 08, 2011 9:16:11 AM org.mortbay.log.Slf4jLog info
  INFO: Logging to org.slf4j.impl.JDK14LoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
  May 08, 2011 9:16:11 AM org.jboss.jawabot.web.RunInJetty run
  INFO: Static files are in:
          /mnt/ssd1/_projekty/GoogleCode-ondrazizka/svn-whole/trunk/bots/JawaBot/branches/2.0/web/workdir/../src/main/java/org/jboss/jawabot/web/files
     == /mnt/ssd1/_projekty/GoogleCode-ondrazizka/svn-whole/trunk/bots/JawaBot/branches/2.0/web/src/main/java/org/jboss/jawabot/web/files
    @@@@@@@ _: org.mortbay.naming.NamingContext
    @@@@@@@ env: org.mortbay.naming.NamingContext
    @@@@@@@ BeanManager: javax.naming.Reference
    @@@@@@@ org.mortbay.jetty.servlet.Context@15d3ddab{_,null}: org.mortbay.naming.NamingContext
  May 08, 2011 9:16:11 AM org.jboss.weld.bootstrap.WeldBootstrap <clinit>
  INFO: WELD-000900 1.1.1 (Final)
  May 08, 2011 9:16:11 AM org.mortbay.log.Slf4jLog info
  INFO: jetty-6.1.26
  May 08, 2011 9:16:12 AM org.jboss.weld.bootstrap.WeldBootstrap startContainer
  INFO: WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
  09:16:12.490 INFO [main] org.jboss.seam.solder.Version Seam Solder 3.0.0.Final (build id: 3.0.0.Final)
  May 08, 2011 9:16:12 AM org.jboss.weld.environment.jetty.AbstractJettyPre72Container initialize
  INFO: Jetty detected, JSR-299 injection will be available in Servlets and Filters. Injection into Listeners is not supported.
  09:16:12.972 INFO [main] org.jboss.seam.solder.core.CoreExtension Preventing class org.jboss.seam.solder.core.VersionLoggerUtil from being installed as bean due to @Veto annotation
  09:16:13.233 INFO [main] org.jboss.seam.solder.core.CoreExtension Preventing class org.jboss.seam.solder.resourceLoader.ResourceProvider from being installed as bean due to @Veto annotation
  May 08, 2011 9:16:13 AM org.jboss.interceptor.util.InterceptionTypeRegistry <clinit>
  WARNING: Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
  May 08, 2011 9:16:13 AM org.jboss.interceptor.util.InterceptionTypeRegistry <clinit>
  WARNING: Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled
  09:16:13.632 DEBUG [main] org.jboss.seam.solder.bean.defaultbean.DefaultBeanExtension Installing default managed bean Default Bean with types [class java.lang.Object, class javax.el.VariableMapper] and qualifiers [@org.jboss.seam.solder.el.Mapper()]
  09:16:13.635 DEBUG [main] org.jboss.seam.solder.bean.defaultbean.DefaultBeanExtension Installing default managed bean Default Bean with types [class java.lang.Object, class javax.el.FunctionMapper] and qualifiers [@org.jboss.seam.solder.el.Mapper()]
  ---- Wicket init() ----

Then I tried the RandomNumber example
http://docs.jboss.org/weld/reference/1.1.0.Final/en-US/html_single/#d0e948

  @ApplicationScoped
  public class RandomNumberGenerator {
     private Random random = new Random(System.currentTimeMillis());
     @Produces @Named int getRandomNumber() {
        return random.nextInt(100);
     }
  }// class

And tried to @Inject it in Wicket component

  public class CdiTestPanel extends Panel
  {
     //@Inject String user;
     //@Inject Logger log;
     @Inject int randomNumber;
     ...
  }

Nothing worked, I got this every time:

  Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [int] with qualifiers [@Default] at injection point [[field] @Inject org.jboss.jawabot.web._co.ReservationListPanel.randomNumber]
   at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:270)
   at org.jboss.weld.bootstrap.Validator.validateInjectionTarget(Validator.java:299)
   at org.jboss.weld.manager.InjectionTargetValidator.addInjectionTarget(InjectionTargetValidator.java:34)
   at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:1052)
   at org.jboss.seam.wicket.util.NonContextual.<init>(NonContextual.java:56)
   at org.jboss.seam.wicket.util.NonContextual.of(NonContextual.java:31)
   at org.jboss.seam.wicket.SeamComponentInstantiationListener.onInstantiation(SeamComponentInstantiationListener.java:28)
   at org.apache.wicket.Application.notifyComponentInstantiationListeners(Application.java:1093)
   at org.apache.wicket.Component.<init>(Component.java:923)
   at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:113)
   at org.apache.wicket.markup.html.WebMarkupContainer.<init>(WebMarkupContainer.java:49)
   at org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup.<init>(WebMarkupContainerWithAssociatedMarkup.java:51)
   at org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup.<init>(WebMarkupContainerWithAssociatedMarkup.java:43)
   at org.apache.wicket.markup.html.panel.Panel.<init>(Panel.java:76)
   at org.jboss.jawabot.web._co.ReservationListPanel.<init>(ReservationListPanel.java:51)
   at org.jboss.jawabot.web._pg.TakePage.<init>(TakePage.java:94)
   ... 31 more

So, how do I get CDI working?
Thanks for any ideas.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文