Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9291149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:34:52+00:00 2026-06-18T20:34:52+00:00

I have a webapp that uses the stack Spring, JPA(Hibernate impl) and Vaadin 7

  • 0

I have a webapp that uses the stack Spring, JPA(Hibernate impl) and Vaadin 7 on a Tomcat 7 server. The problem is that the entity manager is not persisting entity’s. Also, no error/exception is thrown. I think this question can hold the answer, but I’m not sure.

To use Vaadin 7 with Spring I use the Spring Vaadin addon.

Because the number of files, here is an overview:

  • src / main / webapp / META-INF / context.xml
  • src / main / webapp / WEB-INF / web.xml
  • src / main / webapp / WEB-INF / application-context.xml
  • src / main / java / com / ks / places / MyUI.java (autowires placeService and creates Place entity)
  • src / main / java / com / ks / places / model / Place.java (the entity in question)
  • src / main / java / com / ks / places / dao / PlaceDao.java
  • src / main / java / com / ks / places / dao / PlaceDaoImpl.java
  • src / main / java / com / ks / places / service / PlaceService.java
  • src / main / java / com / ks / places / service / PlaceServiceImpl.java

This is my code:

WEB-INF/web.xml

<!-- Spring -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/application-context.xml</param-value>
</context-param>

<!-- Vaadin servlet -->
<servlet>
    <servlet-name>Vaadin Application Servlet</servlet-name>
    <servlet-class>ru.xpoft.vaadin.SpringVaadinServlet</servlet-class>
    <init-param>
        <description>Vaadin UI to display</description>
        <param-name>beanName</param-name>
        <param-value>myUI</param-value>
    </init-param>
    <init-param>
        <param-name>systemMessagesBeanName</param-name>
        <param-value>DEFAULT</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>Vaadin Application Servlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Vaadin Application Servlet</servlet-name>
    <url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>

<!-- Vaadin Production/debug mode -->
<context-param>
    <description>Vaadin production mode</description>
    <param-name>productionMode</param-name>
    <param-value>false</param-value>
</context-param>

<!-- JNDI datasource -->
<resource-ref>
    <description>JNDI Datasource</description>
    <res-ref-name>jdbc/placesPU</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

WEB-INF/application-config.xml (Spring config)

<!-- component scan for @Component, @Repositry, @Service -->
<context:component-scan base-package="com.ks.places" />

<!-- Activates various annotations to be detected in bean classes for eg @Autowired -->
<context:annotation-config />

<jee:jndi-lookup id="jndiDataSource" jndi-name="jdbc/placesPU" resource-ref="true" expected-type="javax.sql.DataSource" />

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="placesPU" />
    <property name="dataSource" ref="jndiDataSource" />
    <property name="packagesToScan" value="com.ks.places.model" />

    <!-- this is important to connect JPA and JdbcTemplate transaction control -->
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="database" value="MYSQL" />
            <property name="showSql" value="true" />
        </bean>
    </property>

</bean>

<bean id="hibernateJpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />

<!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
<bean id='transactionManager' class='org.springframework.orm.jpa.JpaTransactionManager'>
    <property name='entityManagerFactory' ref='entityManagerFactory' />
    <property name="jpaDialect" ref="hibernateJpaDialect" />
</bean>

<!-- enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" proxy-target-class="true" />

<!-- Spring's exception translation -->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

<!-- Spring container will act as a JPA container and inject an EnitityManager from your EntityManagerFactory -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

<bean class="ru.xpoft.vaadin.VaadinMessageSource" />

META-INF/context.xml (Tomcat context file)

<Context antiJARLocking="true" path="/Places">

<Resource   name="jdbc/placesPU" 
            auth="Container"
            type="javax.sql.DataSource" 
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://192.168.1.36:3306/places"
            username="root"
            password="pass" 
            removeAbandoned="true" 
            removeAbandonedTimeout="90"
            logAbandoned="true" 
            maxActive="20" 
            maxIdle="10" 
            maxWait="-1" />

</Context>

PlaceDao.java

public interface PlaceDao {

    public void save(Place place);

}

PlaceDaoImpl.java

@Repository("placeDao")
public class PlaceDaoImpl implements PlaceDao {

    // @PersistenceContext(unitName="placesPU") // also tried this
    private EntityManager entityManager;

    public EntityManager getEntityManager() {
        return entityManager;
    }

    @PersistenceContext(unitName="placesPU")
    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }

    @Override
    public void save(Place place) {
        entityManager.persist(place);
        entityManager.flush(); <- gives an TransactionRequiredException exception
    }

}

PlaceService.java

public interface PlaceService {

    void save(Place place);

}

PlaceServiceImpl.java

//@Transactional(propagation = Propagation.REQUIRED, readOnly = false) // also tried this
@Service("placeService")    
public class PlaceServiceImpl implements PlaceService {

    @Autowired
    private PlaceDao placeDao;

    //@Transactional // also tried this
    @Transactional(propagation= Propagation.REQUIRED, readOnly=false)
    @Override
    public void save(Place place) {
        placeDao.save(place);
    }

}

MyUI.java

@Component
@Scope("prototype")
public class MyUI extends UI implements Serializable {

    private static final long serialVersionUID = 1L;

    @Autowired
    private PlaceService placeService;

    @Override
    protected void init(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        Button button = new Button("Click Me");
        button.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

                Place place = new Place();
                place.setName("vandaag");

                placeService.save(place);

                // No entity was added to the database...

            }
        });
        layout.addComponent(button);
    }

}

The transaction

When I persist the Place entity (placeService.save() in MyUI.java) I do not get any error or exception. But, when I manually try to flush the entityManager I do get an error:

Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:983)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:366)
at $Proxy16.flush(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:241)
at $Proxy16.flush(Unknown Source)
at com.ks.places.dao.PlaceDaoImpl.save(PlaceDaoImpl.java:44)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:34:54+00:00Added an answer on June 18, 2026 at 8:34 pm

    The exception clearly says, that your @Transactional annotation is not taken into account at all.

    I suggest you remove the mode="aspectj" from <tx:annotation-driven ... />:

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

    The default mode is proxy. For aspectj you need full AspectJ-support (and I currently don’t see a reason why you should need that). AspectJ weaving requires spring-aspects.jar on the classpath, as well as load-time weaving (or compile-time weaving) enabled.

    (And by the way you don’t need proxy-target-class="true" as you have interfaces for you services.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spring web app that uses Hibernate and Velocity. It's an MVC
I have a Spring MVC webapp that uses Spring Security. I want to add
I have an existing java webapp that uses Hibernate for it's persistence. I've been
I had a perfectly working webapp that uses Tomcat and Hibernate + c3p0. I'm
I have a Tomcat webapp that uses Hibernation Configuration, the code below silently fails
I have a webapp that uses SpringMVC DispatcherServlet to load a WebApplicationContext. The Spring
I have a web-app with a Java back-end that uses Tomcat jdbc-pool for database
multiple webapp running on same tomcat using same jvm. sometime, one webapp that have
I am working on a webapp that uses both the Spring Framework and RESTEasy.
I have an iPhone webapp that uses a cache manifest to work offline. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.