cancel
Showing results for 
Search instead for 
Did you mean: 

activiti 5.0rc1 JPA Examples

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Hello

I get an exception when running JPAVariableTest included in the examples

20:48:36,250 INF  | ProcessEngine default created  [org.activiti.engine.impl.ProcessEngineImpl]
20:48:36,250 SEV  |                                                                                              [org.activiti.engine.impl.test.ActivitiInternalTestCase]
20:48:36,468 INF  | Processing resource org/activiti/examples/variables/jpa/JPAVariableTest.testStoreJPAEntityAsVariable.bpmn20.xml  [org.activiti.engine.impl.bpmn.deployer.BpmnDeployer]
20:48:37,078 INF  | XMLSchema currently not supported as typeLanguage  [org.activiti.engine.impl.bpmn.parser.BpmnParse]
20:48:37,078 INF  | XPath currently not supported as typeLanguage  [org.activiti.engine.impl.bpmn.parser.BpmnParse]
32  WARN   [main] openjpa.Runtime - The configuration property named "openjpa.Id" was not recognized and will be ignored, although the name closely matches a valid property called "openjpa.Id".
391  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.2.2
20:48:38,781 SEV  |                                                                                              [org.activiti.engine.impl.test.PvmTestCase]
20:48:38,781 SEV  | EXCEPTION: <openjpa-1.2.2-r422266:898935 fatal user error> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
<openjpa-1.2.2-r422266:898935 fatal user error> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
   at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:74)
   at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:784)
   at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:561]

Do I have to configure jdbc somewhere?
I am new to JPA and i am sure i missed out something.

Thank you
parul
11 REPLIES 11

frederikherema1
Star Contributor
Star Contributor
Hi parul,

Thanks for pointing that out! A file wasn't shipped with the distro examples, which causes this error you reported. In the next release which ships next week somewhere, this will be fixed.

For now, you can just add persistence.xml file manually to the /src/ folder in engine-examples, in folder 'META-INF':
/src/META-INF/persistence.xml

containing the folowing:
<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="activiti-jpa-pu">
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
   
    <class>org.activiti.examples.variables.jpa.FieldAccessJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.PropertyAccessJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.SubclassFieldAccessJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.SubclassPropertyAccessJPAEntity</class>
    <!– Mapped superclasses –>
    <class>org.activiti.examples.variables.jpa.MappedSuperClassFieldAccessJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.MappedSuperClassPropertyAccessJPAEntity</class>
   
    <!– Variable types –>
    <class>org.activiti.examples.variables.jpa.ByteIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.ShortIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.IntegerIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.LongIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.FloatIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.DoubleIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.CharIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.StringIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.DateIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.SQLDateIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.BigIntegerIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.BigDecimalIdJPAEntity</class>
   
    <!– Exceptional entities –>
    <class>org.activiti.examples.variables.jpa.CompoundIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.EmbeddableCompoundId</class>
   
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
      <property name="openjpa.ConnectionURL" value="jdbc:h2:mem:activiti-jpa;DB_CLOSE_DELAY=1000"/>
      <property name="openjpa.ConnectionDriverName" value="org.h2.Driver"/>
      <property name="openjpa.ConnectionUserName" value="sa"/>
      <property name="openjpa.ConnectionPassword" value=""/>
      <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(SchemaAction='add,deleteTableContents')"/>
    </properties>
  </persistence-unit>
</persistence>

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Thanks for your reply.

I copied the code to persistence.xml in src directory., but i still get the same error.
Please help

parul

frederikherema1
Star Contributor
Star Contributor
Is it in the /src/META-INF/ folder? Are you running the tests from eclipse? Make sure the META-INF is included on test-classpatch when running the test.

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
ok my mistake., now i placed in src/META-INF folder. now i get another exception.

yes i am running examples from eclipse. i have attached  console logs.
thanks
parul

frederikherema1
Star Contributor
Star Contributor
Looks like the test for a primary key of type BigDecimal goes wrong, value too large… Strange, because open JPA creates the table itself, should be big enough.

I see you are using MySQL, right? Did you alter the configuration for the datasource used by the entitymanager? If so, can you post it?

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
persistence.xml code


<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="activiti-jpa-pu">
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
   
    <class>org.activiti.examples.variables.jpa.FieldAccessJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.PropertyAccessJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.SubclassFieldAccessJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.SubclassPropertyAccessJPAEntity</class>
    <!– Mapped superclasses –>
    <class>org.activiti.examples.variables.jpa.MappedSuperClassFieldAccessJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.MappedSuperClassPropertyAccessJPAEntity</class>
   
    <!– Variable types –>
    <class>org.activiti.examples.variables.jpa.ByteIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.ShortIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.IntegerIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.LongIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.FloatIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.DoubleIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.CharIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.StringIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.DateIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.SQLDateIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.BigIntegerIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.BigDecimalIdJPAEntity</class>
   
    <!– Exceptional entities –>
    <class>org.activiti.examples.variables.jpa.CompoundIdJPAEntity</class>
    <class>org.activiti.examples.variables.jpa.EmbeddableCompoundId</class>
   
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
      <property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/activiti"/>
      <property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
      <property name="openjpa.ConnectionUserName" value="activiti"/>
      <property name="openjpa.ConnectionPassword" value="activiti"/>
      <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(SchemaAction='add,deleteTableContents')"/>
    </properties>
  </persistence-unit>
</persistence>

Thank u

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
apart from persistence.xml, i have not changed any other code from examples.

I see many entity tables are created in the db.

thanks

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Even If I set the value of bigdecimal to a small one

    bigDecimalIdJPAEntity = new BigDecimalIdJPAEntity();
    bigDecimalIdJPAEntity.setBigDecimalId(new BigDecimal("123456789.12345"));
    manager.persist(bigDecimalIdJPAEntity);

It gave me many exceptions
console log is attached., pl help

Thank you
parul

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Hello again,

Is this a bug or i made a mistake somewhere?
Please help.

Thank you

parul