Author: alex.guizar(a)jboss.com
Date: 2010-09-09 23:39:56 -0400 (Thu, 09 Sep 2010)
New Revision: 6655
Added:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2908/
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2908/ChangeJbpmConfigurationAction.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2908/JBPM2908Test.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/jbpm1.cfg.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/jbpm2.cfg.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/processdefinition1.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/processdefinition2.xml
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/scripts/antrun-config.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
Log:
JBPM-2908 prevent stack overflow when parsing alternate configuration resource from action
handler;
remember JbpmConfiguration in which ProcessClassLoader was created
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml 2010-09-09 16:22:28 UTC (rev 6654)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml 2010-09-10 03:39:56 UTC (rev 6655)
@@ -163,6 +163,7 @@
<configuration>
<tasks>
<property name="database" value="${database}"
/>
+ <property name="project.output.dir"
value="${project.build.outputDirectory}" />
<ant antfile="scripts/antrun-config.xml"
target="gen-hibernate-config" />
</tasks>
</configuration>
@@ -194,6 +195,85 @@
</profile>
<!--
+ Name: no-database
+ Desc: Default Database Setup
+ -->
+ <profile>
+ <id>no-database</id>
+ <activation>
+ <property>
+ <name>!database</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>no-hibernate-auto-create</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="project.output.dir"
+ value="${project.build.outputDirectory}" />
+ <property name="project.test.output.dir"
+ value="${project.build.testOutputDirectory}" />
+ <ant antfile="scripts/antrun-config.xml"
+ target="gen-hibernate-config-no-auto" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!--
+ Name: hsqldb
+ Desc: Hypersonic Database Setup
+ -->
+ <profile>
+ <id>hsqldb</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>hsqldb</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>no-hibernate-auto-create</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="project.output.dir"
+ value="${project.build.outputDirectory}" />
+ <property name="project.test.output.dir"
+ value="${project.build.testOutputDirectory}" />
+ <ant antfile="scripts/antrun-config.xml"
+ target="gen-hibernate-config-no-auto" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!--
Name: db2
Desc: DB2 Test Exclusions
-->
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/scripts/antrun-config.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/scripts/antrun-config.xml 2010-09-09 16:22:28
UTC (rev 6654)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/scripts/antrun-config.xml 2010-09-10 03:39:56
UTC (rev 6655)
@@ -8,10 +8,9 @@
<!-- ====================================================================== -->
<project name="gen-config">
+ <property name="project.output.dir"
value="${basedir}/target/classes" />
+ <property name="project.test.output.dir"
value="${basedir}/target/classes" />
- <property name="project.build.directory"
value="${basedir}/target" />
- <property name="build.resources.directory"
value="${basedir}/target/classes" />
-
<macrodef name="macro-disable">
<attribute name="file" />
<attribute name="section" />
@@ -41,7 +40,7 @@
<attribute name="database" />
<sequential>
<available property="(a){database}.properties.available"
-
file="${build.resources.directory}/hibernate.properties.(a){database}.xml" />
+
file="${project.output.dir}/hibernate.properties.(a){database}.xml" />
<fail message="hibernate.properties.(a){database}.xml not available"
unless="(a){database}.properties.available" />
@@ -49,11 +48,11 @@
value="hibernate.mapping.(a){database}.xml"
else="hibernate.mapping.default.xml">
<available property="(a){database}.mapping.available"
-
file="${build.resources.directory}/hibernate.mapping.(a){database}.xml" />
+
file="${project.output.dir}/hibernate.mapping.(a){database}.xml" />
</condition>
<!-- concatenate hibernate.cfg.xml -->
- <concat
destfile="${project.build.directory}/classes/hibernate.cfg.(a){database}.xml"
+ <concat
destfile="${project.output.dir}/hibernate.cfg.(a){database}.xml"
outputencoding="UTF-8">
<header><![CDATA[<?xml version='1.0'
encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
@@ -63,10 +62,10 @@
<hibernate-configuration>
<session-factory>
]]></header>
- <fileset
file="${build.resources.directory}/hibernate.properties.(a){database}.xml" />
- <fileset file="${build.resources.directory}/hibernate.common.xml"
/>
- <fileset
file="${build.resources.directory}/${hibernate.mapping.(a){database}.xml}" />
- <fileset file="${build.resources.directory}/hibernate.cache.xml"
/>
+ <fileset
file="${project.output.dir}/hibernate.properties.(a){database}.xml" />
+ <fileset file="${project.output.dir}/hibernate.common.xml" />
+ <fileset
file="${project.output.dir}/${hibernate.mapping.(a){database}.xml}" />
+ <fileset file="${project.output.dir}/hibernate.cache.xml" />
<footer><![CDATA[ </session-factory>
</hibernate-configuration>
]]></footer>
@@ -89,8 +88,16 @@
<cat-hibernate-config database="sapdb" />
<cat-hibernate-config database="sybase" />
- <copy
file="${project.build.directory}/classes/hibernate.cfg.${database}.xml"
- tofile="${project.build.directory}/classes/hibernate.cfg.xml" />
+ <copy file="${project.output.dir}/hibernate.cfg.${database}.xml"
+ tofile="${project.output.dir}/hibernate.cfg.xml" />
</target>
-
+
+ <target name="gen-hibernate-config-no-auto">
+ <copy file="${project.output.dir}/hibernate.cfg.xml"
+ tofile="${project.test.output.dir}/hibernate-no-auto.cfg.xml" />
+ <macro-disable
file="${project.test.output.dir}/hibernate-no-auto.cfg.xml"
+ section="Automatic schema creation" />
+ <macro-enable
file="${project.test.output.dir}/org/jbpm/jbpm2908/jbpm2.cfg.xml"
+ section="No automatic schema creation"/>
+ </target>
</project>
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2010-09-09
16:22:28 UTC (rev 6654)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2010-09-10
03:39:56 UTC (rev 6655)
@@ -38,7 +38,6 @@
import org.jbpm.configuration.ObjectFactoryParser;
import org.jbpm.configuration.ValueInfo;
import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.instantiation.DefaultProcessClassLoaderFactory;
import org.jbpm.instantiation.ProcessClassLoaderFactory;
import org.jbpm.job.executor.JobExecutor;
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
@@ -445,13 +444,8 @@
}
public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
- ProcessClassLoaderFactory factory;
- if (Configs.hasObject("process.class.loader.factory")) {
- factory = (ProcessClassLoaderFactory)
Configs.getObject("process.class.loader.factory");
- }
- else {
- factory = new DefaultProcessClassLoaderFactory();
- }
+ ProcessClassLoaderFactory factory =
+ (ProcessClassLoaderFactory)
Configs.getObject("process.class.loader.factory");
return factory.getProcessClassLoader(processDefinition);
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java 2010-09-09
16:22:28 UTC (rev 6654)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java 2010-09-10
03:39:56 UTC (rev 6655)
@@ -30,6 +30,7 @@
import java.net.URLConnection;
import java.net.URLStreamHandler;
+import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.file.def.FileDefinition;
@@ -39,6 +40,8 @@
private ProcessDefinition processDefinition;
private long processDefinitionId;
+
+ private final JbpmConfiguration jbpmConfiguration;
private final URLStreamHandler urlStreamHandler = new URLStreamHandler() {
protected URLConnection openConnection(URL url) throws IOException {
@@ -84,20 +87,25 @@
// transient, keep full object
this.processDefinition = processDefinition;
}
+ // remember current jbpm configuration
+ JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
+ jbpmConfiguration = jbpmContext != null ? jbpmContext.getJbpmConfiguration() : null;
}
protected ProcessDefinition getProcessDefinition() {
if (processDefinition != null) return processDefinition;
- JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null) {
- return jbpmContext.getGraphSession().loadProcessDefinition(processDefinitionId);
+ if (jbpmConfiguration != null) {
+ JbpmContext jbpmContext = jbpmConfiguration.getCurrentJbpmContext();
+ if (jbpmContext != null) {
+ return jbpmContext.getGraphSession().loadProcessDefinition(processDefinitionId);
+ }
}
return null;
}
- public URL findResource(String name) {
+ protected URL findResource(String name) {
ProcessDefinition processDefinition = getProcessDefinition();
FileDefinition fileDefinition;
if (processDefinition == null
@@ -162,7 +170,7 @@
}
}
- public Class findClass(String className) throws ClassNotFoundException {
+ protected Class findClass(String className) throws ClassNotFoundException {
ProcessDefinition processDefinition = getProcessDefinition();
FileDefinition fileDefinition;
if (processDefinition == null
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2010-09-09
16:22:28 UTC (rev 6654)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2010-09-10
03:39:56 UTC (rev 6655)
@@ -26,8 +26,9 @@
<service name="tx" factory="org.jbpm.tx.TxServiceFactory"
/>
</jbpm-context>
- <!-- database persistence configuration -->
+ <!-- database persistence configuration
<string name="resource.hibernate.cfg.xml"
value="hibernate.cfg.xml" />
+ -->
<!-- extra database persistence properties
<string name="resource.hibernate.properties"
value="hibernate.properties" />
-->
Added:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2908/ChangeJbpmConfigurationAction.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2908/ChangeJbpmConfigurationAction.java
(rev 0)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2908/ChangeJbpmConfigurationAction.java 2010-09-10
03:39:56 UTC (rev 6655)
@@ -0,0 +1,32 @@
+package org.jbpm.jbpm2908;
+
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.ProcessInstance;
+
+public class ChangeJbpmConfigurationAction implements ActionHandler {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ExecutionContext context) throws Exception {
+ // load another configuration
+ JbpmConfiguration jbpmConfiguration =
JbpmConfiguration.parseResource("org/jbpm/jbpm2908/jbpm2.cfg.xml");
+ try {
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try {
+ // start instance
+ ProcessInstance processInstance =
jbpmContext.newProcessInstance("process2");
+ processInstance.signal();
+ jbpmContext.save(processInstance);
+ }
+ finally {
+ jbpmContext.close();
+ }
+ }
+ finally {
+ jbpmConfiguration.close();
+ }
+ }
+}
Property changes on:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2908/ChangeJbpmConfigurationAction.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2908/JBPM2908Test.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2908/JBPM2908Test.java
(rev 0)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2908/JBPM2908Test.java 2010-09-10
03:39:56 UTC (rev 6655)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.jbpm2908;
+
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.persistence.JbpmPersistenceException;
+
+/**
+ * Change {@link JbpmConfiguration} and start a process instance in an action handler.
This test
+ * is only for detecting {@link StackOverflowError}. This nested {@link JbpmContext}
usage may
+ * not be properly asserted except in an integration test using JTA, so this test ignores
many
+ * {@link JbpmPersistenceException}s.
+ *
+ * @see <a
href="https://jira.jboss.org/jira/browse/JBPM-2908">JBPM-290...
+ * @author Toshiya Kobayashi
+ */
+public class JBPM2908Test extends AbstractDbTestCase {
+
+ protected String getJbpmTestConfig() {
+ return "org/jbpm/jbpm2908/jbpm1.cfg.xml";
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ jbpmConfiguration.close();
+ }
+
+ public void testChangingJbpmConfigurationInActionHandler() throws Exception {
+ // deploy definition
+ ProcessDefinition processDefinition1 =
ProcessDefinition.parseXmlResource("org/jbpm/jbpm2908/processdefinition1.xml");
+ ProcessDefinition processDefinition2 =
ProcessDefinition.parseXmlResource("org/jbpm/jbpm2908/processdefinition2.xml");
+ deployProcessDefinition(processDefinition1);
+ deployProcessDefinition(processDefinition2);
+
+ // start instance
+ ProcessInstance processInstance =
jbpmContext.newProcessInstance("process1");
+ processInstance.signal();
+ assert processInstance.hasEnded() : processInstance;
+ }
+}
Property changes on:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2908/JBPM2908Test.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/jbpm1.cfg.xml
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/jbpm1.cfg.xml
(rev 0)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/jbpm1.cfg.xml 2010-09-10
03:39:56 UTC (rev 6655)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbpm-configuration />
Property changes on:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/jbpm1.cfg.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/jbpm2.cfg.xml
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/jbpm2.cfg.xml
(rev 0)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/jbpm2.cfg.xml 2010-09-10
03:39:56 UTC (rev 6655)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbpm-configuration>
+ <!-- No automatic schema creation (begin) ===
+ <string name="resource.hibernate.cfg.xml"
value="hibernate-no-auto.cfg.xml" />
+ ==== No automatic schema creation (end) -->
+</jbpm-configuration>
Property changes on:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/jbpm2.cfg.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/processdefinition1.xml
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/processdefinition1.xml
(rev 0)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/processdefinition1.xml 2010-09-10
03:39:56 UTC (rev 6655)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition name="process1"
xmlns="urn:jbpm.org:jpdl-3.2">
+ <start-state name="start">
+ <transition to="node1" />
+ </start-state>
+
+ <node name="node1">
+ <event type="node-enter">
+ <action class="org.jbpm.jbpm2908.ChangeJbpmConfigurationAction" />
+ </event>
+ <transition to="end" />
+ </node>
+
+ <end-state name="end" />
+</process-definition>
Property changes on:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/processdefinition1.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/processdefinition2.xml
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/processdefinition2.xml
(rev 0)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/processdefinition2.xml 2010-09-10
03:39:56 UTC (rev 6655)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition name="process2"
xmlns="urn:jbpm.org:jpdl-3.2">
+ <start-state name="start">
+ <transition to="node1" />
+ </start-state>
+
+ <node name="node1">
+ <transition to="end" />
+ </node>
+
+ <end-state name="end" />
+</process-definition>
Property changes on:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2908/processdefinition2.xml
___________________________________________________________________
Name: svn:eol-style
+ native