WEB开发网
开发学院WEB开发Jsp 开发工具:用JBuiler玩转petstore 阅读

开发工具:用JBuiler玩转petstore

 2008-01-05 18:12:20 来源:WEB开发网   
核心提示:开发j2ee应用一直用Jbuiler(两个月前因工作关系开始用eclipse了),仓促开发了所谓数千万的项目(政府的),开发工具:用JBuiler玩转petstore,在banq的指点下,才忽然发现petstore中有很多可借鉴的东西,则persistence选false即可,WeblogicXXXEJB中的prima

开发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。


Tags:开发工具 JBuiler petstore

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接