写了一个很简单的ejb无状态的session Beanpublic class Book implements SessionBean { /** The session context */
private SessionContext context; public Book() {
// TODO Auto-generated constructor stub
}
public Collection getBook(){
ArrayList al=new ArrayList();
BookPCls bp=new BookPCls();
bp.setBname("Java");
bp.setWriter("James");
al.add(bp);
return al;
}
public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub } public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub } public void ejbRemove() throws EJBException, RemoteException {
// TODO Auto-generated method stub }
public void setSessionContext(SessionContext newContext)
throws EJBException {
context = newContext;
}
public void ejbCreate() throws CreateException {
// TODO Add ejbCreate method implementation
}
public void replaceWithRealBusinessMethod() throws EJBException {
// rename and start putting your business logic here
}}remote接口:public interface BookRemote extends EJBObject {
public Collection getBook() throws RemoteException;
}
home接口:public interface BookHome extends EJBHome{
public void ejbCreate() throws CreateException,RemoteException;
}ejb-jar.xml:
<ejb-jar>
<description>
<![CDATA[No Description.]]>
</description>
<display-name>Generated by XDoclet</display-name>
<enterprise-beans>
<session>
<description>
<![CDATA[Description for test]]>
</description>
<display-name>Name for Book</display-name>
<ejb-name>Book</ejb-name>
<home>com.nwt.BookHome</home>
<remote>com.nwt.BookRemote</remote>
<ejb-class>com.nwt.Book</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
</assembly-descriptor>
</ejb-jar>部署时候错误如下:正在生成部署代码 ejbModule/com/nwt/EJSRemoteStatelessBookHome_c28fd646.java(93): 执行不到的 CreateException 的 catch 块。从未从 try 语句主体抛出此异常 ejbModule/com/nwt/EJSRemoteStatelessBookHome_c28fd646.java(93): 执行不到的 CreateException 的 catch 块。从未从 try 语句主体抛出此异常 Shutting down workbench. Execution Halted: Compilation Errors Reported 1 Errors, 0 Warnings, 0 Informational Messages 怎么解决?..
private SessionContext context; public Book() {
// TODO Auto-generated constructor stub
}
public Collection getBook(){
ArrayList al=new ArrayList();
BookPCls bp=new BookPCls();
bp.setBname("Java");
bp.setWriter("James");
al.add(bp);
return al;
}
public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub } public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub } public void ejbRemove() throws EJBException, RemoteException {
// TODO Auto-generated method stub }
public void setSessionContext(SessionContext newContext)
throws EJBException {
context = newContext;
}
public void ejbCreate() throws CreateException {
// TODO Add ejbCreate method implementation
}
public void replaceWithRealBusinessMethod() throws EJBException {
// rename and start putting your business logic here
}}remote接口:public interface BookRemote extends EJBObject {
public Collection getBook() throws RemoteException;
}
home接口:public interface BookHome extends EJBHome{
public void ejbCreate() throws CreateException,RemoteException;
}ejb-jar.xml:
<ejb-jar>
<description>
<![CDATA[No Description.]]>
</description>
<display-name>Generated by XDoclet</display-name>
<enterprise-beans>
<session>
<description>
<![CDATA[Description for test]]>
</description>
<display-name>Name for Book</display-name>
<ejb-name>Book</ejb-name>
<home>com.nwt.BookHome</home>
<remote>com.nwt.BookRemote</remote>
<ejb-class>com.nwt.Book</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
</assembly-descriptor>
</ejb-jar>部署时候错误如下:正在生成部署代码 ejbModule/com/nwt/EJSRemoteStatelessBookHome_c28fd646.java(93): 执行不到的 CreateException 的 catch 块。从未从 try 语句主体抛出此异常 ejbModule/com/nwt/EJSRemoteStatelessBookHome_c28fd646.java(93): 执行不到的 CreateException 的 catch 块。从未从 try 语句主体抛出此异常 Shutting down workbench. Execution Halted: Compilation Errors Reported 1 Errors, 0 Warnings, 0 Informational Messages 怎么解决?..
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货