小编典典

SeamPhaseListener-无法启动事务-Seam 2.3,JSF 2 Tomcat 7,WAR

tomcat

[编辑]
可以在以下位置找到正在运行的项目:
https
:
//github.com/joergi77/JSF2_Richfaces4_Seam_23
[/ EDIT]

我将旧项目迁移到新的设置。

旧设置

  • Seam 2.2.2.Final
  • JSF 1.2
  • Richfaces 3.3.3Final
  • JBoss 5.1 GA
  • EAR
  • EJB
  • Java EE5

新设置:

  • Seam 2.3.1.Final
  • JSF 2.1.2
  • Richfaces 3.3.3 Final(应与JSF 2兼容)
  • Tomcat 7.0.57
  • WAR
  • NO EJB
  • Java 7

WAR文件已经可以部署,并且可以与SEAM 2.2和JSF 1.2一起使用。在Tomcat 7.0.57上

之后,我升级到SEAM 2.3和JSF2。最后,我可以再次编译WAR并将其部署到Tomcat上而没有任何错误日志。但是,当我尝试通过http://localhost:8080 / ourproject进入网站时,出现以下错误:

java.lang.IllegalStateException: Could not start transaction
    at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:602)
    at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:587)
    at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:326)
    at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:143)
    at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:117)
    at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
    at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
    at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
    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.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745) 
Caused by: java.lang.UnsupportedOperationException: no transaction
    at org.jboss.seam.transaction.NoTransaction.begin(NoTransaction.java:36)
    at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:597)
    ... 48 more

这是我们的设置:

web.xml

<?xml version="1.0"?>
<web-app version="3.0" 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_3_0.xsd">

    <!-- Increase buffers so the entire response is sent at once (some people 
        say this could increase the performance). -->
    <context-param>
        <param-name>com.sun.faces.responseBufferSize</param-name>
        <param-value>100000</param-value>
    </context-param>


    <context-param>  
         <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>  
         <param-value>true</param-value>  
    </context-param>


    <!-- Allows the browser to cache jsf's javascript -->
    <context-param>
        <param-name>com.sun.faces.sendPoweredByHeader</param-name>
        <param-value>false</param-value>
    </context-param>

    <context-param>
        <param-name>facelets.BUFFER_SIZE</param-name>
        <param-value>100000</param-value>
    </context-param>

    <!-- ##################### Facelets ##################### Disables facelets 
        debug page Defined in root pom - initial value: fale -->
    <context-param>
        <param-name>facelets.DEVELOPMENT</param-name>
        <param-value>false</param-value>
    </context-param>

        <!-- Stops facelets from scanning the xhtml's for changes Defined in root 
        pom - initial value: -1, for development 2 is recomanded -->
    <context-param>
        <param-name>facelets.REFRESH_PERIOD</param-name>
        <param-value>-1</param-value>
    </context-param>

    <context-param>
        <param-name>facelets.SKIP_COMMENTS</param-name>
        <param-value>false</param-value>
    </context-param>

    <!-- #####################  TagLib ##################### -->
    <context-param>
        <param-name>facelets.LIBRARIES</param-name>
        <param-value>/WEB-INF/taglibs/ourcompany-common.taglib.xml;
            /WEB-INF/taglibs/ourcompany-core.taglib.xml;
            /WEB-INF/taglibs/ourcompany-product.taglib.xml;
            /WEB-INF/taglibs/ourcompany-customer.taglib.xml</param-value>
    </context-param>

    <!-- ##################### JSF ##################### -->
<!--    <context-param> -->
<!--        <param-name>javax.faces.DEFAULT_SUFFIX</param-name> -->
<!--        <param-value>.xhtml</param-value> -->
<!--    </context-param> -->

    <context-param>
        <param-name>org.ajax4jsf.DEFAULT_EXPIRE</param-name>
        <param-value>1000000</param-value>
    </context-param>

    <!-- ##################### Ajax4Jsf ##################### -->
<!--    <context-param> -->
<!--        <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name> -->
<!--        <param-value>javax.faces.application.ViewHandlerWrappe</param-value> -->
<!--    </context-param> -->

<!--  Änderung JSF 2     -->
    <context-param>
       <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
       <param-value>com.sun.facelets.FaceletViewHandler</param-value>
  </context-param>



    <context-param>
        <param-name>org.richfaces.LoadScriptStrategy</param-name>
        <param-value>ALL</param-value>
    </context-param>

    <context-param>
        <param-name>org.richfaces.LoadStyleStrategy</param-name>
        <param-value>ALL</param-value>
    </context-param>

    <!-- ##################### Richfaces ##################### -->
    <context-param>
        <param-name>org.richfaces.SKIN</param-name>
        <param-value>ruby</param-value>
    </context-param>

    <filter>
        <filter-name>Seam Filter</filter-name>
        <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
    </filter>

    <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>Seam Filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>richfaces</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>

    <!-- ##################### Seam ##################### -->
    <listener>
        <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>Seam Resource Servlet</servlet-name>
        <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</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-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>*.htm</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>

    <!-- ##################### Global Stuff ##################### -->

    <session-config>

        <session-timeout>40</session-timeout>
    </session-config>

    <security-constraint>
        <display-name>Restrict raw XHTML Documents</display-name>
        <web-resource-collection>
            <web-resource-name>XHTML</web-resource-name>
            <url-pattern>*.xhtml</url-pattern>
        </web-resource-collection>
        <auth-constraint />
    </security-constraint>

</web-app>

我们的pom.xml:

......
<parent>
    <groupId>org.jboss.seam</groupId>
    <artifactId>jboss-seam-parent</artifactId>
    <version>2.3.1.Final</version>
</parent>
.....

<dependencies>


    <!-- Seam and JBOSS -->

    <dependency>
        <groupId>org.jboss.seam</groupId>
        <artifactId>jboss-seam-ui</artifactId>
    </dependency>

    <dependency>
        <groupId>org.jboss.seam</groupId>
        <artifactId>jboss-seam-remoting</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>persistence-api</artifactId>
        <version>1.0</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>3.1.0.GA</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.3.1.GA</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>3.4.0.GA</version>
    </dependency>

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version> 
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.4.0.GA</version>
    </dependency>

    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4</version>
    </dependency>

    <dependency>
        <groupId>org.jboss.spec.javax.interceptor</groupId>
        <artifactId>jboss-interceptors-api_1.1_spec</artifactId>
        <version>1.0.0.Final</version>
    </dependency>


    <!-- View -->
    <dependency>
        <groupId>javax.el</groupId>
        <artifactId>el-api</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>




    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>

    </dependency>


    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-api</artifactId>
      <version>${jsf.version}</version>
    </dependency>

    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-impl</artifactId>
      <version>${jsf.version}</version>
    </dependency>

    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.1.2</version>
    </dependency>

    <dependency>
        <groupId>com.sun.facelets</groupId>
        <artifactId>jsf-facelets</artifactId>
        <version>1.1.15.B1</version>
    </dependency>

    <dependency>
        <artifactId>richfaces-ui</artifactId>
        <groupId>org.richfaces.ui</groupId>
        <version>3.3.3.Final</version>
    </dependency>

    <dependency>  
        <groupId>org.richfaces.framework</groupId>  
        <artifactId>richfaces-impl-jsf2</artifactId>  
        <version>3.3.3.Final</version>  
    </dependency>

    <!-- Commons -->
    <dependency>
        <groupId>jboss</groupId>
        <artifactId>jboss-common-core</artifactId>
        <version>2.0.4.GA</version>
    </dependency>

    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.3</version>
    </dependency>

    <!-- Logging -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.5.8</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.5.8</version>
    </dependency>

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>

    <dependency>
        <groupId>javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.12.0.GA</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.18</version>
    </dependency>

    <dependency>
        <groupId>net.sourceforge.jexcelapi</groupId>
        <artifactId>jxl</artifactId>
        <version>2.6.10</version>
        <type>jar</type>
    </dependency>

    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.0</version>
    </dependency>

</dependencies>

我们的faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" 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_2_0.xsd">    
 <lifecycle>
  <phase-listener>com.ourproject.view.jsf.listener.NavigationPhaseListener</phase-listener>
 </lifecycle>
</faces-config>

我们的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:persistence="http://jboss.com/products/seam/persistence"
            xmlns:transaction="http://jboss.com/products/seam/transaction"
            xmlns:security="http://jboss.com/products/seam/security"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:mail="http://jboss.com/products/seam/mail"
            xmlns:async="http://jboss.com/products/seam/async"
            xmlns:web="http://jboss.com/products/seam/web"
            xsi:schemaLocation=
                "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.3.xsd 
                http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.3.xsd 
                http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.3.xsd 
                http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.3.xsd
                http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.3.xsd
                http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.3.xsd
                http://jboss.com/products/seam/async http://jboss.com/products/seam/async-2.3.xsd
                http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.3.xsd">

    <core:init debug="true"/>


    <core:manager concurrent-request-timeout="30000"
        conversation-id-parameter="cid" conversation-timeout="1200000"
        parent-conversation-id-parameter="pid" />

    <transaction:entity-transaction entity-manager="#{entityManager}"/>

    <persistence:entity-manager-factory name="companyDatabase"/>

    <persistence:managed-persistence-context name="entityManager"
                               auto-create="true" 
                    entity-manager-factory="#{companyDatabase}"/>

    <security:jpa-identity-store
        user-class="com.ourcompany.user.model.Account"
        role-class="com.ourcompany.user.model.AccountRole" />

    <security:permission-manager permission-store="#{jpaPermissionStore}"/>

    <security:jpa-permission-store
        user-permission-class="com.ourcompany.user.model.AccountPermission"/>

    <web:multipart-filter create-temp-files="true"
        max-request-size="100000000" url-pattern="*.html" />

    <web:logging-filter disabled="true" />

    <web:cache-control-filter name="imageCacheControlFilter"
        regex-url-pattern=".*(\.gif|\.png|\.jpg|\.jpeg)" value="max-age=86400" />

    <web:cache-control-filter name="textCacheControlFilter"
        regex-url-pattern=".*(\.css|\.js)" value="max-age=1400" />


</components>

我还将更改为较新的Richfaces版本,甚至可能是较新的JSF版本,但前提是我将此设置(据我所知应该可以运行)安装到正在运行的版本。


阅读 243

收藏
2020-06-16

共1个答案

小编典典

seam 2.3中component.xml中使用的名称空间已更改。您仍在使用旧的。

更改http://jboss.com/products/seam为:http://jboss.org/schema/seam

如果仍有问题,请查看JBossSeam文档第4章中的从2.2到2.3的迁移:http : //docs.jboss.org/seam/2.3.1.Final/reference/pdf/seam-
reference-guide.pdf

2020-06-16