I'm getting the following exception when trying to persist data using a jta
configured data source
<openjpa-2.2.0-r422266:1244990 fatal general error>
org.apache.openjpa.persistence.PersistenceException: invalid authorization
specification - not found: root
My datasource is listed in tomee.xml
<Resource id="jdbc/mysql" type="javax.sql.DataSource">
# configure the pool
DataSourceCreator = tomcat
# it is a jta datasource
JtaManaged = true
# tomcat pool configuration
driverClassName = com.mysql.jdbc.Driver
url =
jdbc:mysql://localhost:3306/adaptiveauth?noAccessToProcedureBodies=true
username = root
password = *******
validationQuery = SELECT 1
maxActive=4
maxIdle=2
maxWait=-1
jmxEnabled = true # specific to tomcat pooling
</Resource>
My persistence.xml is
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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_2_0.xsd">
<persistence-unit name="analyticsPU" transaction-type="JTA">
<jta-data-source>jdbc/mysql</jta-data-source>
<properties>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(foreignKeys=true,schemaAction='dropDB,add')"/>
<property name="openjpa.jdbc.SchemaFactory"
value="native(foreignKeys=true)" />
<property name="openjpa.jdbc.MappingDefaults"
value="ForeignKeyDeleteAction=restrict,
JoinForeignKeyDeleteAction=restrict"/>
<property name="openjpa.Log" value="DefaultLevel=TRACE,SQL=TRACE" />
</properties>
</persistence-unit>
</persistence>
My web.xml has
<persistence-unit-ref>
<persistence-unit-ref-name>persistence-factory</persistence-unit-ref-name>
<persistence-unit-name>analyticsPU</persistence-unit-name>
</persistence-unit-ref>
Code to create EntityManagerFactory
return (EntityManagerFactory) new
InitialContext().lookup("java:comp/env/persistence-factory");
Below is the log trace for openjpa when trying to open a connection
13776 analyticsPU INFO [http-bio-10080-exec-1] openjpa.Runtime -
Starting OpenJPA 2.2.0
13777 analyticsPU TRACE [http-bio-10080-exec-1] 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: true
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: analyticsPU
openjpa.IgnoreChanges: false
openjpa.InitializeEagerly: false
openjpa.InstrumentationManager: default
openjpa.InverseManager: false
openjpa.LifecycleEventManager: validating
openjpa.LockManager: mixed
openjpa.Log: true(DefaultLevel=TRACE,SQL=TRACE)
openjpa.ManagedRuntime: auto
openjpa.MaxFetchDepth: -1
openjpa.MetaDataFactory:
jpa(Files=/C:/opt/tomcat7/webapps/analytics/WEB-INF/classes/)
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: 0
openjpa.SavepointManager: in-mem
openjpa.Sequence: table
openjpa.TransactionMode: true
openjpa.WriteLockLevel: 20
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(ForeignKeyDeleteAction=restrict,
JoinForeignKeyDeleteAction=restrict)
openjpa.jdbc.QuerySQLCache: true
openjpa.jdbc.ResultSetType: 1003
openjpa.jdbc.SQLFactory: default
openjpa.jdbc.SchemaFactory: native(foreignKeys=true)
openjpa.jdbc.Schemas: []
openjpa.jdbc.SubclassFetchMode: 1
openjpa.jdbc.SynchronizeMappings:
buildSchema(foreignKeys=true,schemaAction='dropDB,add')
openjpa.jdbc.TransactionIsolation: -1
openjpa.jdbc.UpdateManager: default
13814 analyticsPU TRACE [http-bio-10080-exec-1] openjpa.Runtime - No
cache marshaller found for id
org.apache.openjpa.conf.MetaDataCacheMaintenance.
13903 analyticsPU TRACE [http-bio-10080-exec-1] openjpa.MetaData - Using
metadata factory
"org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory@1da817b".
13907 analyticsPU TRACE [http-bio-10080-exec-1] openjpa.jdbc.JDBC -
OpenJPA will now connect to the database to attempt to determine what type
of database dictionary to use. You may prevent this connection in the future
by setting your openjpa.jdbc.DBDictionary configuration property to the
appropriate value for your database (see the documentation for available
values).
13921 analyticsPU TRACE [http-bio-10080-exec-1] openjpa.jdbc.JDBC -
createConnectionFactory:
DataSource:org.apache.openejb.resource.jdbc.managed.local.ManagedDataSource@121f653
Oct 1, 2012 10:44:46 AM org.hsqldb.persist.Logger logInfoEvent
INFO: checkpointClose start
Oct 1, 2012 10:44:46 AM org.hsqldb.persist.Logger logInfoEvent
INFO: checkpointClose end
14503 analyticsPU TRACE [http-bio-10080-exec-1] openjpa.Runtime - No
cache marshaller found for id
org.apache.openjpa.conf.MetaDataCacheMaintenance.
14503 analyticsPU TRACE [http-bio-10080-exec-1] openjpa.MetaData - Using
metadata factory
"org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory@1613fe7".
14503 analyticsPU TRACE [http-bio-10080-exec-1] openjpa.jdbc.JDBC -
OpenJPA will now connect to the database to attempt to determine what type
of database dictionary to use. You may prevent this connection in the future
by setting your openjpa.jdbc.DBDictionary configuration property to the
appropriate value for your database (see the documentation for available
values).
14523 analyticsPU TRACE [http-bio-10080-exec-1] openjpa.jdbc.JDBC -
createConnectionFactory:
DataSource:org.apache.openejb.resource.jdbc.managed.local.ManagedDataSource@121f653
Oct 1, 2012 10:44:46 AM
com.adaptiveauth.rest.server.resources.InspectionResourceBase postInspection
INFO: <openjpa-2.2.0-r422266:1244990 fatal general error>
org.apache.openjpa.persistence.PersistenceException: invalid authorization
specification - not found: root
Don't know what kind of authorization is required for my user 'root' since
that user has all privileges on the database.
--
View this message in context:
http://openejb.979440.n4.nabble.com/Getting-a-persistence-exception-using-openjpa-jta-datasource-tp4657731.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.