2013-04-22 27 views
1

我是新來的OFBiz和我創建了簡單的ofbiz的服務,並指該鏈接http://www.packtpub.com/article/apache-ofbiz-service-engine-part1錯誤而調用的ofbiz服務

我創建實踐項目進入熱部署。

我在servicedef/services.xml中創建的服務如下面在learningFirstService.xml

`<service name="learningFirstService" engine="java" 
     location="org.ofbiz.practice.practice.PracticeServices" invoke="handleParameters"> 
     <description>Our First Service</description> 
     <attribute name="firstName" type="String" mode="IN" optional="true" /> 
     <attribute name="lastName" type="String" mode="IN" optional="true" /> 
    </service>` 

和創建PracticeServices.java類成src.org.ofbiz.practice.practice pakcage 和創建方法

public static Map learningFirstService(DispatchContext dctx, Map context){ 

     System.out.println("learning first service called"); 
     Map resultMap = ServiceUtil.returnSuccess("You have called on service 'learningFirstService' successfully!"); 
     return resultMap; 
    } 

,在我的ofbiz-component.xml文件

<?xml version="1.0" encoding="UTF-8"?> 
<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"/> 

     <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"/> 
    <classpath type="dir" location="config"/> 


</ofbiz-component> 

learningforms.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="TestingServices" type="single" target="${formTarget}"> 
     <field name="firstName"><text/></field> 
     <field name="lastName"><text/></field> 
     <field name="planetId"><text/></field> 
     <field name="submit"><submit/></field> 
    </form> 
</forms> 

和controller.xml有用於示出學習形式

 <request-map uri="TestFirstService"> 
      <event type="service" invoke="learningFirstService" /> 
      <response name="success" type="view" value="TestFirstService" /> 
     </request-map> 
    <view-map name="TestFirstService" type="screen" page="component://practice/widget/PracticeScreens.xml#learningForm"/> 

的learningForm在成功打開請求的映射。但是當我點擊提交按鈕時。它給控制檯帶來錯誤,如

 Error in request handler: 
    Exception: org.ofbiz.webapp.event.EventHandlerException 
    Message: Problems getting the service model (Cannot locate service by name (learningFirstService)) 
    ---- cause --------------------------------------------------------------------- 
    Exception: org.ofbiz.service.GenericServiceException 
    Message: Cannot locate service by name (learningFirstService) 
    ---- stack trace --------------------------------------------------------------- 
    org.ofbiz.service.GenericServiceException: Cannot locate service by name (learningFirstService) 
    org.ofbiz.service.DispatchContext.getModelService(DispatchContext.java:191) 
    org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:116) 
    org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:648) 
    org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:394) 
    org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) 
    org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:637) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:339) 
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:615) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) 
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) 
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) 
    java.lang.Thread.run(Thread.java:619) 

該錯誤表明它找不到我定義的服務。但不明白它出錯的地方。請幫幫我。

謝謝先進。
ANKIT

+0

嗨,我解決了這個錯誤。由於語法錯誤,它只是在服務器啓動時加載錯誤。但是我可以看到我的服務已註冊,但在訪問該服務時,會看到我的課沒有發現異常。 請求處理程序錯誤: 異常:org.ofbiz.webapp.event.EventHandlerException 消息:服務調用錯誤(org.ofbiz.practice.practice.PracticeServices) ---- cause -------- -------------------------------------------------- ----------- 異常:java.lang.ClassNotFoundException 消息:org.ofbiz.practice.practice.PracticeServices – Ankit 2013-04-22 08:53:27

回答

2

我們的第一個服務 `

Web服務調用.... =的」 THT值 「必須用相同

」 org.ofbiz.practice.practice .PracticeServices「的方法,就像」learnFirstService「

+2

請重新表達您的答案,這是很難理解。 – pascalhein 2013-05-31 18:55:49

+0

就像下面一樣,會沒事的。 我們的第一個服務 ' – zgzlwm 2013-06-01 02:11:39