jboss-weld

Injecting EntityManager with a producer in tomcat

﹥>﹥吖頭↗ 提交于 2019-11-30 14:47:24
I am running a project using Hibernate and Weld CDI on tomcat 7. I have write a ServletContextListener to create the EntityManagerFactory and EntityManager during application startup. public class PersistenceListener implements ServletContextListener { private static EntityManagerFactory entityManagerFactory; public void contextInitialized(ServletContextEvent sce){ ServletContext context = sce.getServletContext(); entityManagerFactory = Persistence.createEntityManagerFactory("hibernate-test"); } public void contextDestroyed(ServletContextEvent sce) { entityManagerFactory.close(); } public

Injecting a bean from a different Jar in Weld

≯℡__Kan透↙ 提交于 2019-11-30 00:44:56
问题 I have two Jars A and B where A depends on B. Jar B has a single class: @ApplicationScoped public class MyManagedBean { private String user; public MyManagedBean(){ //Constructor necesary for CDI } @Inject public MyManagedBean(@Named("user") String user){ this.user = user; } ... } Jar A (more precisely, an EJB jar) has a bean: @ApplicationScoped public class AnotherManagedBean { public AnotherManagedBean(){ //Constructor necesary for CDI } @Inject public AnotherManagedBean(MyManagedBean bean)

CDI ConversationScoped long-running Bean not working

旧城冷巷雨未停 提交于 2019-11-29 23:23:48
问题 I got some problems understanding the Conversation scope of Weld or CDI. In my JSF Faclets page i call: <f:metadata> <f:event type="preRenderView" listener="#{viewBean.start}" /> </f:metadata> The bean: import javax.enterprise.context.Conversation; import javax.enterprise.context.ConversationScoped; @Named @ConversationScoped public class ViewBean implements Serializable { @Inject private Conversation conversation; public void start() { if (conversation.isTransient()) { System.out.println(

Injecting EntityManager with a producer in tomcat

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 21:18:11
问题 I am running a project using Hibernate and Weld CDI on tomcat 7. I have write a ServletContextListener to create the EntityManagerFactory and EntityManager during application startup. public class PersistenceListener implements ServletContextListener { private static EntityManagerFactory entityManagerFactory; public void contextInitialized(ServletContextEvent sce){ ServletContext context = sce.getServletContext(); entityManagerFactory = Persistence.createEntityManagerFactory("hibernate-test")

WELD-000072 Managed bean declaring a passivating scope must be passivation capable

坚强是说给别人听的谎言 提交于 2019-11-29 20:06:37
I wrote a simple program in java web forms but i am receiving the following error: WELD-000072 Managed bean declaring a passivating scope must be passivation capable. Bean: Managed Bean [class BeanPakage.DemoBeans ] with qualifiers [ @Any @Default @Named ] Can anyone tell me where this error comes from? import javax.enterprise.context.SessionScoped; import javax.inject.Named; @Named("DemoBeans") @SessionScoped public class DemoBeans { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } You can make your bean passivation capable

How to bootstrap weld-osgi version 2 in SE application

你离开我真会死。 提交于 2019-11-29 16:10:26
It's really not funny. There is no information in internet how to run weld-osgi second version (2.1.2.final) in se app. Instructions for ver 1 don't work. Let the developers be ashamed that they didn't provide necessary samples. I wrote them here . So, I have and OSGi activator and I want to get beans from it. In GF4 I used this: private BeanManager getBeanManager() throws NamingException { try{ InitialContext initialContext = new InitialContext(); return (BeanManager) initialContext.lookup("java:comp/BeanManager"); } catch (NamingException e) { System.out.println("Couldn't get BeanManager

CDI Application and Dependent scopes can conspire to impact garbage collection?

半腔热情 提交于 2019-11-29 01:24:41
We're starting to experiment with implementing our backend services using CDI. The scenario is this: EJB with @Startup is started when EAR deployed. An ApplicationScoped bean is injected onto this: @ApplicationScoped public class JobPlatform { private PooledExecutor threadHolder; @Inject @Any private Instance<Worker> workerSource; ... The bean also has an Observer method, which, when an event is observed, gets a worker bean from the Instance workerSource and puts it on the threadPool, where it eventually runs to completion. All working nicely. However... we've started to see garbage collection

What is the default scope of a Named CDI bean?

…衆ロ難τιáo~ 提交于 2019-11-29 01:10:39
Is there any default scope for a @Named CDI bean without additional @...Scoped annotations? I have not found any relevant information in the official Weld documentation . A @Named bean can be accessed over JSF without additional annotations, so some implicit scope seems likely. Thank you The default scope is the dependent pseudo-scope @Dependent , as stated in the weld documentation : CDI features the so-called dependent pseudo-scope. This is the default scope for a bean which does not explicitly declare a scope type. [...] An instance of a dependent bean is never shared between different

Maven Eclipse Debug “JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)”

安稳与你 提交于 2019-11-29 01:01:50
I'm trying to debug Maven tests in Eclipse. When I launch tests with the maven option maven.surefire.debug, I get this error : ERROR: transport error 202: bind failed: Address already in use FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197) ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690] /bin/sh: line 1: 27500 Abort trap It is the same when I tried tu launch debug in my shell. I tried to add the

Inject a stateless EJB with @Inject into CDI Weld ManagedBean (JSF 1.2 EJB Application on jboss 6 AS)

99封情书 提交于 2019-11-29 00:16:07
Currently I am trying to inject a stateless EJB into a CDI managed controller on Jboss 6 AS Final. The controller is managed in the context an accessible from the JSF pages. If I inject the stateless bean with @EJB it is working. If I inject the stateless EJB with @Inject I get the following Exception: My controller: @Named("TestController") public class TestController { @Inject private TestManagerLocal myTestManager; ... } } My stateless bean: @SuppressWarnings("unchecked") @Stateless public class TestManagerBean implements TestManagerLocal { @PersistenceContext private EntityManager em; ...