以下是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)可我看不明白怎么除错
我记得Deploytool上有个校验的按钮的,你校验了没有?
程序对不对. 如果程序里的写法不符合EJB规范的话DEPLOY时也会出错.
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吃饭找工作的呀
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)可我看不明白怎么除错
如果程序里的写法不符合EJB规范的话DEPLOY时也会出错.
我的代码如下(你帮我看看好吗?):
//==============================================================================
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吃饭找工作的呀
我用verifier校验过了,没错!!!
如果有人帮我解决了问题,我愿意支付RMB
把你的文件邮给我,我试试看
报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好了.
你要靠这个找工作?自己学会有一定的难度.
public Cabin findByPrimaryKey(CabinPK pk)
throws FinderException, RemoteException;
}
吗?
如果是,我定义了呀(如上所示);
如果不是,我看有关书籍,好象CabinBean中不需要定义ejbFindByPrimaryKey方法呀
在sessionBean中可以不写.
只在CabinHome中写不过必须在CabinBean中也定义.