[
https://jira.jboss.org/jira/browse/JBPM-1148?page=com.atlassian.jira.plug...
]
Bernd Ruecker commented on JBPM-1148:
-------------------------------------
The problem with the proposed fix was that it leads to an endless loop, since the
classloader is already needed to load the jbpm.cfg.xml in the JbpmConfiguration
(InputStream jbpmCfgXmlStream = ClassLoaderUtil.getStream(resource);), but this wants to
read which classloader to use.
Exception StackTrace:
at org.jbpm.util.ClassLoaderUtil.getClassLoader(ClassLoaderUtil.java:50)
at org.jbpm.util.ClassLoaderUtil.getStream(ClassLoaderUtil.java:83)
at org.jbpm.JbpmConfiguration.getInstance(JbpmConfiguration.java:279)
at org.jbpm.JbpmConfiguration.getInstance(JbpmConfiguration.java:257)
at
org.jbpm.JbpmConfiguration$Configs.getObjectFactory(JbpmConfiguration.java:418)
at org.jbpm.JbpmConfiguration$Configs.hasObject(JbpmConfiguration.java:426)
at org.jbpm.util.ClassLoaderUtil.getClassLoader(ClassLoaderUtil.java:50)
So my solution is to introduce a special method "getJbpmConfigurationStream"
which is responsible especially for loading the jbpm.cfg.xml. It looks first in the
ClassLoaderUtil.class.getClassLoader (because this is the "old behavior") and if
there is nothing found in the Thread.currentThread().getContextClassLoader(). This method
is used by the JbpmConfiguration and the XmlUtil to load jbpm.cfg.xml. And in the
ObjectFactoryImpl I changed to lazy load the classloader, otherwise it is queried too
early (before the jbpm.cfg.xml is processed)...
Additionally the described patch is applied, but currently I am not sure if we still need
the customClassLoader configuration? Shouldn't all use cases be already solved by
using the context class loader and overwrite the ProcessClassLoader?
Third thing I did was to introduce a ProcessClassLoaderFactory which can be configured via
the jbpm.cfg.xml. So you can easily exchange the ProcessClassLoader to whatever you need
in your project.
The three new configuration parameters are:
<jbpm-configuration>
...
<string name="jbpm.classLoader" value="jbpm" />
<string name="jbpm.customClassLoader.className"
value="com...MyClassLoaderUtil" />
<bean name="jbpm.processClassLoader"
class="org.jbpm.instantiation.DefaultProcessClassLoaderFactory"
singelton="true" />
/>
All these values have defaults (which doesn't change the current behavior), so they
are not required.
All tests are still running, I added a short new test, which also works... I will commit
it, so everybody interested can review it...
The whole conifguration / load during startup / Config part is a bit tricky, didn't
understand each and everything there, would be nice if you, Tom, can have a look at it?
If it keeps like that I can also make a short note in the documentation about these
classloading configuration possibilities...
jBPM Classloading
-----------------
Key: JBPM-1148
URL:
https://jira.jboss.org/jira/browse/JBPM-1148
Project: JBoss jBPM
Issue Type: Patch
Components: Core Engine
Affects Versions: jBPM 3.2.0, jBPM 3.2.1, jBPM 3.2.2
Reporter: Bjoern Wand
Attachments: ClassLoaderUtil.java
jBPM does not use ContextClassloader for classloading. The class ClassLoaderUtil.java has
a comment that class loading could be made configurable. This is the patch I provided in
the forum and I agreed with Koen Ars th open a JIRA for this.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira