我在SUN的J2EE上发布一个简单的EJB不成功

文艺青年2 2001-07-16 12:26:07
我用的J2EE1.3beta支持EJB2.0
我编写的是EJB1.1的例子,J2EE的deployTool已经正确载入我的程序

然后我进入菜单Tool—>Deploy进行配置,提示错误如下:
There was a deployment error

java.rmi.ServerException: RemoteException occurred in server thread;nested is ..
java.rmi.RemoteException: Error processing ejb jar:Compilation failed

Please refer to
<J2EE_HOME>/logs/<machine-name>j2ee/j2ee/error.log
for more information. Please verify your Application with the Verifier tool


...全文
136 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
文艺青年2 2001-07-17
  • 打赏
  • 举报
回复
你是做在CabinHome类中的方法:
public Cabin findByPrimaryKey(CabinPK pk)
throws FinderException, RemoteException;
}
吗?
如果是,我定义了呀(如上所示);
如果不是,我看有关书籍,好象CabinBean中不需要定义ejbFindByPrimaryKey方法呀
nintyuui 2001-07-17
  • 打赏
  • 举报
回复
我按你的程序DEPLOY了
报D:\j2sdkee1.2.1\repository\DIY28-2000J\gnrtrTMP\cabin\CabinHomeImpl.java:50: cla
ss CabinBean 中未找到方法 ejbFindByPrimaryKey(CabinPK)。
primaryKeys = ejb.ejbFindByPrimaryKey( param0);
是你在你的CabinBean中没有定义ejbFindByPrimaryKey,如果你使用EntityBean这个方法必须包含.
看你的程序没有必要写成EntityBean,你不和数据库大交到.写成sessionBean好了.
你要靠这个找工作?自己学会有一定的难度.
文艺青年2 2001-07-17
  • 打赏
  • 举报
回复
好,多谢了
bobosji 2001-07-17
  • 打赏
  • 举报
回复
bow2000@21cn.com
把你的文件邮给我,我试试看
文艺青年2 2001-07-17
  • 打赏
  • 举报
回复
哎,为什么没人帮助我
如果有人帮我解决了问题,我愿意支付RMB
文艺青年2 2001-07-17
  • 打赏
  • 举报
回复
哦,我试试
nintyuui 2001-07-17
  • 打赏
  • 举报
回复
在EntityBean中必须写.
在sessionBean中可以不写.
只在CabinHome中写不过必须在CabinBean中也定义.

bobosji 2001-07-16
  • 打赏
  • 举报
回复
看看你的log文件里写的什么,再校验一下你的bean
文艺青年2 2001-07-16
  • 打赏
  • 举报
回复
TO:bobosji(波波司机) 
我用verifier校验过了,没错!!!
文艺青年2 2001-07-16
  • 打赏
  • 举报
回复
nintyuui(壮志凌云) 
我的代码如下(你帮我看看好吗?):
//==============================================================================
1、远程接口 cabin.java
package com.titan.cabin;

import java.rmi.RemoteException;

public interface Cabin extends javax.ejb.EJBObject {
public String getName() throws RemoteException;
public void setName(String str) throws RemoteException;
public int getDeckLevel() throws RemoteException;
public void setDeckLevel(int level) throws RemoteException;
public int getShip() throws RemoteException;
public void setShip(int sp) throws RemoteException;
public int getBedCount() throws RemoteException;
public void setBedCount(int bc) throws RemoteException;
}
//==============================================================================
2、Bean类: CabinBean
package com.titan.cabin;

import javax.ejb.EntityContext;

public class CabinBean implements javax.ejb.EntityBean {

public int id;
public String name;
public int deckLevel;
public int ship;
public int bedCount;

public CabinPK ejbCreate(int id){
this.id = id;
return null;
}
public void ejbPostCreate(int id){
// Do nothing. Required.
}
public String getName(){
return name;
}
public void setName(String str){
name = str;
}
public int getShip(){
return ship;
}
public void setShip(int sp) {
ship = sp;
}
public int getBedCount(){
return bedCount;
}
public void setBedCount(int bc){
bedCount = bc;
}
public int getDeckLevel(){
return deckLevel;
}
public void setDeckLevel(int level ){
deckLevel = level;
}

public void setEntityContext(EntityContext ctx){
// Not implemented.
}
public void unsetEntityContext(){
// Not implemented.
}
public void ejbActivate(){
// Not implemented.
}
public void ejbPassivate(){
// Not implemented.
}
public void ejbLoad(){
// Not implemented.
}
public void ejbStore(){
// Not implemented.
}
public void ejbRemove(){
// Not implemented.
}
}
//==============================================================================
3、远程接口: CabinHome
package com.titan.cabin;

import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;

public interface CabinHome extends javax.ejb.EJBHome {

public Cabin create(int id)
throws CreateException, RemoteException;

public Cabin findByPrimaryKey(CabinPK pk)
throws FinderException, RemoteException;
}
//==============================================================================
4、主键类: CabinPK
package com.titan.cabin;

public class CabinPK implements java.io.Serializable {
public int id;

public int hashCode( ){
return id;
}
public boolean equals(Object obj){
if(obj instanceof CabinPK){
return (id == ((CabinPK)obj).id);
}
return false;
}
public String toString(){
return String.valueOf(id);
}

}
//==============================================================================
5、ejb-jar.xml
<?xml version="1.0" ?>
<!DOCTYPE ejb-jar (View Source for full doctype...)>
- <ejb-jar>
- <enterprise-beans>
- <entity>
<description>This Cabin enterprise bean entity represents a cabin on a cruise ship.</description>
<ejb-name>CabinBean</ejb-name>
<home>com.titan.cabin.CabinHome</home>
<remote>com.titan.cabin.Cabin</remote>
<ejb-class>com.titan.cabin.CabinBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>com.titan.cabin.CabinPK</prim-key-class>
<reentrant>False</reentrant>
- <cmp-field>
<field-name>id</field-name>
</cmp-field>
- <cmp-field>
<field-name>name</field-name>
</cmp-field>
- <cmp-field>
<field-name>deckLevel</field-name>
</cmp-field>
- <cmp-field>
<field-name>ship</field-name>
</cmp-field>
- <cmp-field>
<field-name>bedCount</field-name>
</cmp-field>
</entity>
</enterprise-beans>
- <assembly-descriptor>
- <security-role>
<description>This role represents everyone who is allowed full access to the cabin bean.</description>
<role-name>everyone</role-name>
</security-role>
- <method-permission>
<role-name>everyone</role-name>
- <method>
<ejb-name>CabinBean</ejb-name>
<method-name>*</method-name>
</method>
</method-permission>
- <container-transaction>
- <method>
<ejb-name>CabinBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
//==============================================================================
目录结构是这样的
com—titan—cabin
|——Cabin.class
|——CabinHome.class
|——CabinBean.class
|——CabinPK.class
META-INF\ejb-jar.xml
//==============================================================================
生成cabin.jar
jar cf cabin.jar com\titan\cabin\*.class META-INF\ejb-jar.xml

请各位大侠帮忙,小弟要用EJB吃饭找工作的呀



nintyuui 2001-07-16
  • 打赏
  • 举报
回复
程序对不对.
如果程序里的写法不符合EJB规范的话DEPLOY时也会出错.
文艺青年2 2001-07-16
  • 打赏
  • 举报
回复
大家帮帮忙啊
bobosji 2001-07-16
  • 打赏
  • 举报
回复
我记得Deploytool上有个校验的按钮的,你校验了没有?
文艺青年2 2001-07-16
  • 打赏
  • 举报
回复
以下是error.log文件里的内容:
Compilation failed.
at com.sun.ejb.codegen.GeneratorDriver.compileClasses(GeneratorDriver.java:319)
at com.sun.ejb.codegen.GeneratorDriver.preDeploy(GeneratorDriver.java:695)
at com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployEjbs(JarInstallerImpl.java:709)
at com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployApplication(JarInstallerImpl.java:216)
at com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployApplication(JarInstallerImpl.java:124)
at org.omg.stub.com.sun.enterprise.tools.deployment.backend._JarInstallerImpl_Tie._invoke(Unknown Source)
at com.sun.corba.ee.internal.corba.ServerDelegate.dispatch(ServerDelegate.java:334)
at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:272)
at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:84)
at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:99)

可我看不明白怎么除错

67,514

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧