5 Replies Latest reply on Jan 6, 2011 9:46 AM by Ayari karim

    Problem Instantiating Session Bean

    Nathan Fuchs Newbie

      I am currently doing a Seam build with Maven2.  My project is deploying just fine, but when I try to hit the project, I am getting instantiation errors.  Sorry for the verbose pieces that follow, but I didn't want to miss anything. I am not sure if there is something simple that I am missing, so I wanted to include as much as possible.


      Stack trace


      11:42:01,129 ERROR [[/appsj/claims-support]] Session event listener threw exception
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: claimsSupportSessionBean
              at org.jboss.seam.Component.newInstance(Component.java:1986)
              at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
              at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
              at org.jboss.seam.contexts.Lifecycle.beginSession(Lifecycle.java:191)
              at org.jboss.seam.contexts.ServletLifecycle.beginSession(ServletLifecycle.java:124)
              at org.jboss.seam.servlet.SeamListener.sessionCreated(SeamListener.java:44)
              at org.apache.catalina.session.StandardSession.tellNew(StandardSession.java:397)
              at org.apache.catalina.session.StandardSession.setId(StandardSession.java:369)
              at org.apache.catalina.session.ManagerBase.createSession(ManagerBase.java:828)
              at org.apache.catalina.session.StandardManager.createSession(StandardManager.java:291)
              at org.apache.catalina.connector.Request.doGetSession(Request.java:2310)
              at org.apache.catalina.connector.Request.getSession(Request.java:2075)
              at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
              at com.sun.faces.context.SessionMap.getSession(ExternalContextImpl.java:1014)
              at com.sun.faces.context.SessionMap.put(ExternalContextImpl.java:977)
              at org.jboss.seam.contexts.BasicContext.set(BasicContext.java:80)
              at org.jboss.seam.Component.newInstance(Component.java:1974)
              at org.jboss.seam.Component.getInstance(Component.java:1876)
              at org.jboss.seam.Component.getInstance(Component.java:1855)
              at org.jboss.seam.Component.getInstance(Component.java:1832)
              at org.jboss.seam.web.Session.getInstance(Session.java:122)
              at org.jboss.seam.contexts.FacesLifecycle.beginRequest(FacesLifecycle.java:54)
              at org.jboss.seam.jsf.SeamPhaseListener.beforeRestoreView(SeamPhaseListener.java:377)
              at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:137)
              at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
              at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
              at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)
              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.RuntimeException: by java.lang.NoClassDefFoundError: com/company/webapps/cp/claimsSupport/beans/ClaimsSupportSessionBeanInterface
              at org.jboss.seam.util.ProxyFactory.createClass(ProxyFactory.java:190)
              at org.jboss.seam.Component.createProxyFactory(Component.java:2270)
              at org.jboss.seam.Component.getProxyFactory(Component.java:1378)
              at org.jboss.seam.Component.wrap(Component.java:1369)
              at org.jboss.seam.Component.instantiateSessionBean(Component.java:1291)
              at org.jboss.seam.Component.instantiate(Component.java:1276)
              at org.jboss.seam.Component.newInstance(Component.java:1970)
              ... 66 more
      Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError: com/company/webapps/cp/claimsSupport/beans/ClaimsSupportSessionBeanInterface
              at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:169)
              at org.jboss.seam.util.ProxyFactory.createClass(ProxyFactory.java:186)
              ... 72 more
      Caused by: java.lang.NoClassDefFoundError: com/company/webapps/cp/claimsSupport/beans/ClaimsSupportSessionBeanInterface
              at java.lang.ClassLoader.defineClass1(Native Method)
              at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
              at sun.reflect.GeneratedMethodAccessor192.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at javassist.util.proxy.FactoryHelper.toClass2(FactoryHelper.java:181)
              at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:163)
              ... 73 more




      components.xml



      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
                  xmlns:core="http://jboss.com/products/seam/core"
                  xmlns:security="http://jboss.com/products/seam/security"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation=
                      "http://jboss.com/products/seam/core 
                       http://jboss.com/products/seam/core-2.0.xsd 
                       http://jboss.com/products/seam/components 
                       http://jboss.com/products/seam/components-2.0.xsd
                       http://jboss.com/products/seam/security 
                       http://jboss.com/products/seam/security-2.0.xsd">
      
          <security:identity jaas-config-name="authorization" />
          <core:init jndi-pattern="claims-support-1.0.0/#{ejbName}/local" />
      
          
      </components>
      



      ClaimsSupportSessionBean


      package com.company.webapps.cp.claimsSupport.beans;
      
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Create;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.Startup;
      import org.jboss.seam.security.AuthorizationException;
      import org.jboss.seam.security.Identity;
      import org.jboss.seam.security.NotLoggedInException;
      
      /**
       * This class acts as the session bean for the Hold Detail portion of the Claims
       * Support application. It is used to handle communication between the web form
       * and the data access level.
       */
      @Stateful
      @Startup
      @Name("claimsSupportSessionBean")
      @Scope(ScopeType.SESSION)
      public final class ClaimsSupportSessionBean implements
              ClaimsSupportSessionBeanInterface {
      
          /** initialize variables outjected at startup */
          @Create
          public void initialize() {
              loggedIn = false;
              authorized = false;
              loginAttempted = false;
          }
      
          /** destroys stateful bean when context ends */
          @Remove
          @Destroy
          public void destroy() {
          }
      
          .....abreviated
      
      }



      ClaimsSupportSessionBeanInterface


      package com.company.webapps.cp.claimsSupport.beans;
      
      import javax.ejb.Local;
      
      /**
       * Interface for ClaimsSupportSessionBean
       */
      @Local
      public interface ClaimsSupportSessionBeanInterface {
      
          /** initialize variables outjected at startup */
          void initialize();
      
          /** destroys stateful bean when context ends */
          void destroy();
      
      }



      My application.xml is generated by Maven and looks like:


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE application PUBLIC
           "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
           "http://java.sun.com/dtd/application_1_3.dtd">
      <application>
        <display-name>claims-support</display-name>
        <description></description>
        <module>
          <web>
            <web-uri>claims-support-1.0.0.war</web-uri>
            <context-root>/appsj/claims-support</context-root>
          </web>
        </module>
        <module>
          <ejb>claims-support-1.0.0.jar</ejb>
        </module>
      </application>



      and my jboss-app.xml that is also generated by Maven looks like:



      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-app PUBLIC
           "-//JBoss//DTD J2EE Application 1.4//EN"
           "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
      <jboss-app>
        <loader-repository>seam.jboss.org:loader=claims-support</loader-repository>
      </jboss-app>