[jboss-jira] [JBoss JIRA] Commented: (JBPM-821) ProcessClassLoader.getResourceAsStream throws JbpmException when the resource is not found in DB
Victor Suarez (JIRA)
jira-events at lists.jboss.org
Wed Apr 4 13:05:58 EDT 2007
[ http://jira.jboss.com/jira/browse/JBPM-821?page=comments#action_12358399 ]
Victor Suarez commented on JBPM-821:
------------------------------------
I agree with Jan Ypma. The "findClass" method already does that:
String fileName = "classes/" + name.replace( '.', '/' ) + ".class";
But this modification implies deeper changes in the code, because ClassLoaderUtil.getStream uses getResourceAsStream assuming no "classes/" prefix when it looks for a resource. I think that the best solution is to rewrite ClassLoaderUtil.getStream for calling directly FileDefinition.getBytes() , but if my previous code is used, then you will not get a JbpmException when the stream is not found in DB (now is returning a null value).
Note: I had to change the getResourceAsStream because we are using jBPM as processes orchestrator, using XFire for SOAP calls, and XFire engine firstly looks for serialization config files in the classpath before applying default (un)marshalling configuration. We include the XFire SOAP clients in the process archive.
> ProcessClassLoader.getResourceAsStream throws JbpmException when the resource is not found in DB
> ------------------------------------------------------------------------------------------------
>
> Key: JBPM-821
> URL: http://jira.jboss.com/jira/browse/JBPM-821
> Project: JBoss jBPM
> Issue Type: Bug
> Components: Core Engine
> Affects Versions: jBPM 3.1.2
> Reporter: Victor Suarez
> Assigned To: Tom Baeyens
>
> "ProcessClassLoader.getResourceAsStream(String name)" must return null when the resource is not found <link>http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassLoader.html#getResourceAsStream(java.lang.String)</link>.
> But when the resource look up must be performed in the DB, if that resource is not found I get a JbpmException.
> "ProcessClassLoader.getResourceAsStream(String name)" delegates in "fileDefinition.getBytes(name)" for searching the resource, and this calls to "getBytesFromDb(name)", and finally, this calls to "getByteArray(name)", that performs this code:
> if (byteArray == null) {
> throw new JbpmException("file '" + name + "' not found in db");
> }
> I think that a possible solution could be:
> byte[] getBytesFromDb(String name) {
> byte[] bytes = null;
>
> //refactored this line
> ByteArray byteArray = doGetByteArray(name);
>
> if (byteArray != null)
> bytes = byteArray.getBytes();
> return bytes;
> }
> ByteArray getByteArray(String name) {
> //extract method refactoring
> ByteArray byteArray = doGetByteArray(name);
>
> if (byteArray == null) {
> throw new JbpmException("file '" + name + "' not found in db");
> }
> return byteArray;
> }
> //extracted method
> ByteArray doGetByteArray(String name) {
> ByteArray byteArray = (ByteArray) (processFiles != null ? processFiles.get(name) : null);
> return byteArray;
> }
>
> I let with no modifications "getByteArray(String name)" because is referenced in the rest of code.
> Thanks
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list