Seam 2.2.2.Final on JBoss AS 7: @In gives NPE
pdhaigh Apr 1, 2012 6:13 AMHi,
I have been working on migrating an application based on Seam 2.2.2.Final to JBoss AS 7. I've worked through Marek's examples, and various other documentation, and have got to the point where the application deploys with no errors (although I did have to downgrade to AS 7.1.0 from 7.1.1 due to this bug: Caused by: java.lang.NoClassDefFoundError: org/hibernate/cache/infinispan/InfinispanRegionFactory)
The steps I have taken are:
components.xml
<core:init jndi-pattern="java:app/myapp/#{ejbName}" debug="false" distributable="false"/> | |
<component class="org.jboss.seam.transaction.EjbSynchronizations" jndi-name="java:app/myapp/EjbSynchronizations"/> | |
<component class="org.jboss.seam.async.TimerServiceDispatcher" jndi-name="java:app/myapp/TimerServiceDispatcher"/> |
jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<!-- This allows you to define additional dependencies, it is the same as using the Dependencies: manifest attribute -->
<dependencies>
<module name="org.apache.commons.logging" />
<module name="javax.faces.api" slot="1.2"/>
<module name="com.sun.jsf-impl" slot="1.2"/>
<module name="org.dom4j" export="true"/>
</dependencies>
<exclusions>
<module name="javax.faces.api" slot="main"/>
<module name="com.sun.jsf-impl" slot="main"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
web.xml
<context-param> | |
<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name> | |
<param-value>Mojarra-1.2</param-value> | |
</context-param> |
Included jsf-facelets.jar in WAR, and bundled hibernate:
pom.xml
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam</artifactId>
<version>2.2.2.Final</version>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-ui</artifactId>
<version>3.3.3.Final</version>
</dependency>
<dependency>
<groupId>org.richfaces.framework</groupId>
<artifactId>richfaces-impl</artifactId>
<version>3.3.3.Final</version>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>1.1.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.9.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.9.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>3.1.0.GA</version>
</dependency>
The application deploys fine, and I can access pages, with facelets templating and EL expressions resolving. However, wherever I have @In, I am getting a NPE:
@Stateless
@Name("authenticator")
public class AuthenticatorAction implements Authenticator
{
@In
Identity identity;
public boolean authenticate()
{
log.info("Authenticating #0", identity.getCredentials().getUsername());
gives NPE on log line and:
@Stateful
@Name("leagueManager")
public class LeagueManager implements LeagueManagerI
{
@In (create=true,required=false)
private LeagueDAO leagueDAO;
public void checkLeague()
{
if (leagueDAO.getInstance().getId()==null)
gives NPE on the last line. However, using Component.getInstance(), does work:
@Stateful
@Name("leagueManager")
public class LeagueManager implements LeagueManagerI
{
@In (create=true,required=false)
private LeagueDAO leagueDAO;
public void checkLeague()
{
leagueDAO = (LeagueDAO) Component.getInstance("leagueDAO");
if (leagueDAO.getInstance().getId()==null)
So it appears that Seam is functioning, but the Injection is failing for some reason. Can anyone help shed some light?
cheers
phil