没有遵循Ofbiz教程第3部分CRUD

时间:2015-07-17 05:03:43

标签: nullpointerexception ofbiz

我几天前开始学习Ofbiz但是我没有遵循Ofbiz教程第3部分CRUD(https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+Tutorial+-+A+Beginners+Development+Guide)。当我开始运行createPracticePerson服务时,我得到了

JavaEventHandler              |E| Problems Processing Event
java.lang.NullPointerException 

at org.ofbiz.service.engine.GenericEngineFactory.getGenericEngine (GenericEngineFactory.java:53) ~[bin/:?] 

at org.ofbiz.service.ServiceDispatcher.getGenericEngine(ServiceDispatcher.java:799) ~[bin/:?] ...

我已尝试使用其他教程作为参考(http://ofbiz.us/developing-enterprise-application-with-apache-ofbiz-platform),但仍然会收到相同的错误消息。我已经包含了一些xml文件以供参考。感谢

的ofbiz-component.xml文件

<ofbiz-component name="practice"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
      <resource-loader name="main" type="component"/>
      <classpath type="dir" location="config"/>
      <classpath type="jar" location="build/lib/*"/>      
      <service-resource type="model" loader="main" location="servicedef/services.xml"/>            
    <webapp name="practice"
       title="Practice"
       server="default-server"
       base-permission="OFBTOOLS"
       location="webapp/practice"
       mount-point="/practice"
       app-bar-display="true"/>
</ofbiz-component>

service.xml中

<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/services.xsd">
    <description>Practice Services</description>
    <vendor>OFBiz</vendor>
    <version>1.0</version>

    <service name="createPracticePerson" default-entity-name="Person" engine="engine-auto"          
             invoke="create" auth="true">
        <description>Create a Person</description>
        <auto-attributes include="pk" mode="OUT" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <override name="comments" optional="true"/>
    </service>   
</services>

controller.xml

<?xml version="1.0" encoding="UTF-8"?>
<site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd">
        <include location="component://common/webcommon/WEB-INF/common-controller.xml"/>
        <include location="component://commonext/webapp/WEB-INF/controller.xml"/>
        <description>Practice Component Site Configuration File</description>
        <owner>Copyright 2001-2009 The Apache Software Foundation</owner>
        <handler name="screenxml" type="view" class="org.ofbiz.widget.screen.ScreenXmlViewHandler"/>
        <handler name="service" type="request" class="org.ofbiz.webapp.event.ServiceEventHandler"/>
        <handler name="service-multi" type="request" class="org.ofbiz.webapp.event.ServiceMultiEventHandler"/>
        <!-- Request Mappings -->
        <request-map uri="main">
           <security https="true" auth="true"/>
           <response name="success" type="view" value="main"/>
           <response name="error" type="view" value="main"/>
        </request-map>
        <request-map uri="personForm">
           <security https="true" auth="true"/>           
           <response name="success" type="view" value="personForm"/>
           <response name="error" type="view" value="personForm"/>
        </request-map>        
        <request-map uri="createPracticePerson">
            <security https="true" auth="true"/>            
            <event type="service" invoke="createPracticePerson"/>            
            <response name="success" type="view" value="personForm"/>
            <response name="error" type="view" value="personForm"/>
        </request-map>
       <!-- end of request mappings -->

       <!-- View Mappings -->
       <view-map name="main" type="screen" page="component://practice/widget/PracticeScreens.xml#main"/>
       <view-map name="personForm" type="screen" page="component://practice/widget/PracticeScreens.xml#personForm"/>       
       <!-- end of view mappings -->
</site-conf>

PracticeForm.xml

<?xml version="1.0" encoding="UTF-8"?>
<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd">    
    <form name="ListPersons" type="list" list-name="persons" list-entry-name="person" target="updatePracticePerson" paginate-target="personForm">
        <auto-fields-service service-name="updatePracticePerson" default-field-type="edit" map-name="person"/>
        <field name="partyId"><hidden/></field>
        <field name="submitButton" title="Update" widget-style="smallSubmit"><submit button-type="button"/></field>
        <field name="deletePracticePerson" title="Delete Person" widget-style="buttontext">
        <hyperlink target="deletePracticePerson?partyId=${person.partyId}" description="Delete"/>
        </field>           
    </form>
    <form name="CreatePerson" type="single" target="createPracticePerson">    
        <auto-fields-service service-name="createPracticePerson"/>
        <field name="submitButton" title="${uiLabelMap.CommonAdd}" widget-style="smallSubmit"><submit button-type="button"/></field>
    </form>
</forms>

PracticeScreens.xml

<?xml version="1.0" encoding="UTF-8"?>
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
    <screen name="main">
        <section>
            <actions>
                <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="PracticeUiLabels" map-name="uiLabelMap" global="true"/>
                <set field="headerItem" value="main"/>
                <set field="titleProperty" value="main page"/>  
            </actions>    
            <widgets>                
                <decorator-screen name="main-decorator" location="${parameters.commonDecoratorLocation}">
                    <decorator-section name="body">
                        <label text="${uiLabelMap.PracticeApplication}"/>                        
                    </decorator-section>
                </decorator-screen>
                <!-- <label>This is first  practice</label> -->            
            </widgets>
        </section>               
    </screen>
    <screen name="personForm">
        <section>
            <actions>
                <set field="headerItem" value="personForm"/>
                <set field="titleProperty" value="PageTitlePracticePersonForm"/>
                <entity-condition entity-name="Person" list="persons"/>
            </actions>
            <widgets>
                <decorator-screen name="main-decorator" location="${parameters.commonDecoratorLocation}">
                    <decorator-section name="body">
                        <label text="Person List" style="h2"/>
                        <include-form name="ListPersons" location="component://practice/widget/PracticeForms.xml"></include-form>
                        <include-form name="CreatePerson" location="component://practice/widget/PracticeForms.xml"></include-form>
                    </decorator-section>
                </decorator-screen>       
            </widgets>
        </section>
    </screen>
</screens>

1 个答案:

答案 0 :(得分:0)

您是否实现了createPracticePerson服务,该服务实际创建了practicePerson?本教程中有一个minilang实现。