问题描述
我正在阅读此页面上的教程:
I was reading the tutorial on this page:
http://edocs.bea.com/docs/cd/E13222_01/wls/docs81/medrec_tutorials/ejbgen.html#858279
我有以下文件BankAccountEJB.java
And I have the following file BankAccountEJB.java
import javax.ejb.CreateException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.CreateException;import javax.ejb.EntityBean;import javax.ejb.EntityContext;
public abstract class BankAccountEJB实现EntityBean {
public abstract class BankAccountEJB implements EntityBean {
private EntityContext context;
public void setEntityContext(EntityContext aContext) {
context = aContext;
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void ejbRemove() {
}
public void unsetEntityContext() {
context = null;
}
public void ejbLoad() {
}
public void ejbStore() {
}
public abstract String getName();
public abstract void setName(String name);
public abstract Float getBalance();
public abstract void setBalance(Float balance);
public java.lang.Long ejbCreate(String name, Float balance) throws CreateException {
if (name == null) {
throw new CreateException("The field \"key\" must not be null");
}
// TODO add additional validation code, throw CreateException if data is not valid
setName(name);
setBalance(balance);
setBalance(balance);
return null;
}
public void ejbPostCreate(java.lang.Long key) {
// TODO populate relationships here if appropriate
}
}
运行java weblogic.tools.ejbgen.EJBGen -ddOnlyGen BankAccountEJB.java,产生以下错误:
and I run java weblogic.tools.ejbgen.EJBGen -ddOnlyGen BankAccountEJB.java which produces the following error:
线程main中的异常com.bea.wls.ejbgen.EJBGenException :ejbName是com.bea.wls.ejbgen.Bean.createBeanSpecificTags(Bean.java:202)中必需的属性
(com.bea.wls.ejbgen.Bean)(Bean.java:127 )
at com.bea.wls.ejbgen.EntityBean。(EntityBean.java:76)
at com.bea.wls.ejbgen.EJBFactory.createBean(EJBFactory.java:135)
在com.bea.wls.ejbgen.EJBFactory.createBean(EJBFactory.java:99)
在com.bea.wls.ejbgen.EJBGenSGen.initModule(EJBGenSGen.java:106)
在com.bea .sgen.SGen.run(SGen.java:205)
at com.bea.wls.ejbgen.EJBGen.main(EJBGen.java:212)
at com.bea.wls.ejbgen.EJBGen .main(EJBGen.java:238)
在weblogic.tools。 ejbgen.EJBGen.main(EJBGen.java:21)
Exception in thread "main" com.bea.wls.ejbgen.EJBGenException: ejbName is a required attribute at com.bea.wls.ejbgen.Bean.createBeanSpecificTags(Bean.java:202) at com.bea.wls.ejbgen.Bean.(Bean.java:127) at com.bea.wls.ejbgen.EntityBean.(EntityBean.java:76) at com.bea.wls.ejbgen.EJBFactory.createBean(EJBFactory.java:135) at com.bea.wls.ejbgen.EJBFactory.createBean(EJBFactory.java:99) at com.bea.wls.ejbgen.EJBGenSGen.initModule(EJBGenSGen.java:106) at com.bea.sgen.SGen.run(SGen.java:205) at com.bea.wls.ejbgen.EJBGen.main(EJBGen.java:212) at com.bea.wls.ejbgen.EJBGen.main(EJBGen.java:238) at weblogic.tools.ejbgen.EJBGen.main(EJBGen.java:21)
任何输入都将非常感谢〜!
Any input will be greatly appreciated~!
推荐答案
注意:您仍然运行Weblogic 8.1 - 已经到了终点。 ejbgen还与EJB 2.x一起工作,在过去的两年中,开发已经转移到EJB 3 ,所以我建议您赶上这些。
Note: Are you still running Weblogic 8.1 - it's already reached end of life. Also ejbgen works with EJB 2.x and over the last 2 years, development has moved on to EJB 3, so i'd advise you to catch up on those.
现在您的具体问题。
您的代码似乎没有ejbgen所需的注释。
Your code does not seem to have the required annotations for ejbgen to work.
这样的注释用于生成描述符。
Annotations like this which are used in generation of the descriptors.
* @ejbgen:entity
* ejb-name = containerManaged
* table-name = ejbAccounts
* data-source-name = examples-dataSource-demoPool
* prim-key-class = AccountPK
* invalidation-target = ServiceDesignEJB
由于您的URL表示教程中的代码具有正确的数据一个示例 - 确保您在自己的代码中正确地复制了这些。
As your URL says the code in the tutorial has the right data as a sample - make sure you replicate those correctly in your own code.
对于ejbgen的另一个版本,请参阅
For another version of ejbgen, see http://www.beust.com/ejbgen/
这篇关于如何使用ejbGen为weblogic生成部署描述符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!