Note that there are some explanatory texts on larger screens.

plurals
  1. POSeam not injecting Stateful EJB dependencies
    primarykey
    data
    text
    <p>I have not been able to find a solution to this problem and my post to the Seam forum has gone unanswered. I am hope someone here can help.</p> <p>I am a noob working with Seam, so I am sure I am just doing something stupid. Any help anyone can give me would be greatly appreciated... I have wasted hours and gotten nowhere. I used the jboss tools to generate a seam project in eclipse. The tool took pre-created JPA entities and created a basic webapp. My first step was to add a registration page so that I can create some users and login using database authentication (I set this up, but will test it once the registration page works). I used the seam-booking example to guide me (basically integrating the form stuff plus additional fields into the view of the seam-gen app). When I test the registration page, I get NullPointerExceptions for all of the injected fields. I have looked through the entire seam-booking example, scoured the web looking at examples, and quickly read through some sections of a book and I do not see where there is any additional configuration information needed. What in the world am I doing wrong? Please help!!!</p> <p>I am using JBoss Server (community edition) 5.1.0GA and Seam 2.2.0GA. </p> <p>If you need any more information than what I am posting, please let me know. Thanks to all ahead of time for your help!! </p> <p>Stateful EJB: </p> <pre><code>@Stateful @Scope(EVENT) @Name("register") public class RegisterAction implements Register { @In private User user; @PersistenceContext private EntityManager entityManager; @In private FacesMessages facesMessages; private String verify = null; private boolean registered = false; public void registerUser() { if (user.getPassword().equals(verify)) { List existing = entityManager .createQuery( "select u.userName from User u where u.userName=#{user.userName}") .getResultList(); if (existing.size() == 0) { entityManager.persist(user); facesMessages .add("Successfully registered as #{user.userName}"); registered = true; } else { facesMessages.addToControl("userName", "Username #{user.userName} already exists"); } } else { facesMessages.addToControl("verify", "Re-enter your password"); verify = null; } } public void invalid() { facesMessages.add("Please try again"); } public boolean isRegistered() { return registered; } public String getVerify() { return verify; } public void setVerify(String verify) { this.verify = verify; } @Remove @Destroy public void destroy() { } } </code></pre> <p>EJB local interface: </p> <pre><code>@Local public interface Register { public void registerUser(); public void invalid(); public String getVerify(); public void setVerify(String verify); public boolean isRegistered(); public void destroy(); } </code></pre> <p>XHTML of registratin page:<br> </p> <pre><code>&lt;ui:define name="body"&gt; &lt;rich:panel&gt; &lt;f:facet name="header"&gt;Register&lt;/f:facet&gt; &lt;h:form id="registration"&gt; &lt;fieldset&gt;&lt;s:decorate id="firstNameDecorate" template="layout/edit.xhtml"&gt; &lt;ui:define name="label"&gt;First Name:&lt;/ui:define&gt; &lt;h:inputText id="firstName" value="#{user.firstName}" required="true"&gt; &lt;a:support id="onblur" event="onblur" reRender="firstNameDecorate" /&gt; &lt;/h:inputText&gt; &lt;/s:decorate&gt; &lt;s:decorate id="lastNameDecorate" template="layout/edit.xhtml"&gt; &lt;ui:define name="label"&gt;Last Name:&lt;/ui:define&gt; &lt;h:inputText id="lastName" value="#{user.lastName}" required="true"&gt; &lt;a:support id="onblur" event="onblur" reRender="lastNameDecorate" /&gt; &lt;/h:inputText&gt; &lt;/s:decorate&gt; &lt;s:decorate id="emailDecorate" template="layout/edit.xhtml"&gt; &lt;ui:define name="label"&gt;Email:&lt;/ui:define&gt; &lt;h:inputText id="emailAddress" value="#{user.emailAddress}" required="true"&gt; &lt;a:support id="onblur" event="onblur" reRender="emailDecorate" /&gt; &lt;/h:inputText&gt; &lt;/s:decorate&gt; &lt;s:decorate id="usernameDecorate" template="layout/edit.xhtml"&gt; &lt;ui:define name="label"&gt;Username:&lt;/ui:define&gt; &lt;h:inputText id="username" value="#{user.userName}" required="true"&gt; &lt;a:support id="onblur" event="onblur" reRender="usernameDecorate" /&gt; &lt;/h:inputText&gt; &lt;/s:decorate&gt; &lt;s:decorate id="passwordDecorate" template="layout/edit.xhtml"&gt; &lt;ui:define name="label"&gt;Password:&lt;/ui:define&gt; &lt;h:inputSecret id="password" value="#{user.password}" required="true" /&gt; &lt;/s:decorate&gt; &lt;s:decorate id="verifyDecorate" template="layout/edit.xhtml"&gt; &lt;ui:define name="label"&gt;Verify Password:&lt;/ui:define&gt; &lt;h:inputSecret id="verify" value="#{register.verify}" required="true" /&gt; &lt;/s:decorate&gt; &lt;div class="buttonBox"&gt;&lt;h:commandButton id="register" value="Register" action="#{register.registerUser}" /&gt; &amp;#160; &lt;s:button id="cancel" value="Cancel" view="/index.xhtml" /&gt;&lt;/div&gt; &lt;/fieldset&gt; &lt;/h:form&gt; &lt;/rich:panel&gt; &lt;/ui:define&gt; &lt;/ui:composition&gt; </code></pre> <p>Template XHTML (Registration page uses this): </p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:a="http://richfaces.org/a4j" xmlns:s="http://jboss.com/products/seam/taglib" contentType="text/html"&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt; &lt;title&gt;MyApp&lt;/title&gt; &lt;link rel="shortcut icon" href="#{request.contextPath}/favicon.ico"/&gt; &lt;a:loadStyle src="resource:///stylesheet/theme.xcss"/&gt; &lt;a:loadStyle src="/stylesheet/theme.css"/&gt; &lt;ui:insert name="head"/&gt; &lt;/head&gt; &lt;body&gt; &lt;ui:include src="menu.xhtml"&gt; &lt;ui:param name="projectName" value="MyApp"/&gt; &lt;/ui:include&gt; &lt;div class="body"&gt; &lt;h:messages id="messages" globalOnly="true" styleClass="message" errorClass="errormsg" infoClass="infomsg" warnClass="warnmsg" rendered="#{showGlobalMessages != 'false'}"/&gt; &lt;ui:insert name="body"/&gt; &lt;/div&gt; &lt;div class="footer"&gt; &lt;p&gt;Powered by &lt;a href="http://seamframework.org"&gt;Seam&lt;/a&gt; #{org.jboss.seam.version} and &lt;a href="http://www.jboss.org/jbossrichfaces"&gt;RichFaces&lt;/a&gt;. Generated by seam-gen.&lt;/p&gt; &lt;s:fragment rendered="#{init.debug}"&gt; &lt;a:log hotkey="D"/&gt; &lt;p style="margin-top: -0.5em;"&gt; Conversation: id = #{conversation.id}, #{conversation.longRunning ? 'long running' : 'temporary'}#{conversation.nested ? ', nested, parent id = '.concat(conversation.parentId) : ''} #{' - '} Ajax4jsf Log (Ctrl+Shift+D) #{' - '} &lt;s:link id="debugConsole" view="/debug.xhtml" value="Debug console" target="debugConsole"/&gt; #{' - '} &lt;s:link id="resetSession" view="/home.xhtml" action="#{org.jboss.seam.web.session.invalidate}" propagation="none" value="Terminate session"/&gt; &lt;/p&gt; &lt;/s:fragment&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; &lt;/f:view&gt; </code></pre> <p>Seam Components.xml file: </p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;components xmlns="http://jboss.com/products/seam/components" xmlns:core="http://jboss.com/products/seam/core" xmlns:persistence="http://jboss.com/products/seam/persistence" xmlns:drools="http://jboss.com/products/seam/drools" xmlns:bpm="http://jboss.com/products/seam/bpm" xmlns:security="http://jboss.com/products/seam/security" xmlns:mail="http://jboss.com/products/seam/mail" xmlns:web="http://jboss.com/products/seam/web" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.2.xsd http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.2.xsd http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.2.xsd http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.2.xsd http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.2.xsd http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.2.xsd http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd"&gt; &lt;core:init debug="true" jndi-pattern="@jndiPattern@"/&gt; &lt;core:manager concurrent-request-timeout="500" conversation-timeout="120000" conversation-id-parameter="cid" parent-conversation-id-parameter="pid"/&gt; &lt;!-- Make sure this URL pattern is the same as that used by the Faces Servlet --&gt; &lt;web:hot-deploy-filter url-pattern="*.seam"/&gt; &lt;persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/MyAppEntityManagerFactory"/&gt; &lt;drools:rule-base name="securityRules"&gt; &lt;drools:rule-files&gt; &lt;value&gt;/security.drl&lt;/value&gt; &lt;/drools:rule-files&gt; &lt;/drools:rule-base&gt; &lt;security:rule-based-permission-resolver security-rules="#{securityRules}"/&gt; &lt;security:identity-manager identity-store="#{jpaIdentityStore}" /&gt; &lt;security:jpa-identity-store entity-manager="#{entityManager}" user-class="my.app.path.dao.profiles.User" role-class="my.app.path.dao.profiles.Role" /&gt; &lt;event type="org.jboss.seam.security.notLoggedIn"&gt; &lt;action execute="#{redirect.captureCurrentView}"/&gt; &lt;/event&gt; &lt;event type="org.jboss.seam.security.loginSuccessful"&gt; &lt;action execute="#{redirect.returnToCapturedView}"/&gt; &lt;/event&gt; &lt;mail:mail-session host="localhost" port="25"/&gt; &lt;/components&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload