8 Replies Latest reply on Nov 26, 2008 11:53 AM by salaboy21

    JbpmContext is always null

      Hi all,
      i'm new here...I want to obtain a list of deployed process on jbpm.
      I try this two lines:

      JbpmContext context = JbpmConfiguration.getInstance().createJbpmContext("jbpm.cfg.xml");
      
      List<ProcessDefinition> processList = context.getGraphSession().findAllProcessDefinitions();
      


      but context is null :-(
      I must say jbpm.cfg.xml is empty...

      Any suggestions???

        • 1. Re: JbpmContext is always null

          Probably i must describe my scenario:
          1) I have my application running on same AS (jboss) of jbpm-console
          2) My application run on 8082 and it must show the list of deployed processes by jpdl.
          3) My application uses its hibernate.cfg.xml and the error makes me wonder to some conflicts with jbpm session.
          4) I use jbpm 3.2.2
          5) Processdefinition files are deployed on local jbpm-console (just during development)

          Thanks again.

          • 2. Re: JbpmContext is always null
            salaboy21

            Where are you running this code?

            if you are doing this in a JUnit test, you must ensure that jbpm.cfg.xml is in your classpath, so you can do the following:

            JbpmConfiguration conf= JbpmConfiguration.getInstance();
            JbpmContext context=conf.createJbpmContext();
            


            Then you should check that your context is not null.


            • 3. Re: JbpmContext is always null

              Ok, salaboy21
              I follow your suggestion but nothing change...it seems jbpm.cfg.xml is not correct because an error regarding a class of my application is required. The error is

              Caused by: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="it.eurosoft.mapping....


              How do this two simple called functions want MY mapping class? Is jbpm reading my hibernate.cfg.xml? :-(

              Bye.

              • 4. Re: JbpmContext is always null
                salaboy21

                Of course, if you not have content in your jbpm.cfg.xml, the content is taken from default.jbpm.cfg.xml that is in jbpm-jpdl.jar. Inside this file, there is a reference to hibernate.cfg.xml.
                So check your mappings in hibernate.cfg.xml in order to fix your problem

                • 5. Re: JbpmContext is always null

                  Oh my god...I don't understand...so I need to add to MY hibernate.cfg.xml the mappings, for instance, from hibernate.cfg.xml of jbpm-console...but then it should require me to put in my jar all mapping xml...

                  Thanks!

                  • 6. Re: JbpmContext is always null
                    salaboy21

                    If you want to create or use a JbpmContext you need to know where is the structe of the processDefinitions and the processInstances. For this, of course that you need to know where and how all the structure are mapped.
                    So if you also add entities in variables, you need to map it too...

                    If you are in a standalone app, you will need the same hibernate mappings that you have in the console.. and may you must change where the Datasource is pointing.

                    Hope it helps

                    • 7. Re: JbpmContext is always null

                      Perfect salaboy21,
                      and how can I know where is the structure of the processDefinitions and the processInstances?

                      • 8. Re: JbpmContext is always null
                        salaboy21

                        this is why you need hibernate.cfg.xml with the correct mappings..
                        because there is the structure of your process and the data of your instances.

                        If you create a sample project with eclipse you should see that a hibernate.cfg.xml is created for you and an empty jbmp.cfg.xml is also created.