ofbiz实体引擎结合jbuilder的配置

03-08-05 uyang
最近在研究ofbiz,希望和有兴趣的人一起交流。

我的email:yangzhihong@sina.com

1.1 配置

这一节将给出实体引擎在jbuider中单独使用的配置向导

本文是从ofbiz网站的(OFBiz Quick Start Guide by Brett G. Palmer)的基础上完成配置。

1.从www.ofbiz.org中下载ofbiz-XX-XX-complete.zip包,本文用的是ofbiz-2.1.1-apps.zip

解开放到某个目录下,本文在j:\ofbiz,这也就是ofbiz.home的值

2.建立jbuilder项目,如下图所示

3.加入源文件,

ofbiz.home/core/src/entiry

ofbiz.home/core/src/share

4.加入所用到的jar文件

ofbiz.home/lib/common

ofbiz.home/lib/compile

ofbiz.home/lib/jasterreports

ofbiz.home/lib/jotm

ofbiz.home/lib/scripting

ofbiz.home/lib/share

ofbiz.home/lib/tyrex

5.将配置文件等导入工程

将ofbiz.home/commonapp/etc下所有文件打到ofbiz_etc.jar包内

jar cvf ofbiz_etc.jar *

将ofbiz.home/core/docs/xmldefs/ofbiz下所有文件打到ofbiz_dtd.jar包内

jar cvf ofbiz_dtd.jar *

将这两个包引入工程。

6.将ofbiz.home\setup\jrun4\servers\ofbiz\SERVER-INF\jndi.properties文件放入

ofbiz.home\lib\jotm\jotm.jar包内

7.配置ofbiz.home

在项目run tab中加入vm parameter:

-Dofbiz.home=j:\ofbiz

8.在GenericDelegator.java中,将下面语句注释掉。

/*

// setup the Entity ECA Handler

try {

Class eecahClass = loader.loadClass(ECA_HANDLER_CLASS_NAME);

this.entityEcaHandler = (EntityEcaHandler) eecahClass.newInstance();

this.entityEcaHandler.setDelegator(this);

} catch (ClassNotFoundException e) {

Debug.logWarning(e, "EntityEcaHandler class with name " + ECA_HANDLER_CLASS_NAME + " was not found, Entity ECA Rules will be disabled");

} catch (InstantiationException e) {

Debug.logWarning(e, "EntityEcaHandler class with name " + ECA_HANDLER_CLASS_NAME + " could not be instantiated, Entity ECA Rules will be disabled");

} catch (IllegalAccessException e) {

Debug.logWarning(e, "EntityEcaHandler class with name " + ECA_HANDLER_CLASS_NAME + " could not be accessed (illegal), Entity ECA Rules will be disabled");

} catch (ClassCastException e) {

Debug.logWarning(e, "EntityEcaHandler class with name " + ECA_HANDLER_CLASS_NAME + " does not implement the EntityEcaHandler interface, Entity ECA Rules will be disabled");

}

*/

9.测试文件Test.java

package org.ofbiz.core;

import org.ofbiz.core.entity.GenericDelegator;

import org.ofbiz.core.entity.GenericValue;

import org.ofbiz.core.util.UtilMisc;

import org.ofbiz.core.entity.*;

public class Test {

public static void main(String[] args) {

System.out.println("Entered testFindByPrimaryKey");

//Instantiate the delegator.

GenericDelegator delegator = GenericDelegator.getGenericDelegator("default");

// Find book by primary key

try {

GenericValue party= delegator.findByPrimaryKey("PartyType",

UtilMisc.toMap("partyTypeId", "PERSON"));

}

catch (GenericEntityException ex1) {

}

return;

}

}

10.ok

likewater
2003-08-11 15:31
好文,顶

myzoucp18
2003-08-11 20:44
谢谢,希望能给大家更多的帮助!

cc
2003-08-14 09:07
你把你配置好的东西压缩,上传上来吧。可以直接运行的

dev
2003-08-15 16:10
前段时间我研究过一阵子ofbize entity engine,发现他有几个问题,一个是对数据查询的分页不支持,只提供了一次查询返回所有记录的接口,效率很低。二是对于熟练的开发人员来说,它的查询接口显得很难用,不如sql。三是它的数据库配置文件不支持字段默认值(时间长了记不太清楚,记得当时好像翻遍了它的文档,也作了测试,好像是不支持默认值,而且对索引似乎也不支持)。四是它的entity和具体的java object没有映射关系。

因此我最后放弃了entity engine,转向castor jdo。jdo具有entity engine具有的功能,但是比它更自然更好用。

entity engine也有一些值得我们学习的地方,一是自动创建和维护数据库结构,二是通过使用中间类型做到数据库独立。

uyang
2003-08-16 11:43
有20M,在jdon能传吗?

conan
2004-02-25 11:01
各位大虾,我想单独使用ofbiz 的entity engine(ofbiz preview 3.0),请各位诊断一下:

1)ant build file(independbuild.xml ):

<?xml version="1.0"?>

<project name="OFBiz - Entity" default="jar" basedir=".">

<!-- ================================================================== -->

<!-- Initialization of all property settings -->

<!-- ================================================================== -->

<target name="init">

<property environment="env"/>

<property name="desc" value="Entity Component"/>

<property name="name" value="ofbiz-entity"/>

<property name="src.dir" value="src"/>

<property name="dtd.dir" value="dtd"/>

<property name="lib.dir" value="lib"/>

<property name="build.dir" value="build"/>

</target>

<target name="classpath">

<path id="local.class.path">

<fileset dir="${lib.dir}" includes="*.jar"/>

<fileset dir="${lib.dir}/dbcp" includes="*.jar"/>

<fileset dir="${lib.dir}/jdbc" includes="*.jar"/>

<fileset dir="${lib.dir}/jotm" includes="*.jar"/>

<fileset dir="../../base/lib" includes="*.jar"/>

<fileset dir="../../base/lib/logging" includes="*.jar"/>

<fileset dir="../../base/build/lib" includes="*.jar"/>

<fileset dir="${build.dir}/lib" includes="*.jar"/>

<fileset dir="../entityext/build/lib" includes="*.jar"/>

<fileset dir="../service/build/lib" includes="*.jar"/>

<fileset dir="../security/build/lib" includes="*.jar"/>

<pathelement location="../../base/config" />

<pathelement location="."/>

<pathelement location="config"/>

<pathelement location="entitydef"/>

<pathelement location="../service/config"/>

<pathelement location="../security/config"/>

</path>

</target>

<!-- ========================================================================

Target: run

Runs Test as a stand-alone application.

========================================================================= -->

<target name="run"

description="Runs EntityEngine Test as a standalone app."

depends="init,classpath">

<java classname="org.ofbiz.entity.Test" fork="true">

<classpath refid="local.class.path"/>

</java>

</target>

</project>

2) Test.java File:

package org.ofbiz.entity;

import org.ofbiz.entity.GenericDelegator;

import org.ofbiz.entity.GenericValue;

import org.ofbiz.base.util.UtilMisc;

import org.ofbiz.entity.*;

public class Test {

public static void main(String[] args) {

System.out.println("Entered testFindByPrimaryKey");

//Instantiate the delegator.

GenericDelegator delegator = GenericDelegator.getGenericDelegator("default");

// Find book by primary key

try {

GenericValue party= delegator.findByPrimaryKey("SequenceValueItem",

UtilMisc.toMap("seqName", "Party"));

System.out.println("seqName=["+party.getString("seqName")+"] seqId=["+party.getString("seqId")+"]");

}catch (GenericEntityException ex1) {

}

return;

}

}

3)重新build entity engine

4)run -f independbuild.xml run 后出现如下信息:

D:\ofbiz\components\entity>ant -f independentbuild.xml run

Buildfile: independentbuild.xml

init:

classpath:

run:

[java] Entered testFindByPrimaryKey

[java] 0 [ GenericDelegator.java:137:INFO ] Creating new Delegator wit

h name "default".

[java] 1071 [ ComponentConfig.java:103:WARN ] No components were found,

something is probably missing or incorrect in the component-load setup.

[java] 1081 [ ModelReader.java:260:INFO ] FINISHED LOADING ENTITIES

- ALL FILES; Entities=0 ViewEntities=0 Fields=0 Relationships=0

[java] 1101 [ ComponentConfig.java:103:WARN ] No components were found,

something is probably missing or incorrect in the component-load setup.

[java] 1201 [ ServiceDispatcher.java:74 :INFO ] [ServiceDispatcher] : Crea

ting new instance.

[java] 1271 [ ComponentConfig.java:103:WARN ] No components were found,

something is probably missing or incorrect in the component-load setup.

[java] 1271 [ ComponentConfig.java:103:WARN ] No components were found,

something is probably missing or incorrect in the component-load setup.

[java] 1492 [ ServiceDispatcher.java:140:INFO ] [ServiceDispatcher.registe

r] : Registered dispatcher: entity-default

[java] 1502 [ ComponentConfig.java:103:WARN ] No components were found,

something is probably missing or incorrect in the component-load setup.

[java] 1502 [ GenericDispatcher.java:85 :INFO ] [LocalDispatcher] : Create

d Dispatcher for: entity-default

[java] 1502 [ ComponentConfig.java:103:WARN ] No components were found,

something is probably missing or incorrect in the component-load setup.

[java] 1502 [ JobPoller.java:85 :INFO ] JobPoller: (org.ofbiz.serv

ice.job.JobPoller@2b3d53) Thread Running...

[java] 1522 [ JmsListenerFactory.java:72 :INFO ] Starting JMS Listener Fact

ory Thread...

[java] 1542 [ GenericDelegator.java:280:ERROR] Error getting entity defin

ition from model

[java] org.ofbiz.entity.GenericModelException: Could not find definition fo

r entity name SequenceValueItem

[java] at org.ofbiz.entity.model.ModelReader.getModelEntity(ModelReader

.java:321)

[java] at org.ofbiz.entity.GenericDelegator.getModelEntity(GenericDeleg

ator.java:278)

[java] at org.ofbiz.entity.GenericDelegator.makePK(GenericDelegator.jav

a:462)

[java] java.lang.IllegalArgumentException: [GenericDelegator.makePK] could

not find entity for entityName: SequenceValueItem

[java] at org.ofbiz.entity.GenericDelegator.makePK(GenericDelegator.jav

a:465)

[java] at org.ofbiz.entity.GenericDelegator.findByPrimaryKey(GenericDel

egator.java:600)

[java] at org.ofbiz.entity.GenericDelegator.findByPrimaryKey(GenericDel

egator.java:600)

[java] at org.ofbiz.entity.Test.main(Test.java:18)

[java] at org.ofbiz.entity.Test.main(Test.java:18)

[java] 1772 [ Jotm.java:98 :INFO ] JOTM started with a local

transaction factory which is not bound.

[java] 1782 [ Jotm.java:109:INFO ] CAROL initialization

[java] 2072 [ JobManager.java:123:ERROR] Cannot load jobs from data

source.

[java] org.ofbiz.entity.GenericModelException: Could not find definition fo

r entity name JobSandbox

[java] at org.ofbiz.entity.model.ModelReader.getModelEntity(ModelReader

.java:321)

[java] at org.ofbiz.entity.GenericDelegator.findByCondition(GenericDele

gator.java:985)

[java] at org.ofbiz.entity.GenericDelegator.findByAnd(GenericDelegator.

java:913)

[java] at org.ofbiz.service.job.JobManager.poll(JobManager.java:121)

[java] at org.ofbiz.service.job.JobPoller.run(JobPoller.java:89)

[java] at java.lang.Thread.run(Thread.java:536)

????????(Y/N)? y

D:\ofbiz\components\entity>

5)问题:如何才能找到SequenceValueItem的definition,不想让JobManager等出来?

谢谢

conan8chan@yahoo.com

猜你喜欢