Topic: [求助]在JBuilder中编译EJB出错,急!!!!

  Print this page

1.[求助]在JBuilder中编译EJB出错,急!!!! Copy to clipboard
Posted by: greennba99
Posted on: 2004-02-01 16:46

我用JBuilder写了个EJB,已写好了远程接口,本地接口和Bean类,我把这三个文件分别编译都没问题,但如果是Make整个工程就出现以下错误信息:

Question"MusicEJB.jar": Spaces in the temporary directory path may cause WebLogic APPC utility to produce fatal compile errors.

Question"MusicEJB.jar": F:\bea\jdk141_02\bin\javaw -classpath "E:\Objects\MusicServer\classes;F:\bea\weblogic81\server\lib\weblogic_sp.jar;F:\bea\weblogic81\server\lib\weblogic.jar;F:\bea\weblogic81\server\lib\webservices.jar;" weblogic.appc -keepgenerated -forceGeneration -compiler F:/bea/jdk141_02/bin/javac E:/Objects/MusicServer/MusicEJB.jar.jar -output E:/Objects/MusicServer/MusicEJB.jar

Angry"MusicEJB.jar": <2004-2-1 下午16时04分11秒 CST> <Warning> <EJB> <BEA-010054> <EJB Deployment: LoginEJB has a class ejb.LoginEJB that is in the classpath. This class should only be located in the ejb-jar file.>

Angry"MusicEJB.jar": <2004-2-1 下午16时04分11秒 CST> <Warning> <EJB> <BEA-010054> <EJB Deployment: LoginEJB has a class ejb.LoginEJBHome that is in the classpath. This class should only be located in the ejb-jar file.>

Angry"MusicEJB.jar": <2004-2-1 下午16时04分11秒 CST> <Warning> <EJB> <BEA-010054> <EJB Deployment: LoginEJB has a class ejb.LoginEJBRemote that is in the classpath. This class should only be located in the ejb-jar file.>

Angry"MusicEJB.jar": [J2EE:160121]Errors encountered while compiling module 'E:\Objects\MusicServer\MusicEJB.jar.jar':

Angry"MusicEJB.jar": In EJB LoginEJB, the home interface findByPrimaryKey method parameter must be the primary key type or java.lang.Object: findByPrimaryKey(java.lang.String,java.lang.String)

Angry"MusicEJB.jar": In EJB LoginEJB, the throws clause for ejbFind method findByPrimaryKey(java.lang.String,java.lang.String) contains exceptions that are NOT in the throws clause of the home interface.

Light Bulb已下为远程接口,本地接口和Bean类的代码:

Light Bulb远程接口:
package ejb;

import java.rmi.RemoteException;
import javax.ejb.EJBObject;

//登陆注册远程接口类!!!!
public interface LoginEJBRemote extends EJBObject
{
public String clientName() throws RemoteException;

public String clientPassword() throws RemoteException;

public String clientEmail() throws RemoteException;

public int loginCount() throws RemoteException;
}

Light Bulb本地接口:
package ejb;

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

//登陆注册本地接口
public interface LoginEJBHome extends EJBHome
{
public LoginEJBRemote create(String cName, String cPassword, String cEmail) throws
CreateException, RemoteException;

public LoginEJBRemote findByPrimaryKey(String cName, String cPassword) throws
FinderException, RemoteException;
}

Light BulbBean类:
package ejb;

import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.FinderException;
import javax.ejb.NoSuchEntityException;
import javax.ejb.ObjectNotFoundException;
import javax.naming.InitialContext;
import javax.sql.DataSource;

//登陆注册的EJB类
public class LoginEJB implements EntityBean
{
private String cName;
private String cPassword;
private String cEmail;
private int count;

private EntityContext context;

private Connection con;

//业务方法实现
public String clientName() throws RemoteException
{
return cName;
}

public String clientPassword() throws RemoteException
{
return cPassword;
}

public String clientEmail() throws RemoteException
{
return cEmail;
}

public int loginCount() throws RemoteException
{
this.count = this.count + 1;
return this.count;
}

public void setEntityContext(EntityContext context)
{
this.context = context;
try
{
String dbName = "java:comp/env/jdbc/Music";

InitialContext cn = new InitialContext();
DataSource ds = (DataSource) cn.lookup(dbName);

con = ds.getConnection();
}
catch(Exception e)
{
System.out.printlnEnvelope;
e.printStackTrace();
}
}

public void unsetEntityContext()
{
try
{
con.close();
}
catch(Exception e)
{
System.out.printlnEnvelope;
e.printStackTrace();
}
}

public String ejbCreate(String cName, String cPassword, String cEmail) throws
CreateException
{
try //插入注册信息
{
String sql = "insert Client_Table values(?,?,?,?)";
PreparedStatement sta = con.prepareStatement(sql);
sta.setString(1, cName);
sta.setString(2, cPassword);
sta.setString(3, cEmail);
sta.setInt(4, 1);
sta.executeUpdate();
sta.close();
}
catch(Exception e)
{
throw new EJBException("ejbCreate: " + e.getMessage());
}

this.cName = cName;
this.cPassword = cPassword;
this.cEmail = cEmail;
this.count = 1;

return cName;
}

public void ejbPostCreate(String cName, String cPassword, String cEmail) throws
CreateException
{}

public String ejbFindByPrimaryKey(String PrimaryKey, String cPassword) throws
FinderException, SQLException
{
//登陆信息验证
String sql =
"select cName from Client_Table where cName=? and cPassword=?";
PreparedStatement sta = con.prepareStatement(sql);
sta.setString(1, PrimaryKey);
sta.setString(2, cPassword);
ResultSet result = sta.executeQuery();
if(result.next())
{
sta.close();

return PrimaryKey;
}
else
{
sta.close();
throw new ObjectNotFoundException("ejbFindByPrimaryKey: " +
PrimaryKey + " 该用户不存在!");
}
}

public void ejbRemove()
{}

public void ejbActivate()
{
this.cName = (String) context.getPrimaryKey();
}

public void ejbPassivate()
{
this.cName = null;
}

public void ejbLoad()
{
try
{
loadRow();
}
catch(Exception e)
{
throw new EJBException("ejbLoad: " + e.getMessage());
}
}

public void ejbStore()
{
try
{
storeRow();
}
catch(Exception e)
{
throw new EJBException("ejbStore: " + e.getMessage());
}
}

public void loadRow() throws SQLException
{
String sql =
"select cPassword,cEmail,iCount from Client_Table where cName=?";
PreparedStatement sta = con.prepareStatement(sql);
sta.setString(1, cName);
ResultSet result = sta.executeQuery();

if(result.next())
{
this.cPassword = result.getString(1);
this.cEmail = result.getString(2);
this.count = result.getInt(3);

sta.close();
}
else
{
sta.close();
throw new NoSuchEntityException("用户 " + cName + " 的数据没有找到,无法读入!");
}
}

public void storeRow() throws SQLException
{
String sql =
"update Client_Table set cPassword=?,cEmail=?,iCount=? where cName=?";
PreparedStatement sta = con.prepareStatement(sql);
sta.setString(1, cPassword);
sta.setString(2, cEmail);
sta.setInt(3, this.count);
sta.setString(4, cName);
int i = sta.executeUpdate();
sta.close();
if(i == 0)
{
throw new NoSuchEntityException("用户 " + cName + " 的数据没有找到,无法更新!");
}
}
}

(!)请各位大侠指点这个问题改怎么解决,由于我是初学者,所以请详细解答,非常感谢!!!!

2.Re:[求助]在JBuilder中编译EJB出错,急!!!! [Re: greennba99] Copy to clipboard
Posted by: cjsdn
Posted on: 2004-02-01 20:31

Spaces in the temporary directory path may cause WebLogic APPC utility to produce fatal compile errors

程序已经给出了提示,也是刚学的

3.Re:[求助]在JBuilder中编译EJB出错,急!!!! [Re: greennba99] Copy to clipboard
Posted by: greennba99
Posted on: 2004-02-03 15:42

我在创建这个EJB时所定的Primary Key Class为java.lang.String,创建后JBuilder会自动产生远程接口,本地接口和Bean类这三个文件,其中本地接口中的Find方法为:

public RemoteInterface findByPrimaryKey(String primKey) throws ObjectNotFoundException, RemoteException, FinderException;

这样整个工程能够成功编译,但我把Find方法改成:

public RemoteInterface findByPrimaryKey(String primKey,String primKey1) throws ObjectNotFoundException, RemoteException, FinderException;
再把Bean类文件中的Find方法做相应的修改后整个工程就不能成功编译了,出现以下错误信息:

"MusicEJB.jar": F:\bea\jdk141_02\bin\javaw -classpath "E:\Objects\MusicServer\classes;F:\bea\weblogic81\server\lib\weblogic_sp.jar;F:\bea\weblogic81\server\lib\weblogic.jar;F:\bea\weblogic81\server\lib\webservices.jar;" weblogic.appc -keepgenerated -forceGeneration -compiler F:/bea/jdk141_02/bin/javac E:/Objects/MusicServer/MusicEJB.jar.jar -output E:/Objects/MusicServer/MusicEJB.jar

"MusicEJB.jar": <2004-2-3 下午15时31分27秒 CST> <Warning> <EJB> <BEA-010054> <EJB Deployment: LoginEJB has a class ejb.EJBClass that is in the classpath. This class should only be located in the ejb-jar file.>

"MusicEJB.jar": <2004-2-3 下午15时31分27秒 CST> <Warning> <EJB> <BEA-010054> <EJB Deployment: LoginEJB has a class ejb.HomeInterface that is in the classpath. This class should only be located in the ejb-jar file.>

"MusicEJB.jar": <2004-2-3 下午15时31分27秒 CST> <Warning> <EJB> <BEA-010054> <EJB Deployment: LoginEJB has a class ejb.RemoteInterface that is in the classpath. This class should only be located in the ejb-jar file.>

"MusicEJB.jar": [J2EE:160121]Errors encountered while compiling module 'E:\Objects\MusicServer\MusicEJB.jar.jar':

"MusicEJB.jar": In EJB LoginEJB, the home interface findByPrimaryKey method parameter must be the primary key type or java.lang.Object: findByPrimaryKey(java.lang.String,java.lang.String)

也就是说我的主键是一个复合键,请问这个问题改这么解决,由于我是初学者,所以请详细解答,非常感谢!!!!

4.Re:[求助]在JBuilder中编译EJB出错,急!!!! [Re: greennba99] Copy to clipboard
Posted by: frankjin
Posted on: 2004-02-18 11:41

new a primary key class.

Public XXXPK{
private String pk1;
private String pk2;

//put set methods

//put get methods
}


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923