8 Replies Latest reply on Oct 10, 2007 9:52 PM by Tim Evers

    How to use Seam without persistence?

    Tim Evers Master

      Hi all,

      I have a very unusual task at my work and I'm struggeling to find a way to accomplish what my team leader wants.

      We are writing an app that is using Spring for transaction management and for some *unknown/stupid* reason they do not want seam to handle persistence. However, I am running into all sorts of problems at the moment trying to set seam up without any persistence information.

      All we really want from seam is how much easier it makes writing the jsf side of things.

      First problem I'm having. If i disable transactions in components.xml using:

      <core:init transaction-management-enabled="false"/>


      I get the following error on every request a browswer makes to a page.
      2007-10-10 15:32:29,898 ERROR [http-8080-1] contexts.Contexts (Contexts.java:335) - could not discover transaction status


      If I just put in the components.xml the following:
      <core:init debug="true"/>


      I get the following error:
      2007-10-10 15:38:08,993 ERROR [http-8080-1] jsf.SeamPhaseListener (SeamPhaseListener.java:122) - uncaught exception
      java.lang.RuntimeException: exception invoking: getTransaction
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:135)
       at org.jboss.seam.Component.callComponentMethod(Component.java:2087)
       at org.jboss.seam.Component.unwrap(Component.java:2113)
       at org.jboss.seam.Component.getInstance(Component.java:1892)
       at org.jboss.seam.Component.getInstance(Component.java:1857)
       at org.jboss.seam.Component.getInstance(Component.java:1834)
       at org.jboss.seam.Component.getInstance(Component.java:1829)
       at org.jboss.seam.transaction.Transaction.instance(Transaction.java:36)
       at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:301)
       at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:142)
       at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:116)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:307)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       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:44)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
       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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:150)
       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:233)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)
      Caused by: javax.naming.NamingException: Cannot create resource instance
       at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:113)
       at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
       at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
       at javax.naming.InitialContext.lookup(InitialContext.java:392)
       at org.jboss.seam.transaction.Transaction.getUserTransaction(Transaction.java:79)
       at org.jboss.seam.transaction.Transaction.createUTTransaction(Transaction.java:71)
       at org.jboss.seam.transaction.Transaction.getTransaction(Transaction.java:44)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
       ... 46 more
      


      I have looked at the Spring example and to be quite honest I'm relatively inexperienced in Java and am not sure if the Spring example is doing what I want to achieve. That is if it is even possible.

      Could someone point me in the direction I should be going?

      I'm pretty sure that it has something to do with components.xml but I'm confused as to what I have to put in there to make it all work.

      Anyway here are my files.

      web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5"
       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/web-app_2_5.xsd">
      
       <welcome-file-list>
       <welcome-file>web/blah.html</welcome-file>
       </welcome-file-list>
      
       <context-param>
       <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
       <param-value>com.sun.facelets.FaceletViewHandler</param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>client</param-value>
       </context-param>
      
       <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value>
       </context-param>
      
       <context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>
       classpath:spring-gekko/spring-gekko-services-context.xml
       classpath:spring-gekko/spring-gekko-web-context.xml
       </param-value>
       </context-param>
      
       <!-- Ajax4jsf (must come first!) -->
       <filter>
       <display-name>RichFaces Filter</display-name>
       <filter-name>richfaces</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
      
       <filter>
       <filter-name>Seam Filter</filter-name>
       <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>richfaces</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
      
       <filter-mapping>
       <filter-name>Seam Filter</filter-name>
       <url-pattern>/*</url-pattern>
       </filter-mapping>
      
       <!-- Spring -->
       <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
       </listener>
      
       <!-- Seam -->
       <listener>
       <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
       </listener>
      
       <!-- JSF -->
       <listener>
       <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
       </listener>
      
       <servlet>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <servlet-class>org.jboss.seam.servlet.ResourceServlet</servlet-class>
       </servlet>
      
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
      
       <servlet>
       <servlet-name>Some Application Logic</servlet-name>
       <servlet-class>gekko.web.manualservlet.SomeApplicationLogicServlet</servlet-class>
       <load-on-startup>100</load-on-startup>
       </servlet>
      
       <servlet>
       <servlet-name>XmlRpcDispatcher</servlet-name>
       <servlet-class>gekko.web.remote.xmlrpc.XmlRpcDispatcher</servlet-class>
       <init-param>
       <description>Sets, whether the servlet supports vendor extensions for XML-RPC.</description>
       <param-name>enabledForExtensions</param-name>
       <param-value>false</param-value>
       </init-param>
       <init-param>
       <description>If the client is to receive the server exception message</description>
       <param-name>enabledForExceptions</param-name>
       <param-value>true</param-value>
       </init-param>
       <load-on-startup>1</load-on-startup>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <url-pattern>/seam/resource/*</url-pattern>
       </servlet-mapping>
      
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.jsf</url-pattern>
       </servlet-mapping>
      
       <servlet-mapping>
       <servlet-name>XmlRpcDispatcher</servlet-name>
       <url-pattern>/xmlrpc</url-pattern>
       </servlet-mapping>
      
       <servlet-mapping>
       <servlet-name>Some Application Logic</servlet-name>
       <url-pattern>/someApplicationLogic</url-pattern>
       </servlet-mapping>
      
       <session-config>
       <session-timeout>10</session-timeout>
       </session-config>
      
      </web-app>
      


      faces-config.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xi="http://www.w3.org/2001/XInclude"
       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/web-facesconfig_1_2.xsd">
      
       <!-- Facelets support -->
       <application>
       <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
       <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
       </application>
      
      </faces-config>
      


      and last but not least
      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"
       xmlns:web="http://jboss.com/products/seam/web"
       xsi:schemaLocation=
       "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd
       http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.0.xsd">
      
       <core:init debug="true"/>
      
      </components>