Workflow wf = new BasicWorkflow((String) session.getAttribute("username"));
wf.setConfiguration(workflowConfiguration);
……

解决方案 »

  1.   

    sgdb:
          老兄能不能讲具体一点!
      

  2.   

    可能不是Configuration的问题刚才仔细看了一下,你的examples是什么?是xml文件么? 
    如果是你的xml文件并且就在newworkflow的目录下,那么试试:
    id = wf.initialize("example.xml", 1, null);
      

  3.   

    sgdb:
         老兄我现在把我的配制文件及相关代码详细列出请指点!谢谢!
    我的开发环境为:
                  jbuilder9.0+jboss4.0
    工程名为testworkflow.jpx
          webapp(web应用程序名):
               testworkflowweb
    新建工作流:newworkflow.jsp代码:(登录时新建了用户放在session.getAttribute("username")中)
                Workflow wf = new BasicWorkflow((String) session.getAttribute("username"));
                DefaultConfiguration configs = new DefaultConfiguration();
                wf.setConfiguration(configs);
                id = wf.initialize("example",1, null);
                out.print("得到工作流实例为:"+Long.toString(id)+"<br><br>");
    osworkflow配置文件如下:
       在 testworkflow\testworkflowweb\WEB-INF目录下有如下文件
       1.workflows.xml
       2.osworkflow.xml
       3.example.xml
        
     osworkflow.xml的内容:
                   <osworkflow>
                  <persistence       class="com.opensymphony.workflow.spi.memory.MemoryWorkflowStore"/>
      <factory class="com.opensymphony.workflow.loader.XMLWorkflowFactory">
        <property key="resource" value="workflows.xml" />
      </factory> 
    </osworkflow>workflows.xml的内容:
    <workflows>
      <workflow name="example" type="resource" location="example.xml"/>
    </workflows>example.xml的内容:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE workflow PUBLIC 
                     "-//OpenSymphony Group//DTD OSWorkflow 2.7//EN"
                     "http://www.opensymphony.com/osworkflow/workflow_2_7.dtd">
    <workflow>
      <initial-actions>
        <action id="1" name="Start Workflow">
          <results>
            <unconditional-result old-status="Finished" status="Queued" step="1"/>
          </results>
        </action>
      </initial-actions>
      <steps>
        <step id="1" name="First Draft">
          <actions>
            <action id="1" name="Start First Draft">
              <restrict-to>
                <conditions>
                  <condition type="class">
                    <arg name="class.name">
                       com.opensymphony.workflow.util.StatusCondition
                    </arg>
                    <arg name="status">Queued</arg>
                  </condition>
                </conditions>
              </restrict-to>
              <pre-functions>
                <function type="class">
                  <arg name="class.name">
                     com.opensymphony.workflow.util.Caller
                  </arg>
                </function>
              </pre-functions>
              <results>
                <unconditional-result old-status="Finished" status="Underway" 
                                               step="1"  owner="${caller}"/>
              </results>
            </action>
            <action id="2" name="Finish First Draft">
              <restrict-to>
                <conditions type="AND">
                  <condition type="class">
                    <arg name="class.name">
                        com.opensymphony.workflow.util.StatusCondition
                    </arg>
                    <arg name="status">Underway</arg>
                  </condition>
                  <condition type="class">
                    <arg name="class.name">
                      com.opensymphony.workflow.util.AllowOwnerOnlyCondition
                    </arg>
                  </condition>
                </conditions>
              </restrict-to>
              <results>
                <unconditional-result old-status="Finished" status="Queued" step="2"/>
              </results>
            </action>
          </actions>
        </step>
        <step id="2" name="finished" />
      </steps>
    </workflow>