开发j2ee应用一直用jbuiler(两个月前因工作关系开始用eclipse了),仓促开发了所谓数千万的项目(政府的),在banq的指点下,才突然发现petstore中有很多可借鉴的东西。
而jbuiler下玩petstore不是件很容易的事,本人在暑假期间花了三天时间解决了这个问题,愿与大家共享。本文只包括ejb部分。petstore的版本是bea提供的,因为我用的是weblogic,带来的一个附加的优点是学习了ejb的继承。
首先从以下地址下载petstore源码。
ftp://edownload:buy_me@ftpna2.bea.com/pub/downloads/petstore_1.3.1_02_bea.zip
0.按jbuilder标准拷贝文件至src目录
1.package com.sun.j2ee.blueprints.waf.view.taglibs.smart;
开始位置在com.sun.j2ee.bluprints.taglibs.smart,改。
2.新建petstore web app,自然引入原有的web pacakage
3.配好pointbase数据源:enterprise setup--database poilet(url中要注意去掉jdbc:)--jbuiler中配数据源(一直不能看到table,不知何原因。重启后没反应,删除jndi-definations.xml后,又乱改了一下密码,refresh才行。)
4.可以开始import ejb了,import所有带ejb子目录下的ejb。注意!primary key class手工写为java.lang.string报错:error parsing ejb file: source file not found for class: null。是指的string类找不到!麻烦!而写为com.sun.j2ee.blueprint.xxx.xxpk!也出错:包不对:com.sun.j2ee.blueprint.xxx.string。改为:com.sun.j2ee.blueprint.xxx.weblogicxxpk。又出错!
"estore.jar": unable to load a class specified in your ejb-jar.xml: unable to load primary key class: 'string'. possible causes: 1:
the primary key class is a java language primitive;
this is not allowed. 2: if the primary key is a compound key,
the compound primary key class is not in the jar file being compiled.
3: the classpath is incorrect.
此问题最后手工改:petstore.ejbgrpx中的java.lang.string解决。
注意:weblogicxxxejb的inheritence选项中指定ejb的父类。引完后必须手工选择table,table schema要把后缀ejb去掉,不然ejb-ql语句会出错。手工选择对应数据库的column,不然会报错:ejb-jar.xml中的cmp-field必须在weblogic-rdbms-jar中有对应元素。
另外,customerejb中account, profile都选对应的field为account_primarykey, profile_primarykey而不是同名的field!
5.一路顺利,但opcadminfacadeejb报告名称冲突。原因是建立了错误的ejb,找到那个打了叉的ejb视图。
6.ejb-ql书写。找到primiry-key之外的方法,搜索ejb-jar.xml中包括ejb名称的文件(有很多ejb-jar文件)。拷贝相应的ejb-ql语句。
7.ejbcreat方法必须返回primary-key类型的值。此问题的解决办法是在local home interface中定义主键时,使用(object key),jbuiler有时会自动改,再改回来!
8.把weblogicxxejb的primarykey的integer类型改为string类型,否则会说主键描述和定义的不一样。不能改父类的定义,只能这么改了,不知有无副作用。
9.console-security-user中把admin等用户的用户名改为petstore,以便登录
10.
(1)jms stores
myjms file store, jmsfilestore
myjms file store persist, p_jmsfilestore
(2)jms server
myjms server
注意选择persistent store, paging store
(3)connection factorys
jms/opc/queueconnectionfactory jms/opc/queueconnectionfactory n/a 4 0 0
jms/petstore/queueconnectionfactory jms/petstore/queueconnectionfactory n/a 4 0 0
jms/supplier/queueconnectionfactory jms/supplier/queueconnectionfactory n/a 4 0 0
jms/supplier/topicconnectionfactory jms/supplier/topicconnectionfactory n/a 4 0 0
weblogic default connection factory:weblogic.jms.connectfactory
(4)jms server destinction
//jms/opc/mailcompletedorderqueue jmsqueue jms/opc/mailcompletedorderqueue n/a default 0
//jms/opc/mailorderapprovalqueue jmsqueue jms/opc/mailorderapprovalqueue n/a default 0
//jms/opc/mailqueue jmsqueue jms/opc/mailqueue n/a default 0
//jms/opc/orderapprovalqueue jmsqueue jms/opc/orderapprovalqueue n/a default 0
jms/opc/orderqueue jmsqueue jms/opc/orderqueue n/a default 0
jms/petstore/asyncsenderqueue jmsqueue jms/petstore/asyncsenderqueue n/a default 0
//jms/supplier/purchaseorderqueue jmsqueue jms/supplier/purchaseorderqueue n/a default 0
//jms/opc/invoicetopic jmstopic jms/opc/invoicetopic n/a default 0
//jms/opc/mailinvoicetopic jmstopic jms/opc/mailinvoicetopic n/a default 0
11.mdb
it's so strange:mailinvoicetopic and invoicetopic no correcpondding conncetion factory,
i use jms/supplier/topicconnectionfactory
12.
[ejb:011031]the entity ejb requires the table: managerejb to be accessible.
please ensure that this table exists and is accessible.
更改weblogic-cmp-rdbms.jar中的所有table名,前面加上secame名:petstore
13.如果数据库中没有对应field,则persistence选false即可。
weblogicxxxejb中的primarykey field没有值,参照源码中的weblogic-cmp-rdbms.jar改为primarykey。
闽公网安备 35060202000074号