cancel
Showing results for 
Search instead for 
Did you mean: 

Resource not found exception

arno1
Champ in-the-making
Champ in-the-making
Hi,
I programmed the example given in documentation (10 minute tutorial). But an exception occured, i do not know how to solve it:
The exception occured at this position:

Programcode:
// Deploy the process definition
    repositoryService.createDeployment()
      .addClasspathResource("C:\\FinancialReportProcess.bpmn20.xml")
      .deploy();

   

Exception:
Exception in thread "main" org.activiti.engine.ActivitiException: resource 'C:\FinancialReportProcess.bpmn20.xml' not found
   at org.activiti.engine.impl.repository.DeploymentBuilderImpl.addClasspathResource(DeploymentBuilderImpl.java:56)
   at TenMinuteTutorial.main(TenMinuteTutorial.java:22)


I do not know where there occurs an NotFoundException, the file is located at C:\. I've tried it by using some different locations - same result, so thats no matter of user rights.

Can anybody help me?
8 REPLIES 8

frederikherema1
Star Contributor
Star Contributor
Hi,
Classpath-resource is relative to the classpath, not the filesystem. Use:

addInputStream("xxx",new FileInputStream(new File("C:/xxx.bpmn20.xml"))

arno1
Champ in-the-making
Champ in-the-making
Thank you for the advice, it works!
Smiley Very Happy

wiwengweng
Champ in-the-making
Champ in-the-making
I wonder if I could use "org.activiti.examples/…/..bpmn20.xml" instead?? Smiley Very Happy
'cause the file path's so long…

wiwengweng
Champ in-the-making
Champ in-the-making
Hi,
Classpath-resource is relative to the classpath, not the filesystem. Use:

addInputStream("xxx",new FileInputStream(new File("C:/xxx.bpmn20.xml"))
hi, how can I make the classpath available? should I configure the system classpath??

BR~

wiwengweng
Champ in-the-making
Champ in-the-making
Hi,
Classpath-resource is relative to the classpath, not the filesystem. Use:

addInputStream("xxx",new FileInputStream(new File("C:/xxx.bpmn20.xml"))
hi, how can I make the classpath available? should I configure the system classpath??

BR~


yep,I got it work. what I have to do is to put the bpmn20.xml file somewhere defined in the .classpath file~hah hah~ I don't know if it is legal, at least it works.~ :lol:

koopa1
Champ in-the-making
Champ in-the-making
I'm having the same problem. Where do I find the classpath?

rovo
Champ in-the-making
Champ in-the-making
I'm having the same problem. Where do I find the classpath?
As I had the same issues while creating a unit test I'll post my solutions here:

The root directory of the eclipse project contains a .classpath file which is hidden by default in eclipse. On opening this file this should look something like
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Activiti Designer Extensions"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
As the structure of this project contains a tree like this:

project base
|-src/main/java
|-src/main/resources
|-src/test/java
|-target

well see that src/main/resources is already in the .classpath. So the following code snippet will load a PaymentProcess definition into the Activiti engine, which Activiti Designer created in a diagrams
sub-directory of resources for me.

// deploy the process definition
DeploymentBuilder builder = repositoryService.createDeployment();
builder.addClasspathResource("diagrams/PaymentProcess.bpmn20.xml");
builder.deploy();
// use the id of the root-process defined in the definition - PaymentProcess in my case
ProcessInstance proc = runtimeService.startProcessInstanceByKey("PaymentProcess");

An alternative way would be to define an InputStream:

DeploymentBuilder builder = repositoryService.createDeployment();
builder.addInputStream("PaymentProcess.bpmn20.xml", new FileInputStream(System.getProperty("user.dir")+"/src/main/resources/diagrams/PaymentProcess.bpmn20.xml"));
builder.deploy();
// use the id of the root-process defined in the definition - PaymentProcess in my case
ProcessInstance proc = runtimeService.startProcessInstanceByKey("PaymentProcess");
HTH,
Roman

sunitanayak83
Champ in-the-making
Champ in-the-making
Hi,

I am using Alfresco Activiti and want to initiate a task outside of alfresco activiti. I have written a standalone java program to do this(i.e my java program creates a task in alfresco activiti on execution).

My java program looks like this :

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;

public class TestingABC {

public static void main(String[] args)
{

//Create Activiti process engine
     ProcessEngine processEngine = ProcessEngineConfiguration
       .createStandaloneInMemProcessEngineConfiguration()
       .buildProcessEngine();

     // Get Activiti services
     RepositoryService repositoryService = processEngine.getRepositoryService();
     RuntimeService runtimeService = processEngine.getRuntimeService();

     // Deploy the process definition
     repositoryService.createDeployment()
       .addClasspathResource("diagram/TestingThruActiviti.bpmn20.xml")
       .deploy();

     // Start a process instance
     ProcessInstance processInstance=runtimeService.startProcessInstanceByKey("TestingThruActiviti");
    
     TaskService taskService=processEngine.getTaskService();
  Task task=taskService.createTaskQuery().taskAssignee("$INITIATOR").singleResult();
 
  System.out.println(task.getName());

    

}

}

The program runs fine as long as my taskAssignee is "$INITIATOR", but when I change my taskAssignee to a real user in alfresco activiti, it throws a null pointer exception.

Exception in thread "main" java.lang.NullPointerException
at TestingABC.main(TestingABC.java:34)

Any pointers ?