-
1. Re: Seam injection works for POJO, fails when made Stateless
asookazian Mar 9, 2010 12:06 AM (in response to purecharger)You can try doing @In(create=true, required=false) but I'm not sure why this works for JavaBean but not for SLSB...
I'm assuming you're using the Seam component as a backing bean (hence the @Name), so Seam should auto-instantiate the component instance when it is referenced in the JSF EL...
-
2. Re: Seam injection works for POJO, fails when made Stateless
purecharger Mar 9, 2010 12:14 AM (in response to purecharger)
Arbi Sookazian wrote on Mar 09, 2010 00:06:
You can try doing @In(create=true, required=false) but I'm not sure why this works for JavaBean but not for SLSB...
I'm assuming you're using the Seam component as a backing bean (hence the @Name), so Seam should auto-instantiate the component instance when it is referenced in the JSF EL...Thanks for your reply. I tried changing these to @In(create=true) and still have the same problem, they are not being injected. However, changing @In EntityManager entityManager to @PersistenceContext EntityManager entityManager then caused it to be injected, where it wasnt before.
Still confused....
-
3. Re: Seam injection works for POJO, fails when made Stateless
asookazian Mar 9, 2010 12:33 AM (in response to purecharger)show your components.xml.
I am looking for the SMPC config in particular:
<persistence:managed-persistence-context auto-create="true" name="entityManager"> <persistence:persistence-unit-jndi-name>java:/blogEntityManagerFactory</persistence:persistence-unit-jndi-name> </persistence:managed-persistence-context>
Did you seam-gen this app?
-
4. Re: Seam injection works for POJO, fails when made Stateless
purecharger Mar 9, 2010 12:42 AM (in response to purecharger)<?xml version="1.0" encoding="UTF-8"?> <components xmlns="http://jboss.com/products/seam/components" ... http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd"> <core:init debug="false" jndi-pattern="kiosk-votingengine/#{ejbName}/local"/> <core:manager concurrent-request-timeout="500" conversation-timeout="120000" conversation-id-parameter="cid" parent-conversation-id-parameter="pid"/> <!-- Make sure this URL pattern is the same as that used by the Faces Servlet --> <web:hot-deploy-filter url-pattern="*.ec"/> <persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/kveEntityManagerFactory"/> <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/> <security:jpa-permission-store user-permission-class="com.example.db.voting.model.UserPermission" role-permission-class="com.example.db.voting.model.UserPermission"/> <event type="org.jboss.seam.security.notLoggedIn"> <action execute="#{redirect.captureCurrentView}"/> </event> <event type="org.jboss.seam.security.loginSuccessful"> <action execute="#{redirect.returnToCapturedView}"/> </event> <mail:mail-session host="localhost" port="25"/> </components>
Yes, I used seam-gen to create this project initially, and have not altered it all that much.
I'm just really perplexed that not even the @Logger annotation is working. Everything is injected properly without the @stateless annotation on the class, then as soon as I add that nothing is injected. From what I understand, that places my class into the Stateless context, but the Log object should be injected into any context correct?
Thank you
-
5. Re: Seam injection works for POJO, fails when made Stateless
asookazian Mar 9, 2010 1:01 AM (in response to purecharger)Are you using JBoss AS 4.x or 5.x?
from ref doc:
For JBoss AS, the following pattern is correct: <core:init jndi-name="earName/#{ejbName}/local" /> In this case, earName is the name of the EAR in which the bean is deployed, Seam replaces #{ejbName} with the name of the EJB, and the final segment represents the type of interface (local or remote).
Is the name of your EAR the following?
kiosk-votingengine
Are there any exceptions in the server.log after the authenticate() method executes?
-
6. Re: Seam injection works for POJO, fails when made Stateless
purecharger Mar 9, 2010 1:07 AM (in response to purecharger)I'm using JBoss 6.0.0 M1 and Seam 2.2.1-SNAPSHOT from last month (we are making the decision to deploy on Jboss 6, and the latest Seam GA release has a bug preventing startup with our deployment profile, hence the snapshot).
Yes, my ear is named kiosk-votingengine, and the EJBs contained in my EAR modules are installed into JNDI with the proper names. I have verified using the JNDIView in JMX, but here are log snippets too:
[org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] (Thread-2) Binding the following Entries in Global JNDI: kiosk-votingengine/DbAuthenticator/local - EJB3.x Default Local Business Interface kiosk-votingengine/DbAuthenticator/local-com.example.voting.auth.Authenticator - EJB3.x Local Business Interface ... [org.jboss.seam.Component] (Thread-2) Component: authenticator, scope: STATELESS, type: STATELESS_SESSION_BEAN, class: com.example.voting.auth.DbAuthenticator, JNDI: kiosk-votingengine/DbAuthenticator/local
And my Authenticator interface has the @Local annotation as well:
@javax.ejb.Local public interface Authenticator { boolean authenticate(); }
-
7. Re: Seam injection works for POJO, fails when made Stateless
asookazian Mar 9, 2010 1:18 AM (in response to purecharger)If I were you, I would try to reproduce using stable JBoss (4.2.x or 5.x) and Seam versions... maybe it's a bug in Seam/JBoss.
I don't recommend you be that aggressive about upgrading but it's your project...
-
8. Re: Seam injection works for POJO, fails when made Stateless
purecharger Mar 9, 2010 1:56 AM (in response to purecharger)Yeah, thats a good suggestion, and probably a little less time consuming that digging into Seam source and understanding why a static Logger gets injected but not a member variable.
Thanks for you time and help!
-
9. Re: Seam injection works for POJO, fails when made Stateless
swd847 Mar 9, 2010 3:41 AM (in response to purecharger)Doyou have the following ejb-jar.xml in your deployment?
<?xml version="1.0" encoding="UTF-8"?> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0"> <interceptors> <interceptor> <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class> </interceptor> </interceptors> <assembly-descriptor> <interceptor-binding> <ejb-name>*</ejb-name> <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class> </interceptor-binding> </assembly-descriptor> </ejb-jar>
-
10. Re: Seam injection works for POJO, fails when made Stateless
purecharger Mar 9, 2010 4:31 AM (in response to purecharger)D'oh! The jar containing my EJBs does NOT have that file, which would explain why nothing is being injected. I'll try it out shortly, thank you!
-
11. Re: Seam injection works for POJO, fails when made Stateless
nklashok Apr 21, 2010 2:24 AM (in response to purecharger)Ryan, My POJO injection is failing . I am not able to get the EntityManager in side my DataBean. I need to get the session from the EntityManager and pass it to DAO. Can you throw some light on this?