AnsweredAssumed Answered

Exception JPA Entity does not exist

Question asked by jdupont1 on Dec 20, 2011
I try to use a service task with JPA entity variable ! When i process my diagram i have the following error :


org.activiti.engine.ActivitiException: Entity does not exist: com.francetelecom.oncc.business.model.ClientAccount - 0
   at org.activiti.engine.impl.variable.JPAEntityMappings.findEntity(JPAEntityMappings.java:130)
   at org.activiti.engine.impl.variable.JPAEntityMappings.getJPAEntity(JPAEntityMappings.java:119)
   at org.activiti.engine.impl.variable.JPAEntityVariableType.getValue(JPAEntityVariableType.java:77)
   at org.activiti.engine.impl.persistence.entity.VariableInstanceEntity.getValue(VariableInstanceEntity.java:158)
   at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.getVariable(VariableScopeImpl.java:93)
   at org.activiti.engine.impl.el.VariableScopeElResolver.getValue(VariableScopeElResolver.java:65)
   at org.activiti.engine.impl.javax.el.CompositeELResolver.getValue(CompositeELResolver.java:231)
   at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:81)

The "CreateClientAccount" bpmn code :


<process id="CreateClientAccount" name="CreateClientAccount">
    <documentation>Place documentation for the 'CreateClientAccount' process here.</documentation>
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="createClientAccount" name="Create client account" activiti:expression="${activitiClientAccountService.addClientAccount(clientAccount.name)}"></serviceTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="createClientAccount"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" name="" sourceRef="createClientAccount" targetRef="endevent1"></sequenceFlow>
  </process>

activiti:expression="${activitiClientAccountService.addClientAccount(clientAccount.name)}"

The activitiClientAccountService :


@Service("activitiClientAccountService")
public class ActivitiClientAccountServiceImpl implements ActivitiClientAccountService {

   private static final Logger LOGGER = Logger.getLogger(ActivitiClientAccountServiceImpl.class);
   
   @Autowired
   private RuntimeService runtimeService;
   
   @Override
   @Transactional
   public String runAddClientAccount(final ClientAccount clientAccount, final ClientAccountSAV clientAccountSAV, final User referent) {
      final Map<String, Object> parameters = new HashMap<String, Object>();
      parameters.put("clientAccount", clientAccount);
      parameters.put("clientAccountSAV", clientAccountSAV);
      parameters.put("referent", referent);
      
      return runtimeService.startProcessInstanceByKey("CreateClientAccount", parameters).getProcessInstanceId();
   }
   
   @Override
   public void addClientAccount(final String clientAccountName) {
      LOGGER.info("addClientAccount : ");
      LOGGER.info("clientAccountName : "+clientAccountName);
   }
}

My Spring configuration :

Business-orchestration module (Maven)


   <context:component-scan base-package="xxx.business.orchestration.*" />

   <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
      <property name="databaseType" value="oracle" />
      <property name="dataSource" ref="modelDataSource" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="databaseSchemaUpdate" value="true" />
      <property name="jpaEntityManagerFactory" ref="entityManagerFactory" />
      <property name="jpaHandleTransaction" value="true" />
      <property name="jpaCloseEntityManager" value="true" />
      <property name="jobExecutorActivate" value="false" />
      <property name="deploymentResources" value="classpath*:diagram/*.bpmn20.xml" />
   </bean>

   <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
      <property name="processEngineConfiguration" ref="processEngineConfiguration" />
   </bean>

   <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
   <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
   <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
   <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
   <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
   <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />

Business-core module (Maven)


   <jee:jndi-lookup id="modelDataSource" jndi-name="${jndi.lookup.business.model}" />
   
   <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean>   
           <property name="dataSource" ref="modelDataSource" />
             <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                        <property name="database" value="ORACLE"/>
                        <property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect"/>
                        <property name="showSql" value="false"/>
                        <property name="generateDdl" value="true"/>
                </bean>
           </property>
           <property name="persistenceUnitName" value="myUnit" />
   </bean>       

   <context:component-scan base-package=xxx.business.core.*"/>

   <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
           <property name="entityManagerFactory" ref="entityManagerFactory" />
   </bean>
   
   <tx:annotation-driven transaction-manager="transactionManager"/>

Persistence.xml


<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="myUnit" transaction-type="RESOURCE_LOCAL">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      
      <class>xxx.business.model.ClientAccount</class>
      <class>xxx.business.model.ClientAccountSAV</class>
      <class>xxx.business.model.DataCenter</class>
      <class>xxx.business.model.DCCell</class>   
                <class>…</class>   
   </persistence-unit>
</persistence>

Outcomes