问题标签 [jboss-weld]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
20842 浏览

dependency-injection - 使用 @Inject 将无状态 EJB 注入 CDI Weld ManagedBean(jboss 6 AS 上的 JSF 1.2 EJB 应用程序)

目前我正在尝试将无状态 EJB 注入到 Jboss 6 AS Final 上的 CDI 托管控制器中。控制器在可从 JSF 页面访问的上下文中进行管理。如果我用它注入无状态bean,@EJB它就可以工作。如果我注入无状态 EJB,@Inject我会得到以下异常:

我的控制器:

我的无状态bean:

Bean 的接口使用@Local 进行注解。

如果我尝试调用 myTestManager 我得到以下异常:

WELD-000079 在 JNDI 中找不到 EJB:类 de.crud.org$jboss$weld$bean-jboss$classloader:id="vfs:$$$usr$local$jboss$server$default$deploy$test$耳朵"-SessionBean-TestManagerBean_$$_WeldProxy

多谢。

0 投票
1 回答
12638 浏览

jakarta-ee - 什么是焊接,JSR-299?

我发现很多教程展示了 Weld 代码示例,但不是介绍性概述。

您能否推荐一篇介绍性文章,或回答以下问题:

  • Weld 能为您做什么/给您什么?
  • 它与 Java EE 6 有什么关系?
  • 如何在 Java EE 6 项目中使用它?
  • 如果在 Java EE 6 项目中使用它,它会取代什么(如果有的话)?
0 投票
1 回答
5601 浏览

jsf - CDI ConversationScoped 长时间运行的 Bean 不工作

我在理解 Weld 或 CDI 的对话范围时遇到了一些问题。

在我的 JSF Faclets 页面中,我调用:

豆子:

现在每次我刷新浏览器时,都会开始一个新的对话。这是正确的行为吗?那么为什么谈话总是短暂的呢?不会抛出异常。beans.xml 已创建且为空:

0 投票
3 回答
3101 浏览

cdi - CDI/Weld:书籍或资源推荐

您可以推荐一本现有的或即将出版的关于 CDI/Weld 的书吗?

我正在寻找与Seam in Action在范围和质量上相似的东西,这对 Seam 来说是一个很好的参考,但现在似乎有点过时了。

0 投票
2 回答
6736 浏览

spring - JSF2 managed bean annotation + scope + injection confusion

I would like to achieve this idealism :

  1. To have only 1 implementation for the JSF Bean container, like to use only Spring or Weld but not both. Currently i am using Spring for my backend, so i prefer Spring.
  2. To have only 1 annotation, to choose between @ManagedBean, @Named, @Model
  3. To be able to use all supported scopes, like @RequestScoped, @SessionScoped, @ViewScoped, @FlashScoped, maybe also @ConversationScoped
  4. The JSF Beans could be injected with spring-managed-services (The backend services), perhaps using @Inject or @Autowired

So far i've been finding no best combination to achieve these because as far as i know, please correct me if i am wrong, :

  1. @ManagedBean can not be injected with spring services ?
  2. @Named can be injected with spring services using @Inject, but @Named is using Weld. Can i just use spring to managed the @Named instead of Weld ?
  3. @Named doesnt support @ViewScoped and FlashScope ?

Please share your thoughts and experiences.

Thank you :-)


UPDATE 15 March 2011

Found an interesting page that describes how to replace Jboss Weld with Spring as the JSR 299 CDI implementation. So basically, the question number 2 is answered. Number 1 is also answered indirectly since i can now inject spring services.

But still, the number 3 question remains. I would find very helpful if i can use the @ViewScoped and Flash Scope in the @Named, something like this article. Flash scope implementation has yet to be seen, but the closest one i can get so far is this page.

Hopefully, replacing weld with spring as the jsr 299 implementation will still enable me to use @ConversationScoped.

Gotta test things now, wish me luck :-)


UPDATE 18 MARCH 2011

Successfully make use of Spring 3 instead of weld to do the @Named, @Inject. The important thing is to set the el-resolver in the faces-config.xml.

AFAIK, Spring 3 currently doesnt support CDI yet, so bye2 @ConversationScoped.

For the scoping, i must still use @Scope("request") or @Scope("session"), but if i prefer the @RequestScoped (javax.enterprise.context.RequestScoped) and @SessionScoped, i can make use of the bridge provided from this article.

The Scope("view") for spring from this article works like magic :-)

One problem remain though, how to pass objects between Scope("view")-beans .. Wish me luck !


update

Ahhh .. finally done .. Passing the variables using Flash provided by JSF2 really works like magic. I dont need an 3rd party implementation for that.

So basically, i can do without weld, but with spring, with the common scopes available, including the view scope, dan can pass between beans using the flash object.

One thing missing is the conversation scope, which isnt a major problem to me yet. Hopefully the future spring can support this conversation scope.

Cheers :-)

0 投票
1 回答
1263 浏览

jsf-2 - 如何使带有 CDI 的 Seam3 Solder 在 WebSphere 7 中工作?

我想在带有 JSF 2.0(RI 是 Mojarra 2.0.4)和 CDI 的 WebSphere 7 中使用 Seam Solder 和 Seam Faces 3。我包括了所有必需的依赖项(Weld 1.1,JBoss Logging),但服务器没有开始说:

无法使用以下任何提供程序找到 BeanManager:
org.jboss.seam.solder.beanManager.DefaultJndiBeanManagerProvider(11)、
org.jboss.seam.solder.beanManager.ServletContainerJndiBeanManagerProvider(10)`

我遵循了pre-servlet 3.0 环境的 Seam 配置说明

在我看来,缺少一个资源(BeanMananger),我尝试按照Servlet Container 的Weld 指令将 BeanManager 设置为 Websphere 中的 jndi 资源,但这也不起作用。

在服务器启动期间导致异常的源代码尝试像这样查找 bean 管理器:

到目前为止,有没有人在 Websphere 7 上运行 Seam 3 和 CDI 1.0(分别是 Weld 1.1)?我在这里想念什么?

PS:JSF 2.0 运行良好。

0 投票
3 回答
2721 浏览

java - JBoss Weld + java.lang.OutOfMemoryError:PermGen 空间

我刚刚切换到 Weld 以使用 CDI JSF 2 Beans + 对话范围。

这是我的 Maven 依赖项:

这是我的 web.xml 中的条目:

我立即注意到的一件事是我只需要重新加载我的 tomcat 7 2 次,它java.lang.OutOfMemoryError: PermGen space就会出现在 catalina.out 日志文件中。

在使用 Weld 之前,我可以在没有 java.lang.OutOfMemoryError 的情况下安全地重新加载我的 tomcat 7 超过 10 次。我认为在 catalina.sh 中增加我的 Xmx 选项会有所帮助,但在我的经验中并没有。JAVA_OPTS=-Xmx1024m

这是正常的吗?

0 投票
3 回答
3584 浏览

jsf - Weld 1.0.1-Final:对话范围 bean 即使在开始对话后仍会重新创建?

我目前使用:

  1. 阿帕奇雄猫 7
  2. JBoss Weld servlet 1.0.1-Final
  3. 空 beans.xml
  4. <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>在 web.xml 中

我目前正在测试一个简单的计数器@ConversationScoped bean,其目的是在开始对话范围后,在单击按钮时不断增加计数器..

但似乎在提交之后,bean总是会被重新创建,即使在我首先开始对话之后也是如此。

这是我的简单 bean:

这是我的简单 jsf 视图:

这是第一次访问的日志文件:

显示视图后,我单击按钮,然后在 catalina.out 中使用此日志引发异常:

这是来自 tomcat 日志的异常跟踪:

任何想法出了什么问题?

谢谢 !

0 投票
1 回答
1800 浏览

jetty - 码头:添加以编程方式

我有一个带有嵌入式 Jetty 和 Wicket 的独立应用程序。
我想使用 CDI 进行注射。

所以我找到了http://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#d0e5286
现在我正在尝试以编程方式添加它,但它非常复杂。

我该如何编码?

我发现的其他来源是:

到目前为止,我有:

0 投票
1 回答
1031 浏览

java - 将 EL Resolver 与 WELD 结合使用时,如何解决类型差异?

我有一个通用的 EL 生产者,我编写它以利用 WELD 的能力,在我需要它完成时“让它工作”,甚至将类型强制写入函数中,以确保返回类型与焊接注射点。

这是我的问题:WELD 从注入点的可分配类型解析,即,如果您的注入点是一个字符串,它只会寻找具有字符串返回类型的生产者。

这是有问题的,因为我想要一个负责类型强制的生产者,并交还一个正确类型的对象。

作为一个 kludge,我有一个 String 生产者方法,它别名为真正的生产者,并且只做类型 kludging。

这...至少有效,直到我遇到对象类型注入点的情况,此时我的所有 kludge 方法和通用生产者 ALL 都匹配,即使我使用 @Typed 也会给出模棱两可的依赖异常对生产者。

有没有一种理智的方法可以解决这个问题,还是我应该放弃让 WELD 为我完成所有艰苦工作的想法?

这是一个使用此生产者的示例,来自具有请求范围的错误处理 bean。RequestURI 在这种情况下很麻烦,另外两个需要键入的“kludge”方法才能工作。这个特定 bean(不包括代码)的主要功能是捕获未处理的异常并通过电子邮件将它们报告给我们,以便在未来的修订中进行更具体的错误处理。这里的基本用例是简化对 EL 的编程访问,并可能允许使用值绑定写回 EL,尽管这在此特定代码中是不可能的。

我知道我可以使用其他方法执行以下操作,这不是重点。实际上,以编程方式更容易地访问 EL IMO 是一件好事,尤其是在处理 JSF 2.0 引入的一些更奇特的作用域(尤其是 Flash 作用域)时。我的大多数用例都与 Flash 作用域有关,但在这里公开并不安全,它们也不是可预测的类型,或者应该为它们编写杂乱无章的类型,因此我想要这种更通用的方法。

这是我的预选赛:

制作人:

和错误: