我部署BMP的时候在控制台(浏览器)提示如下错误信息:[Deployer:149233]An unexpected error was encountered during the deployment process.[Deployer:149033]preparing application bmp on myserver
[Deployer:149033]failed application bmp on myserver
[Deployer:149034]An exception occurred for task [Deployer:149026]Deploy application bmp on myserver.: [Deployer:149233]An unexpected error was encountered during the deployment process.. 何解?哪位大侠知道的,帮忙吧。谢谢!
代码如下:
Account.java(远称接口)package bmp;import javax.ejb.*;
import java.rmi.*;
public interface Account extends EJBObject{
public void setName(String name) throws RemoteException;
public String getName() throws RemoteException;
public void setAge(String age) throws RemoteException;
public String getAge() throws RemoteException;
}
AccountHome.java(home接口)
package bmp;import javax.ejb.*;
import java.rmi.*;
public interface AccountHome extends EJBHome{
public Account create(String id,String name,String age) throws CreateException,RemoteException;
public Account findName(String name) throws FinderException,RemoteException;
public Account findByPrimaryKey(AccountPK key) throws FinderException,RemoteException;
}AccountPK.java(主键类)
package bmp;import java.io.*;
public class AccountPK implements Serializable{
public String accountID;
public AccountPK(String id){
this.accountID=id;
}
public String toString(){
return accountID;
}
public boolean equals(Object account){
return ((AccountPK)account).equals(accountID);
}
}
AccountBean.java(BEAN类)
package bmp;
import java.util.*;
import java.io.*;
import java.sql.*;
import javax.sql.*;
import java.rmi.*;
import javax.ejb.*;
import javax.ejb.EntityContext;
import javax.naming.*;
public class AccountBean implements EntityBean{
protected EntityContext ctx;
public String accountID;
public String name;
public String age;
public AccountBean(){
System.out.println("开始输出");
}
public void setName(String name){
this.name=name;
}
public String getName(){
return this.name;
}
public void setAge(String age){
this.age=age;
}
public String getAge(){
return this.age;
}
public void setAccountID(String id){
this.accountID=id;
}
public String getAccountID(){
return this.accountID;
}public void ejbActivate() throws RemoteException{}
public void ejbPassivate() throws RemoteException{}
public void ejbRemove() throws RemoteException{}
public void ejbStore() throws RemoteException{}
public void ejbLoad() throws RemoteException{
System.out.println("ejbload()");
AccountPK pk=(AccountPK)ctx.getPrimaryKey();
String id=pk.accountID;
Statement query=null;
ResultSet rs=null;
Connection conn=null;
try{
conn=getConnection();
String sqloka="select * from bmp where id='"+id+"'";
rs=query.executeQuery(sqloka);
rs.next();
name=rs.getString("name");
age=rs.getString("age");
accountID=rs.getString("id");
}
catch(Exception e){}
} public void setEntityContext(EntityContext ctx) throws RemoteException{
this.ctx=ctx;
} public void unsetEntityContext() throws RemoteException{
this.ctx=null;
}
public void ejbPossCreate(String id,String name,String age){
}
public Connection getConnection() throws Exception{
String driver="org.gjt.mm.mysql.Driver";
String url="jdbc:mysql://127.0.0.1:3306/bmp";
String name="root";
String pass="";
Connection conn=null;
try{
Class.forName(driver).newInstance();
conn=DriverManager.getConnection(url,name,pass);}
catch(Exception e){}
return conn;
}
public AccountPK ejbCreate(String accountID,String name,String age) throws CreateException,RemoteException{
Statement query=null;
ResultSet rs=null;
Connection conn=null;
try{
System.out.println("开始创建数据");
this.accountID=accountID;
this.name=name;
this.age=age;
conn=getConnection();
String sql="insert into bmp(id,name,age)values('"+accountID+"','"+name+"','"+age+"'";
query.executeUpdate(sql);
}
catch(Exception e){}
return new AccountPK(accountID);
}
public AccountPK findByPrimaryKey(AccountPK key) throws FinderException,RemoteException{
Statement query=null;
ResultSet rs=null;
Connection conn=null;
try{
System.out.println("开始查找");
conn=getConnection();
String mysql="select * from bmp where id='"+key.toString()+"'";
rs=query.executeQuery(mysql);
rs.next();}
catch(Exception e){}
return key;
}
public AccountPK ejbFindName(String name) throws FinderException,RemoteException{
Statement query=null;
ResultSet rs=null;
Connection conn=null;
String ida=null;
try{
System.out.println("开始查找");
conn=getConnection();
String sqlok="select * from bmp where name='"+name+"'";
rs=query.executeQuery(sqlok);
rs.next();
ida=rs.getString("id");
}
catch(Exception e){}
return new AccountPK(ida);
}
}
ejb-jar.xml部署文件<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<display-name>Account</display-name>
<enterprise-beans>
<entity>
<display-name>Account</display-name>
<ejb-name>Account</ejb-name>
<home>AccountHome</home>
<remote>Account</remote>
<ejb-class>AccountBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>AccountPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Account</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
[Deployer:149033]failed application bmp on myserver
[Deployer:149034]An exception occurred for task [Deployer:149026]Deploy application bmp on myserver.: [Deployer:149233]An unexpected error was encountered during the deployment process.. 何解?哪位大侠知道的,帮忙吧。谢谢!
代码如下:
Account.java(远称接口)package bmp;import javax.ejb.*;
import java.rmi.*;
public interface Account extends EJBObject{
public void setName(String name) throws RemoteException;
public String getName() throws RemoteException;
public void setAge(String age) throws RemoteException;
public String getAge() throws RemoteException;
}
AccountHome.java(home接口)
package bmp;import javax.ejb.*;
import java.rmi.*;
public interface AccountHome extends EJBHome{
public Account create(String id,String name,String age) throws CreateException,RemoteException;
public Account findName(String name) throws FinderException,RemoteException;
public Account findByPrimaryKey(AccountPK key) throws FinderException,RemoteException;
}AccountPK.java(主键类)
package bmp;import java.io.*;
public class AccountPK implements Serializable{
public String accountID;
public AccountPK(String id){
this.accountID=id;
}
public String toString(){
return accountID;
}
public boolean equals(Object account){
return ((AccountPK)account).equals(accountID);
}
}
AccountBean.java(BEAN类)
package bmp;
import java.util.*;
import java.io.*;
import java.sql.*;
import javax.sql.*;
import java.rmi.*;
import javax.ejb.*;
import javax.ejb.EntityContext;
import javax.naming.*;
public class AccountBean implements EntityBean{
protected EntityContext ctx;
public String accountID;
public String name;
public String age;
public AccountBean(){
System.out.println("开始输出");
}
public void setName(String name){
this.name=name;
}
public String getName(){
return this.name;
}
public void setAge(String age){
this.age=age;
}
public String getAge(){
return this.age;
}
public void setAccountID(String id){
this.accountID=id;
}
public String getAccountID(){
return this.accountID;
}public void ejbActivate() throws RemoteException{}
public void ejbPassivate() throws RemoteException{}
public void ejbRemove() throws RemoteException{}
public void ejbStore() throws RemoteException{}
public void ejbLoad() throws RemoteException{
System.out.println("ejbload()");
AccountPK pk=(AccountPK)ctx.getPrimaryKey();
String id=pk.accountID;
Statement query=null;
ResultSet rs=null;
Connection conn=null;
try{
conn=getConnection();
String sqloka="select * from bmp where id='"+id+"'";
rs=query.executeQuery(sqloka);
rs.next();
name=rs.getString("name");
age=rs.getString("age");
accountID=rs.getString("id");
}
catch(Exception e){}
} public void setEntityContext(EntityContext ctx) throws RemoteException{
this.ctx=ctx;
} public void unsetEntityContext() throws RemoteException{
this.ctx=null;
}
public void ejbPossCreate(String id,String name,String age){
}
public Connection getConnection() throws Exception{
String driver="org.gjt.mm.mysql.Driver";
String url="jdbc:mysql://127.0.0.1:3306/bmp";
String name="root";
String pass="";
Connection conn=null;
try{
Class.forName(driver).newInstance();
conn=DriverManager.getConnection(url,name,pass);}
catch(Exception e){}
return conn;
}
public AccountPK ejbCreate(String accountID,String name,String age) throws CreateException,RemoteException{
Statement query=null;
ResultSet rs=null;
Connection conn=null;
try{
System.out.println("开始创建数据");
this.accountID=accountID;
this.name=name;
this.age=age;
conn=getConnection();
String sql="insert into bmp(id,name,age)values('"+accountID+"','"+name+"','"+age+"'";
query.executeUpdate(sql);
}
catch(Exception e){}
return new AccountPK(accountID);
}
public AccountPK findByPrimaryKey(AccountPK key) throws FinderException,RemoteException{
Statement query=null;
ResultSet rs=null;
Connection conn=null;
try{
System.out.println("开始查找");
conn=getConnection();
String mysql="select * from bmp where id='"+key.toString()+"'";
rs=query.executeQuery(mysql);
rs.next();}
catch(Exception e){}
return key;
}
public AccountPK ejbFindName(String name) throws FinderException,RemoteException{
Statement query=null;
ResultSet rs=null;
Connection conn=null;
String ida=null;
try{
System.out.println("开始查找");
conn=getConnection();
String sqlok="select * from bmp where name='"+name+"'";
rs=query.executeQuery(sqlok);
rs.next();
ida=rs.getString("id");
}
catch(Exception e){}
return new AccountPK(ida);
}
}
ejb-jar.xml部署文件<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<display-name>Account</display-name>
<enterprise-beans>
<entity>
<display-name>Account</display-name>
<ejb-name>Account</ejb-name>
<home>AccountHome</home>
<remote>Account</remote>
<ejb-class>AccountBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>AccountPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Account</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货