Announcement Announcement Module
Collapse
No announcement yet.
No insert Data with Spring WS + OPENJPA Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No insert Data with Spring WS + OPENJPA

    Hi all,

    I am developping an application with Spring WS + OPEN JPA + MySQL and I try to insert a data into my database. And my problem is when I call the function which insert Data, I have no data inserted. I have no exception and I have a response from web service like the data is inserted.

    I have searched a rollback into the logs but I don't find it.

    So I don't why it doesn't work.

    This is the ApplicationContext.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns="http://www.springframework.org/schema/beans" xmlns:tx="http://www.springframework.org/schema/tx"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    
    	<!-- ******************************************************************** -->
    	<!-- Mark bean transactions as annotation driven -->
    	<!-- ******************************************************************** -->
    	<tx:annotation-driven transaction-manager="transactionManager" />
    
    	<!-- ******************************************************************** -->
    	<!-- PropertyConfigurer for the DAO -->
    	<!-- ******************************************************************** -->
    	<bean id="propertyConfigurer"
    		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="location" value="classpath:db.properties" />
    	</bean>
    
    	<!-- ******************************************************************** -->
    	<!-- Setup the transaction manager -->
    	<!-- ******************************************************************** -->
    	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory" />
    	</bean>
    
    	<!-- ******************************************************************** -->
    	<!-- Setup each data source -->
    	<!-- ******************************************************************** -->
    	<bean id="dataSource"
    		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="driverClassName" value="${connection.driver_class}" />
    		<property name="url" value="${connection.url}" />
    		<property name="username" value="${connection.username}" />
    		<property name="password" value="${connection.password}" />
    	</bean>
    
    	<!-- ******************************************************************** -->
    	<!-- Setup each persistence unit -->
    	<!-- ******************************************************************** -->
    
    	<!-- Configure a JPA vendor adapter -->
    	<bean id="openJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
    		<property name="showSql" value="${connection.show_sql}" />
    		<property name="generateDdl" value="${connection.generateDdl}" />
    		<property name="databasePlatform" value="${connection.dialect}" />
    	</bean>
    
    	<!-- EntityManager Factory that brings together the persistence unit, datasource, 
    		and JPA Vendor -->
    	<bean id="entityManagerFactory"
    		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="dataSource" ref="dataSource" />
    		<property name="jpaVendorAdapter" ref="openJpaVendorAdapter" />
    		<property name="persistenceUnitName" value="aquamoni-persistence-unit" />
    
    		<property name="loadTimeWeaver">
    			<bean
    				class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
    		</property>
    	</bean>
    	<bean id="sharedEntityManager"
    		class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
    		<property name="entityManagerFactory" ref="entityManagerFactory" />
    	</bean>
    </beans>
    This is the persistence.xml :
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    	version="1.0">
    	<persistence-unit name="aquamoni-persistence-unit"
    		transaction-type="RESOURCE_LOCAL">
    		<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
    		<class>com.aquamoni.aquaco.domain.JpaUser</class>
    		<class>com.aquamoni.aquaco.domain.JpaAquarium</class>
    		<class>com.aquamoni.aquaco.domain.JpaProbeSettings</class> 
    		<class>com.aquamoni.aquaco.domain.JpaProbeType</class>
    		<class>com.aquamoni.aquaco.domain.JpaProbeData</class>
    		<properties>
    			<property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=TRACE, Tool=INFO" />
    		</properties>
    	</persistence-unit>
    </persistence>
    And this is my DAO which inserts data :
    Code:
    ...
    @Repository
    public class AquariumDAOImpl implements AquariumDAO {
    
    	@PersistenceContext
    	private EntityManager entityManager;
    
    	...
    	
    	@Override
    	@Transactional
    	public void saveProbeData(JpaProbeData probeData) {
            entityManager.persist(probeData);
    	}
    
    }
    Someone knows where is the problem ?

    Thanks in advance.

  • #2
    This is my logs :
    Code:
    2013-07-23 21:55:55.268:/Aquaco:INFO:  Initializing Spring FrameworkServlet 'spring-ws'
    2013-07-23 21:55:55,020 INFO [org.springframework.ws.transport.http.MessageDispatcherServlet] - FrameworkServlet 'spring-ws': initialization started
    2013-07-23 21:55:55,024 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Refreshing WebApplicationContext for namespace 'spring-ws-servlet': startup date [Tue Jul 23 21:55:55 CEST 2013]; parent: Root WebApplicationContext
    2013-07-23 21:55:55,026 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-ws-servlet.xml]
    2013-07-23 21:55:55,200 INFO [org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping] - Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
    2013-07-23 21:55:55,203 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@27b06d5b: defining beans [aquariumDAOImpl,databaseInitializer,aquacoServiceImpl,aquacoEndpoint,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping#0,org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping#0,org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping#0,org.springframework.ws.server.endpoint.adapter.method.dom.DomPayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.method.SourcePayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.method.jaxb.XmlRootElementPayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.method.jaxb.JaxbElementPayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter#0,org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver#0,org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver#0,org.springframework.xml.xsd.SimpleXsdSchema#0,aquaco,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@1b0c366b
    8482  aquamoni-persistence-unit  INFO   [qtp0-0] openjpa.Runtime - Starting OpenJPA 2.2.2
    8483  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - Properties: javax.persistence.lock.timeout: 0
    javax.persistence.query.timeout: 0
    javax.persistence.sharedCache.mode: UNSPECIFIED
    javax.persistence.validation.group.pre-persist: javax.validation.groups.Default
    javax.persistence.validation.group.pre-update: javax.validation.groups.Default
    javax.persistence.validation.mode: AUTO
    openjpa.AutoClear: 0
    openjpa.AutoDetach: []
    openjpa.BrokerFactory: jdbc
    openjpa.BrokerImpl: non-finalizing
    openjpa.CacheDistributionPolicy: default
    openjpa.Callbacks: default
    openjpa.ClassResolver: org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl
    openjpa.Compatibility: default
    openjpa.ConnectionFactoryMode: false
    openjpa.ConnectionRetainMode: 0
    openjpa.DataCache: false
    openjpa.DataCacheManager: default
    openjpa.DataCacheTimeout: -1
    openjpa.DetachState: loaded
    openjpa.DynamicDataStructs: false
    openjpa.DynamicEnhancementAgent: true
    openjpa.EntityManagerFactory: default
    openjpa.FetchBatchSize: -1
    openjpa.FetchGroups: [default]
    openjpa.FlushBeforeQueries: 0
    openjpa.Id: aquamoni-persistence-unit
    openjpa.IgnoreChanges: false
    openjpa.InitializeEagerly: false
    openjpa.InstrumentationManager: default
    openjpa.InverseManager: false
    openjpa.LifecycleEventManager: default
    openjpa.LockManager: mixed
    openjpa.Log: true(DefaultLevel=WARN, Runtime=TRACE, Tool=INFO)
    openjpa.ManagedRuntime: auto
    openjpa.MaxFetchDepth: -1
    openjpa.MetaDataFactory: jpa(Files=/C:/Users/Nicolas/Dropbox/workspace/java/Aquaco/target/classes, Types=com.aquamoni.aquaco.domain.JpaUser;com.aquamoni.aquaco.domain.JpaAquarium;com.aquamoni.aquaco.domain.JpaProbeSettings;com.aquamoni.aquaco.domain.JpaProbeType;com.aquamoni.aquaco.domain.JpaProbeData)
    openjpa.MetaDataRepository: default
    openjpa.Multithreaded: false
    openjpa.NontransactionalRead: true
    openjpa.NontransactionalWrite: true
    openjpa.Optimistic: true
    openjpa.OptimizeIdCopy: false
    openjpa.OrphanedKeyAction: log
    openjpa.PostLoadOnMerge: false
    openjpa.ProxyManager: default
    openjpa.QueryCache: false
    openjpa.QueryCompilationCache: true
    openjpa.ReadLockLevel: 10
    openjpa.RefreshFromDataCache: false
    openjpa.RestoreState: 1
    openjpa.RetainState: true
    openjpa.RetryClassRegistration: false
    openjpa.RuntimeUnenhancedClasses: 1
    openjpa.SavepointManager: in-mem
    openjpa.Sequence: table
    openjpa.TransactionMode: false
    openjpa.WriteLockLevel: 20
    openjpa.jdbc.DBDictionary: mysql
    openjpa.jdbc.DriverDataSource: auto
    openjpa.jdbc.EagerFetchMode: 2
    openjpa.jdbc.FetchDirection: 1000
    openjpa.jdbc.FinderCache: true
    openjpa.jdbc.IdentifierUtil: default
    openjpa.jdbc.LRSSize: 2
    openjpa.jdbc.MappingDefaults: jpa
    openjpa.jdbc.QuerySQLCache: true
    openjpa.jdbc.ResultSetType: 1003
    openjpa.jdbc.SQLFactory: default
    openjpa.jdbc.SchemaFactory: dynamic
    openjpa.jdbc.Schemas: []
    openjpa.jdbc.SubclassFetchMode: 1
    openjpa.jdbc.SynchronizeMappings: buildSchema(ForeignKeys=true)
    openjpa.jdbc.TransactionIsolation: -1
    openjpa.jdbc.UpdateManager: default
    8483  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - No cache marshaller found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
    9092  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - No cache marshaller found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
    9162  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - Found datasource 2: null from config. StoreContext: null
    9162  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - Trying datasource1
    9162  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - Found datasource1: datasource 1131563092 from configuration. StoreContext: null
    9164  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - Found datasource 2: null from config. StoreContext: null
    9164  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - Trying datasource1
    9164  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - Found datasource1: datasource 1131563092 from configuration. StoreContext: null
    9438  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - Found datasource1: datasource 1131563092 from configuration. StoreContext: org.apache.openjpa.kernel.BrokerImpl@65b051a5
    9451  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - org.apache.openjpa.persistence.EntityManagerFactoryImpl@798aed7e created EntityManager org.apache.openjpa.persistence.EntityManagerImpl@65b051a5.
    2013-07-23 21:55:56,420 INFO [com.aquamoni.aquaco.dao.jpa.DatabaseInitializer] - Initializing Database
    9473  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - [email protected]() invoked.
    2013-07-23 21:55:56,595 INFO [org.springframework.ws.soap.saaj.SaajSoapMessageFactory] - Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
    2013-07-23 21:55:56,600 INFO [org.springframework.ws.transport.http.MessageDispatcherServlet] - FrameworkServlet 'spring-ws': initialization completed in 1579 ms
    9747  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - Found datasource1: datasource 1131563092 from configuration. StoreContext: org.apache.openjpa.kernel.BrokerImpl@3b7aefd7
    9747  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - org.apache.openjpa.persistence.EntityManagerFactoryImpl@798aed7e created EntityManager org.apache.openjpa.persistence.EntityManagerImpl@3b7aefd7.
    9766  aquamoni-persistence-unit  TRACE  [qtp0-0] openjpa.Runtime - [email protected]() invoked.

    Comment

    Working...
    X