何时需要重启 OFBiz

[b]何时需要重启OFBiz[/b]
[color=red][b]何时需要重启OFBiz[/b][/color]

你在做如下更改时需要重新启动OFBiz服务器:

-[color=blue] Java文件(记得要重新编译)

- 配置/.properties文件

- entitymodel或entitygroup XML定义文件

- 服务或secas XML文件

- JPublish XML文件[/color]

[color=red][b] 你在进行以下修改时无需重新启动OFBiz服务器:[/b][/color]

[color=blue]- freemarker FTL模版

- beanshell BSH模版

- Screens XML文件

- Forms XML文件
[/color]
- 控制器XML文件(注意:在opentaps-0.8和OFBiz 3.x及更早版本中,你在更改控制器时需要重启)

[color=red][b]但有可能你需要在浏览器中清除缓存[/b][/color][color=red][b]。比如修改使用的装饰器 很多时候需要重新启动浏览器的 [/b][/color]

[color=violet][b]忘记转载哪里 以前保存的下来的 [/b][/color]


1.当客户端发出请求时,调用第一个配置文件WEB-INF/controller.xml,根据请求的地址
处理方法1:直接调用java类的方法
<request-map uri="login">
<security https="true" auth="false"/>
<event type="java" path="org.ofbiz.webapp.control.LoginWorker" invoke="login"/>
<response name="success" type="view" value="main"/>
<response name="error" type="view" value="login"/>
</request-map>
如果为login,会查找path="org.ofbiz.webapp.control.LoginWorker"这个类的invoke="login"
这个方法进行处理
处理方式2:通过service配置文件取查找对应的service(常用)
<request-map uri="createForum">
<security https="true" auth="true"/>
<event type="service" path="" invoke="createForum"/>
<response name="success" type="view" value="FindForum"/>
<response name="error" type="view" value="FindForum"/>
</request-map>
表示调用的类型为type="service"调用的方法为invoke="createForum"
2.进入servicedef/services.xml,这是service的配置文件

从里面找到上面对应的配置信息
<service name="createForum" default-entity-name="GroupForum" engine="simple"
location="org/ofbiz/group/GroupServices.xml" invoke="createForum" auth="true">
<description>Create a GroupForum</description>
<permission-service service-name="exampleGenericPermission" main-action="CREATE"/>
<auto-attributes include="pk" mode="OUT" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
<override name="forumName" optional="false"/>
</service>
文件配置的createForum这个文件实现的相关信息location="org/ofbiz/group/GroupServices.xml"表示实现
是通过minilanguage配置文件
3.进入script下面的org/ofbiz/group/GroupServices.xml文件
通过minilanguage配置文件
<simple-method method-name="createForum" short-description="create a GroupForum">
<make-value entity-name="GroupForum" value-name="newEntity"/>
<sequenced-id-to-env sequence-name="GroupForum" env-name="newEntity.forumId"/> <!-- get the next sequenced ID -->
<field-to-result field-name="newEntity.forumId" result-name="forumId"/>
<set-nonpk-fields map-name="parameters" value-name="newEntity"/>
<create-value value-name="newEntity"/>

</simple-method>
配置了对entity-name="GroupForum"实体的创建的相关信息和操作,该步骤可以用java代码实现.
4.进入实体配置文件部分
entitymodel.xml
<entity entity-name="GroupForum" package-name="org.ofbiz.group" title="GroupForum Entity">
<field name="forumId" type="id-ne"><!-- primary sequenced ID --></field>
<field name="forumName" type="name"></field>
<field name="description" type="description"></field>
<field name="authorID" type="id"></field>
<field name="created" type="date-time"></field>
<prim-key field="forumId"/>
</entity>
配置了entity-name="GroupForum" 的实体与数据库映射文件

entitygroup.xml
<entitygroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/entitygroup.xsd">
<entity-group group="org.ofbiz" entity="GroupForum"/>
<entity-group group="org.ofbiz" entity="GroupCategory"/>
<entity-group group="org.ofbiz" entity="GroupThread"/>
<entity-group group="org.ofbiz" entity="GroupPost"/>
</entitygroup>
配置了实体名称的组

5.service执行成功后会返回到展现逻辑配置部分,也就是WEB-INF/controller.xml中
<request-map uri="login">
<security https="true" auth="false"/>
<event type="java" path="org.ofbiz.webapp.control.LoginWorker" invoke="login"/>
<response name="success" type="view" value="main"/>
<response name="error" type="view" value="login"/>
</request-map>
现在会请求到main中,
<view-map name="main" type="screen" page="component://group/widget/group/CommonScreens.xml#main"/>
在WEB-INF/controller.xml中找到main的配置信息
该显示用screen配置显示component://group/widget/group/CommonScreens.xml#main

6.现在根据地址找到配置文件component://group/widget/group/CommonScreens.xml
#main表示该文件中name为main的screen
<screen name="main">
<section>
<actions>
<set field="titleProperty" value="OrderOrderTaskList"/>
<set field="headerItem" value="tasklist"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/task/ordertasklist.bsh"/>
</actions>
<widgets>
<decorator-screen name="main-decorator">
<decorator-section name="body">
<container style="screenlet">
<container style="screenlet-header">
<label style="boxhead" text="Main Page"/>
</container>
<container style="screenlet-body">
<section>
<condition><if-empty field-name="userLogin"/></condition>
<widgets>
<container><label text="${uiLabelMap.ExampleMessage}"/></container>
</widgets>
</section>
<container><label text="${uiLabelMap.Welcome}"/></container>
</container>
</container>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>

<screen name="login">
<section>
<widgets>
<decorator-screen name="main-decorator">
<decorator-section name="body">
<platform-specific>
<html><html-template location="component://common/webcommon/login.ftl"/></html>
</platform-specific>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
</screens>
该配置文件配置了显示的数据以及显示的格式
其中数据是通过.bsh文件和service提供的,而显示的格式为ftl文件提供的

7.进入group\webapp\group\WEB-INF\actions\forum在
bsh为beansheel配置文件,语法与java类似,在这儿是为了提供显示数据

import java.util.*;
import java.io.*;
import org.ofbiz.entity.*;
import org.ofbiz.base.util.*;

security = request.getAttribute("security");
delegator = request.getAttribute("delegator");
userLogin = session.getAttribute("userLogin");
person = null;
if (userLogin != null ) {
person = userLogin.getRelatedOne("Person");
}
forumId = request.getParameter("forumId");
categoryId = request.getParameter("categoryId");
if ( categroyId == null ||UtilValidate.isEmpty(categoryId) ){
categoryId = delegator.getNextSeqId("GroupCategory");
}

groupCategory = delegator.findByPrimaryKey("GroupCategory", UtilMisc.toMap("categoryId", categoryId));
context.put("forumId", forumId);
context.put("categoryId", categoryId);
context.put("groupCategory", groupCategory);
context.put("person", person);
该文件把需要的数据放到返回的上下文中

8.进入到group\webapp\group\forum\listForum.ftl
该文件为Freemarker的文件,作用是代替jsp作显示层
<#if forums?has_content>
Some of the famous celebrities who have visited our site:


<table>
<ul>
<#list forums as forum>
<tr>
<li><td><a href ="EditForum?forumId=${forum.forumId?if_exists}">${forum.forumId?if_exists}</a></td>
<td>12 ${forum.forumName?if_exists}</td>
<td> ${forum.description?if_exists}</td>

<li><td><a href ="deleteForum?forumId=${forum.forumId?if_exists}">${forum.forumId?if_exists}</a></td>
</tr>

<tr>
<li><td><a href ="FindCategory?forumId=${forum.forumId?if_exists}">${forum.forumId?if_exists}</a></td>
<td><a href ="EditCategory?forumId=${forum.forumId?if_exists}">${forum.forumId?if_exists}</a></td>
<td> </td>

<li><td></td>
</tr>


</#list>
</ul>
</table>
</#if>

通过一些表达式和判断把数据显示出来,这样整个请求完毕


其他配置文件的作用:
data目录下的配置文件:
<entity-engine-xml>
<UserLogin userLoginId="DemoBuyer" currentPassword="47ca69ebb4bdc9ae0adec130880165d2cc05db1a" passwordHint=""/>
<UserLogin userLoginId="DemoRepAll" currentPassword="47ca69ebb4bdc9ae0adec130880165d2cc05db1a" passwordHint=""/>
<UserLogin userLoginId="DemoRepStore" currentPassword="47ca69ebb4bdc9ae0adec130880165d2cc05db1a" passwordHint=""/>
<UserLogin userLoginId="DemoCustCompany" currentPassword="47ca69ebb4bdc9ae0adec130880165d2cc05db1a" passwordHint=""/>
<UserLogin userLoginId="DemoCustAgent" currentPassword="47ca69ebb4bdc9ae0adec130880165d2cc05db1a" passwordHint=""/>
<UserLogin userLoginId="DemoCustomer" currentPassword="47ca69ebb4bdc9ae0adec130880165d2cc05db1a" passwordHint=""/>
<UserLogin userLoginId="supplier" partyId="externaluser" currentPassword="47ca69ebb4bdc9ae0adec130880165d2cc05db1a" passwordHint=""/>
<UserLoginSecurityGroup groupId="ORDERSUPPLIER_LTD" userLoginId="supplier" fromDate="2001-01-01 12:00:00.0"/>
</entity-engine-xml>
配置了系统启动时后需要添加的一些数据

config目录下的配置文件:为国际化配置信息
<property key="OrderCaughtExceptionOnCartUpdate">
<value xml:lang="en">Caught exception on cart update. </value>
<value xml:lang="es">Excepción capturada en la actualización del carro.</value>
<value xml:lang="fr">%Exception attrapée dans la mise à jour du chariot. %</value>
<value xml:lang="it">Eccezione sull'aggiornamento carrello. </value>
<value xml:lang="ro">Exceptie la actualizarea cosului. </value>
<value xml:lang="zh">更新购物车时发生意外情况 </value>
</property>

widget里面的form配置文件:
<form name="OrderPurchaseProductOptions" type="single" target="OrderPurchaseReportProduct.pdf" title="" extends="OrderPurchaseReportOptions">
<field name="fromOrderDate" title="${uiLabelMap.OrderReportFromDate}"><date-time type="timestamp"/></field>
<field name="thruOrderDate" title="${uiLabelMap.OrderReportThruDate}"><date-time type="timestamp"/></field>
<field name="submitButton" title="${uiLabelMap.CommonRun}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
配置了一些表单信息,和screen一样,但是他可以直接显示数据不需要使用Freemaerker的文ftl文件作页面布局,根据配置信息可以直接生成

ofbiz-componet.xml文件配置了项目要加载的配置文件的信息,它可以告诉OFBIZ应用程序组件的相关信息:数据模型,商业逻辑,用户接口,种子数据,以及其他程序需要的资源。
<ofbiz-component name="order"
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="jar" location="build/lib/*"/>
<classpath type="dir" location="config"/>
<classpath type="dir" location="script"/>
<classpath type="dir" location="email"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_old.xml"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_view.xml"/>
<entity-resource type="group" reader-name="main" loader="main" location="entitydef/entitygroup.xml"/>
<entity-resource type="eca" reader-name="main" loader="main" location="entitydef/eecas.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/OrderTypeData.xml"/>
<entity-resource type="data" reader-name="seed-initial" loader="main" location="data/OrderScheduledServices.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/OrderSecurityData.xml"/>
<entity-resource type="data" reader-name="demo" loader="main" location="data/OrderDemoUser.xml"/>
<entity-resource type="data" reader-name="demo" loader="main" location="data/OrderProcessWorkflow.xml"/>
<service-resource type="model" loader="main" location="servicedef/services.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_cart.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_shoppinglist.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_request.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_quote.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_requirement.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_return.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_opportunity.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_upgrade.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas.xml"/>

<test-suite loader="main" location="testdef/OrderTest.xml"/>

<webapp name="order"
title="Order"
server="default-server"
location="webapp/ordermgr"
base-permission="OFBTOOLS,ORDERMGR"
mount-point="/ordermgr"/>
</ofbiz-component>


eca.xml配置了调用指定的entity或者service触发的对应事件
entity:
<eca entity="OrderHeader" operation="create-store" event="return">
<condition field-name="statusId" operator="equals" value="ORDER_COMPLETED"/>
<condition field-name="needsInventoryIssuance" operator="equals" value="Y"/>
<action service="issueImmediatelyFulfilledOrder" mode="sync"/>
</eca>
service:
<eca service="changeOrderItemStatus" event="commit">
<condition field-name="statusId" operator="equals" value="ITEM_CANCELLED"/>
<action service="cancelOrderInventoryReservation" mode="sync"/>
<action service="recalcShippingTotal" mode="sync"/>
<action service="recalcTaxTotal" mode="sync"/>
<action service="resetGrandTotal" mode="sync"/>
<action service="checkOrderItemStatus" mode="sync"/>
</eca>

entityengine.xml配置了数据库连接的相关信息
<datasource name="localmssql"
helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
schema-name="dbo"
field-type-name="mssql"
check-on-start="true"//启用的数据库连接
add-missing-on-start="true"
join-style="ansi"
alias-view-columns="false"
use-fk-initially-deferred="false">
<read-data reader-name="seed"/>
<read-data reader-name="seed-initial"/>
<read-data reader-name="demo"/>
<read-data reader-name="ext"/>
<inline-jdbc
jdbc-driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc-uri="jdbc:sqlserver://10.0.70.15:1433;databaseName=ofbiz;SelectMethod=cursor;"
jdbc-username="ofbiz"
jdbc-password="ofbiz"
isolation-level="ReadCommitted"
pool-minsize="2"
pool-maxsize="250"/>
<!-- <jndi-jdbc jndi-server-name="default" jndi-name="comp/env/jdbc/xa/localmssql" isolation-level="ReadCommitted"/> --> <!-- Orion Style JNDI name -->
</datasource>





1、如何调试OFBiz

首 先你需要学习和熟悉OFBiz的教程与工具指导文档。指导文档特别重要,因为很多子主题内容不是排列最前的内容却可能导致问题的发生。你应该熟悉类似于 Freemaker,beanshell,XML这些技术。你也应该有过处理那些与OFBiz无关问题的经验,比如处理数据库或服务器引起的问题。

现 在,你应该仔细查看日志文件了解你错误发生的原因。OFBiz在日志文件中提供大量的信息,这些信息将有助于你了解你遇到的问题。它比处理的艺术更重要。 哪些东西看上去工作有些特别,比如比如有些关联程序将导致或影响到的结果,你都可以在日志文件中找到。如果你确实无法在日志文件中发现任何有用的东西,这 时增加你自己的日志信息直到你有足够的信息来发现实际的问题所在。

本指引将向你介绍OFBiz的日志文件工作情况,如何增加你自己的日志记录,以及一些常见信息的含义。这些知识的理解建立在你理解JAVA及其它相关的技术基础上,所有问题的焦点只在于OFBiz的概念与信息内容中。



2. OFBiz日志文件

OFBiz创建较多日志文件并将它们存储于logs/目录(在opentaps-0.9或更早版本中)或framework/logs/(在opentaps-0.9之后版本),文件有:

- ofbiz.log.? - 记录所有 OFBiz 生成日志信息。此文件将在满时自动循环创建新文件,即 ofbiz.log 是当前日志文件, ofbiz.log.1 是较早些时间的日志文 件,ofbiz.log.2是比ofbiz.log.1更早时间的日志文件,以此类推。

- console.log - 记录所有 OFBiz 在控制台界面运行显示的内容。也有可能无效。

- access_log.? - 类似于 Apache httpd 日志格式记录所有服务请求。很漂亮但对调试没有什么用处。

大多数据时间,你可以通过ofbiz.log或console.log来查询调试信息。因为它们有很多内容,所以你最好使用一个可以翻页与进行查找的编辑器来打开这些日志文件。



3、查找日志信息

Java日志信息最容易查找。它们的日志信息中通常有类名与行号生成:

111770[PaymentGatewayServices.java:776:INFO ] (Capture) Invoice [#10110] total: 38.54

Minilang方法日志中的类名均为Log.java,如:

112499[ Log.java:103:INFO ] Finished quickShipEntireOrder:\nshipmentShipGroupFacilityList=[[shipmentId=10120, facilityId=WebStoreWarehouse, shipGroupSeqId=00001]]\nsuccessMessageList=[Created shipment with ID [10120] for ship group ID [00001] for facility ID [WebStoreWarehouse]]

如果你在beanshell中直接使用输出,你输出的内容将显著的显示于日志文件中:

2006-07-19 13:46:26,373 [ ServiceDispatcher.java:450:DEBUG] [[Sync service finished- total:0.027,since last(Begin):0.027]] - 'ecommerce / getProductCategoryAndLimitedMembers'

parentCategory = TABLE-LINENS-SOLIDS

2006-07-19 13:46:26,874 [ PriceServices.java:802:INFO ] PromoPrice and ProductPriceAction had null amount and no default price was available, using list price: 2.0 for product with id 15899

如果你在beanshell中使用调试方法,你将在日志中得到如下信息:

2006-07-19 13:46:26,373 [ ?:?] parentCategory = TABLE-LINENS-SOLIDS

你可以为那些无法发现日志信息的minilang或beanshell代码中加入自己的信息输出。

所有freemarker,screen-widget或form widget输出的信息将直接显示在你的浏览器屏幕上。除非这些控件崩溃否则不会显示任何日志信息。



4. 增加你自己的日志信息

在Java中增加你自己的日志信息,请使用OFBiz Debug类(org.ofbiz.base.util.Debug)中的调试方法,如logInfo,logWarning, logError...

示例: Debug.logInfo("Now processing invoice " + invoiceId, module);

在beanshell中增加日志信息,同样使用Debug方法,但在内容中忽略如""这样内容。

在freemarker中增加日志信息,只需要显示你打算跟踪的变量,如:

${invoice} < #-- 将显示 invoice 的一般属性值 -- >

${invoice.invoiceId} < #-- 将显示 invoice.invoiceId 属性值 -- >



在minilang中增加日志信息,使用<log >指令并输入你的值,比如在freemarker中:

${invoice} < #-- will display the entire GenericValue invoice -- >

${invoice.invoiceId} < #-- will display the invoiceId field of invoice -- >



通常level节点属性用于设置日志级别,如:"info", "warning", "error",对应于Debug中的同名方法。



5. [color=red][b]何时需要重启OFBiz[/b][/color]

你在做如下更改时需要重新启动OFBiz服务器:

-[color=blue] Java文件(记得要重新编译)

- 配置/.properties文件

- entitymodel或entitygroup XML定义文件

- 服务或secas XML文件

- JPublish XML文件[/color]

[color=red][b] 你在进行以下修改时无需重新启动OFBiz服务器:[/b][/color]

[color=blue]- freemarker FTL模版

- beanshell BSH模版

- Screens XML文件

- Forms XML文件
[/color]
- 控制器XML文件(注意:在opentaps-0.8和OFBiz 3.x及更早版本中,你在更改控制器时需要重启)

[color=red][b]但有可能你需要在浏览器中清除缓存[/b][/color][color=red][b]。比如修改使用的装饰器 很多时候需要重新启动浏览器的 [/b][/color]



6. 常见错误及其含义:

Cannot locate service by name (captureBillingAccountPayment)

* 此服务 (captureBillingAccountPayment) 在所有 services.xml 定义中都找不到 .

Cannot find service location (org.ofbiz.order.order.OrderServices)

* 说明在 services XML 定义点上指向的资源不存在 . 如果这是一个 minilang 或 beanshell 服务,即服务引擎无法找到此文件。如果这是一个 Java 服务,则说明在 classpath 中无法查找到这个类。

Service method does not exist (com.opensourcestrategies.financials.invoice.InvoiceServices.setInvoiceDueDate(org.ofbiz.service.DispatchContext, java.util.Map))

* 含义是在某个 services.xml 指定的这个服务不存在对应的 Java 方法。通常发生于你在修改了 Java 文件后忘记再次编译它来使新增的方法生效。

java.lang.IllegalArgumentException: Could not get next sequenced ID for sequence name: Party (Could not get next sequenced ID for sequence name: Party).

* 系统无法取得实体的下一个自动 ID ,通常发生于数据库断开情况。

ERROR: insert or update on table "inventory_item" violates foreign key constraint "inv_item_facility"



* 在 "inventory_item" 表的插入 / 修改操作时违犯 "inv_item_facility" 外键约束。

Error calling event: org.ofbiz.webapp.event.EventHandlerException: Service invocation error (Commit transaction failed)

* 这是一个非常令人讨厌的错误信息。通常它意味着你访问的服务所触发的 ECA 链服务中有一个服务失败,于是导致全部的操作失败。服务引擎无法为你进一步跟 踪,所以你需要进入log文件中进一步查找错误原因。访问你的logs/ofbiz.log 或logs/console.log文件去了解触发错误的根本原因。



Unable to bind UserTransaction/TransactionManager to JNDI

* 这是在 opentaps 0.8/0.9 及 OFBiz 的 pre-Geronimo 版本在 Linux 系统下可能会发生的一个问题 . 解决方法可以在以下网址中找到 :

http://lists.ofbiz.org/pipermail/users/2004-June/004094.html

Message: The entity name must immediately follow the '&' in the entity reference.

org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.



* 这是一个 XSL:FO 错误并意味着你在文本中使了字符 '&' ,比如说你在描述或地址中使了这个字符。 XSL:FO 使用 xml 属性格式,所以你需要确认你在文本字段后放置 ?xml 。



7 . 远程 debug 调试:

如果是自己写的 java 实现代码,或找到了 ofbiz 的 java 实现代码,可以以监听模式启动 ofbiz, 在 ofbiz 启动后,运行 debug, 就可以对所选的 java 类进行远程断点调试,在调试当中,如果想要改代码,可以暂时不用重新编译,用 debug 的 execute 执行一下,可以欺骗当前运行,起到了不重启即可看到更新的效果。


转载自. 真忘记哪了 以前保存下来的
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值