# Spring - no transaction is in progress



## bluer (12. Aug 2011)

Hi Leute,

ich verstehe einfach den Grund für diese Exception nicht, dann sie wird meines Erachtens total beliebig geworfen. So nach dem Motto: Jetzt will und jetzt nicht. Ich habe folgende Konfiguration, die für 90% meiner Applikation funktioniert:
web.xml:
[XML]
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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">
 <display-name>portalmatrix</display-name>
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/spring-beans.xml
/WEB-INF/spring-security.xml</param-value>
 </context-param>
 <context-param>
  <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
  <param-value>.jsp</param-value>
 </context-param>
 <context-param>
  <param-name>facelets.REFRESH_PERIOD</param-name>
  <param-value>2</param-value>
 </context-param>
 <context-param>
  <param-name>facelets.DEVELOPMENT</param-name>
  <param-value>true</param-value>
 </context-param>
 <context-param>
  <param-name>facelets.RECREATE_VALUE_EXPRESSION_ON_BUILD_BEFORE_RESTORE</param-name>
  <param-value>false</param-value>
 </context-param>
 <context-param>
  <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  <param-value>server</param-value>
 </context-param>
 <context-param>
  <param-name>org.richfaces.SKIN</param-name>
  <param-value>wine</param-value>
 </context-param>
 <context-param>
  <param-name>javax.faces.PROJECT_STAGE</param-name>
  <param-value>Development</param-value>
 </context-param>
 <filter>
  <display-name>Ajax4jsf Filter</display-name>
  <filter-name>ajax4jsf</filter-name>
  <filter-class>org.ajax4jsf.Filter</filter-class>
 </filter>
 <filter>
  <filter-name>OpenEntityManagerInViewFilter</filter-name>
  <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
 </filter>
 <filter>
  <filter-name>springSecurityFilterChain</filter-name>
  <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
 </filter>
 <filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
 <filter-mapping>
  <filter-name>ajax4jsf</filter-name>
  <servlet-name>Faces Servlet</servlet-name>
  <dispatcher>REQUEST</dispatcher>
  <dispatcher>FORWARD</dispatcher>
  <dispatcher>INCLUDE</dispatcher>
 </filter-mapping>
 <filter-mapping>
  <filter-name>OpenEntityManagerInViewFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <filter-mapping>
  <filter-name>springSecurityFilterChain</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>
 <servlet>
  <servlet-name>Static Servlet</servlet-name>
  <servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
  <init-param>
   <param-name>allowedResourcePaths</param-name>
   <param-value>/**/*.css,/**/*.gif,/**/*.ico,/**/*.jpeg,/**/*.jpg,/**/*.js,/**/*.png</param-value>
  </init-param>
  <load-on-startup>0</load-on-startup>
 </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>Spring Dispatcher</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
   <param-name>contextConfigLocation</param-name>
   <param-value/>
  </init-param>
  <load-on-startup>2</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>Static Servlet</servlet-name>
  <url-pattern>/static/*</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
  <servlet-name>Spring Dispatcher</servlet-name>
  <url-pattern>/</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.jsf</url-pattern>
 </servlet-mapping>
 <session-config>
  <session-timeout>30</session-timeout>
 </session-config>
 <welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.htm</welcome-file>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
 <error-page>
  <error-code>404</error-code>
  <location>/error.jsf?m=404</location>
 </error-page>
 <error-page>
  <exception-type>javax.faces.application.ViewExpiredException</exception-type>
  <location>/error.jsf?m=expired</location>
 </error-page>
 <error-page>
  <exception-type>java.lang.Exception</exception-type>
  <location>/error.jsf</location>
 </error-page>
 <login-config>
  <auth-method>BASIC</auth-method>
 </login-config>
</web-app>
[/XML]
persistence.xml:
[XML]
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
		http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
	<persistence-unit name="persistenceUnit"
		transaction-type="RESOURCE_LOCAL">
		<provider>org.hibernate.ejb.HibernatePersistence</provider>
		<properties>
			<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
			<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy" />
			<property name="hibernate.connection.url" value="jdbc:mysql://localhost/develope" />
			<property name="hibernate.connection.username" value="root" />
			<property name="hibernate.connection.password" value="tomcat" />
<!--			<property name="hibernate.hbm2ddl.auto" value="update" />-->

			<property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider" />
			<property name="hibernate.c3p0.min_size" value="3" />
			<property name="hibernate.c3p0.max_size" value="20" />
			<property name="hibernate.c3p0.timeout" value="25200" /> <!-- less that mysql wait_timeout -->
			<property name="hibernate.c3p0.max_statements" value="0" />
			<property name="hibernate.c3p0.acquire_increment" value="3" />
			<property name="hibernate.c3p0.idle_test_period" value="14400" />
<!--			<property name="hibernate.c3p0.validate" value="false" />-->
		</properties>
	</persistence-unit>
</persistence>
[/XML]
spring-beans-xml:
[XML]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
Index of /schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
Index of /schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
Index of /schema/tx
		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
	default-autowire="byType">

	<context:annotation-config />

	<!-- Configures the @Controller programming model -->
	<mvc:annotation-driven />

	<!-- Scans the classpath of this application for @Components	-->
	<context:component-scan base-package="controller" />
	<context:component-scan base-package="service" />
	<context:component-scan base-package="dao" />

	<contextroperty-placeholder location="classpath:META-INF/*.properties" />

	<bean id="entityManagerFactory"
	      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="persistenceUnitName" value="persistenceUnit" />
		<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
		<property name="jpaVendorAdapter">
			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
				<!-- <property name="showSql" value="true" />-->
				<property name="generateDdl" value="true" />
				<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
			</bean>
		</property>
	</bean>

	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="entityManagerFactory" />
	</bean>

	<!-- Publishing session factory to be able view statistics -->
	<bean id="sessionFactory" factory-bean="entityManagerFactory"
		factory-method="getSessionFactory" />

	<tx:annotation-driven proxy-target-class="true" />

	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.UrlBasedViewResolver">
		<property name="viewClass"
			value="org.springframework.web.servlet.view.JstlView" />
		<property name="prefix" value="/" />
		<property name="suffix" value=".jsf" />
	</bean>
</beans>
[/XML]
Bei dieser DAO läuft es ohne Probleme:

```
package dao.project;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;

import model.project.Project;
import model.security.User;

import org.springframework.stereotype.Repository;

@Repository("projectDao")
public class ProjectDaoImpl implements ProjectDao {
	@PersistenceContext(type = PersistenceContextType.EXTENDED)
	private EntityManager em;

    @Override
    public Project findByCompanyName(String projectName){
        try {
            return em.createQuery("select p from Project p where p.projectName = :name",
				  Project.class).setParameter("name", projectName).getSingleResult();
	} catch (NoResultException e) {
		return null;
        }
    }

	@Override
	public List<Project> getAll() {
		return em.createQuery("select p from Project p", Project.class)
				.getResultList();
	}

	@Override
	public Project getById(Long id) {
		return em.find(Project.class, id);
	}

	@Override
	public void persist(Project project) {
		em.persist(project);
		em.flush();
	}

	@Override
	public Project merge(Project project) {
		return em.merge(project);
	}

	@Override
	public void remove(Project project) {
		em.remove(project);
		em.flush();
	}

	@Override
	public Project update(Project project) {
		project = em.merge(project);
		em.flush();
		
		return project;
	}

	@Override
	public void clear() {
		em.clear();
	}

    public boolean removeProject(List<User> users, Project project) {
        try{
            for( User i : users)
                em.merge(i);
            em.remove(project);
            em.flush();
            return true;

        }catch(Exception e){
            return false;
        }
    }
}
```
wenn ich zum Beispiel die Methode:

```
@Transactional
    public void finalWizard(){
        if( !this.selectedCatalog.equals(-1L))
            try{
                if( this.customer.getId() == null ){
                    ...
                    this.userDao.persist(this.user, this.customer, consultantUser, this.project);
                }else{
                    ...
                    this.userDao.update(updateCustomer, updateConsultant, this.project);
                }
            }catch(Exception e){
                System.out.println(e.getMessage());
            }
    }
```
aufrufe. Bei einem anderen DAO jedoch schmeißt wird die Exception geworfen. Das DAO:

```
package dao.catalog;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import model.catalog.Catalog;
import model.criteria.CriteriaRoot;
import org.springframework.stereotype.Repository;

@Repository("catalogDao")
public class CatalogDaoImpl implements CatalogDao {

    @PersistenceContext(type = PersistenceContextType.EXTENDED)
    private EntityManager em;

    public Catalog getById(Long id) {
        return em.find(Catalog.class, id);
    }

    public List<Catalog> getAll() {
        return em.createQuery("select c from Catalog c ", Catalog.class).getResultList();
    }

    public Catalog update(Catalog object) {
        object = em.merge(object);
        em.flush();
        return object;
    }

    public void persist(Catalog object) {
        em.persist(object);
        em.flush();
    }

    public Catalog merge(Catalog object) {
        return em.merge(object);
    }

    public void remove(Catalog object) {
        em.remove(object);
        em.flush();
    }

    public void clear() {
        em.clear();
    }

    public Catalog findByName(String catalogName) {
        try{
            return em.createQuery("select c from Catalog c where c.name = :name", Catalog.class)
                .setParameter("name", catalogName).getSingleResult();
        }catch( NoResultException e){
            return null;
        }
    }

    public void persist(Catalog catalog, CriteriaRoot criteriaRoot) {
        
        em.persist(catalog);
        em.persist(criteriaRoot);
        em.flush();

    }

}
```
Die Methode zum Speichern:

```
@Transactional
    public void saveCatalogPersistenceWork(){
        this.catalogDao.persist(this.catalog, this.criteriaRoot);
    }
```

Ich habe doch bei beiden die gleiche herangehendsweise und trotzdem funktioniert das erste DAO und das 2. wirft folgende Exception:

```
2011-08-12 10:27:57,166 ERROR org.ajax4jsf.webapp.BaseXMLFilter - Exception in the filter chain
javax.servlet.ServletException: #{catalogWizardController.saveNewCatalog}: javax.persistence.TransactionRequiredException: no transaction is in progress
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        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:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
        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:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        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:298)
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
        at java.lang.Thread.run(Thread.java:619)
Caused by: javax.faces.FacesException: #{catalogWizardController.saveNewCatalog}: javax.persistence.TransactionRequiredException: no transaction is in progress
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
        at javax.faces.component.UICommand.broadcast(UICommand.java:387)
        at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
        at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)
        at org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)
        at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)
        at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:474)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
        ... 54 more
Caused by: javax.faces.el.EvaluationException: javax.persistence.TransactionRequiredException: no transaction is in progress
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
        ... 64 more
Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
        at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:789)
        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.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
        at $Proxy68.flush(Unknown Source)
        at dao.catalog.CatalogDaoImpl.persist(CatalogDaoImpl.java:64)
        at controller.catalog.CatalogWizardController.saveNewCatalogPersistence(CatalogWizardController.java:211)
        at controller.catalog.CatalogWizardController.saveCatalogPersistenceWork(CatalogWizardController.java:217)
        at controller.catalog.CatalogWizardController.saveNewCatalog(CatalogWizardController.java:270)
        at controller.catalog.CatalogWizardController$$FastClassByCGLIB$$10c02459.invoke(<generated>)
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
        at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:617)
        at controller.catalog.CatalogWizardController$$EnhancerByCGLIB$$ab5a25aa.saveNewCatalog(<generated>)
        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.apache.el.parser.AstValue.invoke(AstValue.java:191)
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
        at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
        ... 65 more
```

Vielen Dank schonmal für eure schnelle Hilfe!!!


----------



## bluer (12. Aug 2011)

Der genaue Stack-Trace:

```
javax.persistence.TransactionRequiredException: no transaction is in progress
        at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:789)
        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.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
        at $Proxy68.flush(Unknown Source)
        at dao.catalog.CatalogDaoImpl.persist(CatalogDaoImpl.java:64)
        at controller.catalog.CatalogWizardController.saveNewCatalogPersistence(CatalogWizardController.java:211)
        at controller.catalog.CatalogWizardController.saveCatalogPersistenceWork(CatalogWizardController.java:217)
        at controller.catalog.CatalogWizardController.saveNewCatalog(CatalogWizardController.java:270)
        at controller.catalog.CatalogWizardController$$FastClassByCGLIB$$10c02459.invoke(<generated>)
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
        at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:617)
        at controller.catalog.CatalogWizardController$$EnhancerByCGLIB$$3ceade1d.saveNewCatalog(<generated>)
        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.apache.el.parser.AstValue.invoke(AstValue.java:191)
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
        at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
        at javax.faces.component.UICommand.broadcast(UICommand.java:387)
        at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
        at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)
        at org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)
        at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)
        at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:474)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
        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.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:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
        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:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        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:298)
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
        at java.lang.Thread.run(Thread.java:619)
```


----------



## bluer (15. Aug 2011)

Hatte keiner bisher ein ähnliches Problem? Hatte mittlerweile die Vermututng angestellt, dass es daran liegt, dass die Bean CatalogWizardController eine @Scope( value="session")-annotation hat, aber auch ohne diese Annotation bekomme ich den gleichen fehler. Am DAO CatalogDao kann es auch nicht liegen, da ich mit jedem anderen beliebigen DAO die gleiche Fehlermeldung bekomme. Demzufolge bleibt nur noch ein Fehler im Bean oder in der zugehörigen .jsp. Kann eine nicht gesetzte oder zuviel gesetzte <h:form>-Umgebung diesen Fehler auslösen?

Bitte dringend um Hilfe!


----------



## Noctarius (15. Aug 2011)

Bist du sicher, dass du die Annotation-driven Konfiguration, sowie AOP (das sieht man ja im Stacktrace, trotzdem mal kontrollieren) aktiviert hast?

Das kann eigentlich nur sein, dass das @Transactional nicht akzeptiert wird, dieses Annotation erzeugt nämlich automatisch eine Transaction falls noch keine existiert (im Threadcontext).

Irgendwie fehlt mir in deiner AppContext Config nämlich das tx:annotationDriven Zeugs

Abschnitt: 9.5.6. Using @Transactional
Chapter*9.*Transaction management

[xml]<tx:annotation-driven transaction-manager="transactionManager"/>[/xml]


----------



## bluer (15. Aug 2011)

Ich habe die Configs größtenteils von meinem Vorgänger bei diesem Projekt übernommen. Jedoch steht in Zeile 48 der Spring-Beans.xml:
[XML]
<tx:annotation-driven proxy-target-class="true" />
[/XML]

Danke schonmal für deine Mithilfe!!!


----------



## bluer (15. Aug 2011)

Vielen Vielen Dank Noctarius!!!!!!!!!!!!!! Das hat mein Problem gelöst. Ich war der Meinung, dass die Spring-Beans.xml korrekt war, da bisher auch alles lief. Mich wundert nun ein wenig, wie diese Exception bisher immer umgangen wurde und warum genaue diese Bean den "Schleichweg" nicht nehmen konnte??? Jetzt ist hoffentlich alles korrekt in meinen xml's. 

VIELEN VIELEN DANK NOCH EINMAL!!!


----------



## Noctarius (15. Aug 2011)

Habt ihr eventuell die JPA Implementierung oder den Transaction Manager gewechselt?


----------



## bluer (15. Aug 2011)

Weder noch. Das einzige, was ich zu der Konfiguration hinzugefügt habe, ist das OpenSessionInViewPattern, sonst ist alles so woe es vorher war. Eine zusätzliche große Änderung ist, dass fast die komplette Applikation so umgeschrieben wird, dass es so gut wie keine Request's gibt. Es wird momentan nur noch zum Einloggen ein Request durchgeführt. Alles andere läuft mit Ajax.


----------



## Noctarius (15. Aug 2011)

Hm dann KA, aber egal, hauptsache es läuft wieder


----------

