-
1. Re: MissingResourceException :ActionHandler
ashwin_4421 Aug 14, 2005 7:37 AM (in response to aguizar)Hi,
I followed the process you have asked me to , but am still getting the same exception.
I gave the full path of the properties file , it din't work
so i changed the location of the properties file to folder containing the classes and tried using the path as :
classes/com/sample/action/labels
i also tried
classes/com/sample/action/labels.properties
but all this gives me the same issue
Any clues?
Thanks
Ashwin -
2. Re: MissingResourceException :ActionHandler
ashwin_4421 Aug 14, 2005 8:43 AM (in response to aguizar)Hi,
all i need to do is read from a file the "Source" and "Destination" values.
the file could even be a "XML"
I have been stuck up with this issues for couple of days now ..
Any help on this would be greatful,
Thanks
Ashwin -
3. Re: MissingResourceException :ActionHandler
peterj Aug 15, 2005 11:10 AM (in response to aguizar)Try "com.sample.action.labels". I think that the resource bundle uses class naming conventions, not directory locations, to locate properties files.
-
4. Re: MissingResourceException :ActionHandler
aguizar Aug 15, 2005 4:20 PM (in response to aguizar)If all you need is to load a properties file and do not need the localization features provided by ResourceBundle, you can do something like this in your action handler:
package com.sample.action; // ... public class ResourceActionHandler implements ActionHandler { // ... public void execute(ExecutionContext exeContext) throws Exception { // open a stream to a file within the process archive FileDefinition fileDefinition = exeContext.getProcessDefinition().getFileDefinition(); InputStream labelStream = fileDefinition.getInputStream("classes/com/sample/action/labels.properties"); // read a property list from the stream Properties labelProperties = new Properties(); labelProperties.load(labelStream); labelStream.close(); // set the properties as variables exeContext.getContextInstance().addVariables(labelProperties); } }
I put my properties file in the same directory as the ResourceActionHandler class, but you can put your file anywhere in the process archive. Here is my process definition:<process-definition name="resourceful"> <start-state name="start"> <transition name="t1" to="process resources"></transition> </start-state> <node name="process resources"> <transition name="t2" to="end"></transition> <action class="com.sample.action.ResourceActionHandler" /> </node> <end-state name="end"></end-state> </process-definition>
and my test case:public void testSimpleProcess() throws Exception { // Extract a process definition from the processdefinition.xml file. ProcessDefinition definition = ProcessDefinition.parseParResource("process.par"); // Create an instance of the process definition. ProcessInstance instance = new ProcessInstance(definition); Token rootToken = instance.getRootToken(); assertEquals("instance is in start state", "start", rootToken.getNode().getName()); // Move the process instance from its start state to the first state. // The configured action should execute. instance.signal(); assertEquals("instance is in 'process resources' state", "process resources", rootToken.getNode().getName()); // The properties should now be in the data context. ContextInstance contextInstance = instance.getContextInstance(); assertEquals("firstHandler variable exists", "com.sample.action.GizmoHandler", contextInstance.getVariable("firstHandler")); assertEquals("secondHandler variable exists", "com.sample.action.FunkyHandler", contextInstance.getVariable("secondHandler")); // Move the process instance to the end state. instance.signal(); assertEquals("instance is in end state", "end", rootToken.getNode().getName()); assertTrue("instance has ended", instance.hasEnded()); }
Hope this helps. -
5. Re: MissingResourceException :ActionHandler
ashwin_4421 Aug 16, 2005 11:57 AM (in response to aguizar)Hi Alex,
Thanks a lot for the help.
I could finally get the stuff working.
Is there any reason why ResourceBundle doesn't work ?
My only concern over using a Properties class is , may be in future we might need to use the Locale.
Thanks for the help,
Ashwin -
6. Re: MissingResourceException :ActionHandler
aguizar Aug 16, 2005 3:00 PM (in response to aguizar)There is a known reason. ProcessClassLoader does not override getResource(String), which ResourceBundle depends on.
The reason is that there is no direct way to create working URLs for files associated with a process definition when they are stored in the database. This limitation does not apply when they are stored in the file system, tough it requires some changes.
Please open a JIRA issue if you're interested in this feature, but consider it isn't a blocking problem so it won't be resolved in the near future. -
7. JBPM GPD
vonarxma Oct 14, 2005 10:38 AM (in response to aguizar)"ashwin_4421" wrote:
Hi ,
I have posted this topic before , i am posting it again as i am not able to post a reply in the previous thread
Here goes my problem:
I will have to read from a .properties file from one of my ActionHandlers, the properties file supplies the "source" and "destination" path to the ActionHandler.
These are the steps i followed:
1.Included the labels.properties along with the gpd.xml ,processdefintion.xml in the simple.par folder
When i build the processArchive , i see the labels.properties included in the generated simple.par file ,in the same path as gpd.xml
2.I deployed the process.
2.The code in my ActionHandler was
ResourceBundle scpBundle = ResourceBundle.getBundle("labels",Locale.getDefault());
At this stage i get the MissingResourceException,
I am not very sure as to how to use the ProcessClassLoader,
Can you please explain
Thanks
Ashwin -