Message:
A new issue has been created in JIRA.
---------------------------------------------------------------------
View the issue:
http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WF-172
Here is an overview of the issue:
---------------------------------------------------------------------
Key: WF-172
Summary: When creating XML using velocity Classloader can't find template
Type: Bug
Status: Assigned
Priority: Major
Project: OSWorkflow
Components:
Core
Versions:
1.0
Assignee: Patrick Lightbody
Reporter: Jan Kruger
Created: Wed, 28 May 2003 10:45 AM
Updated: Wed, 28 May 2003 10:45 AM
Environment: Sun JDK 1.3.1
Description:
When Velocity gets ingratiated by any other code within the same class loader, the Template cannot be found when trying to generate the XML in the workflow code.
The problem is the following:
WorkflowSerializer.java contains this code:
Velocity.setProperty("resource.loader", "class");
Velocity.setProperty(
"class.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
Velocity.init();
The problem is, if you run this code AFTER something has initialized Velocity without adding the ClasspathResourceLoader, setting the property and init()ing Velocity will not reinitialize it. The solution is the following:
/************************* start new code
protected static void initVelocity() throws Exception {
if (mVelocityEngine == null){
mVelocityEngine = new VelocityEngine();
mVelocityEngine.setProperty("resource.loader", "class");
mVelocityEngine.setProperty(
"class.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
mVelocityEngine.init();
}
}
public static byte[] generateWorkflowXML(WorkflowDescriptor wf) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(baos);
initVelocity();
/* ...
* CODE STAYS THE SAME...
*/
}
protected static VelocityEngine mVelocityEngine = null;
/************************* End new code
With the major changes being that we use a local instance of the VelocityEngine rather than the Singleton instance already available in the VM.
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.opensymphony.com/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.