You haven't declared "throws CreateException"
on the home interface's "void create()" method?
XDoclet created the home interface, and create() throws both javax.ejb.CreateException and java.rmi.RemoteException.
Post the relevent section of the server.log
and the full client side exception trace.
I took an example from Apple -- http://developer.apple.com/internet/java/enterprisejava.tar.gz --
and modified it slightly -- to always throw an exception in ejbCreate, and to better check for exceptions.
From the jboss log:
00:21:38,309 ERROR [STDERR] Caught class java.lang.reflect.UndeclaredThrowableException: null
00:21:38,310 ERROR [STDERR] java.lang.reflect.UndeclaredThrowableException
00:21:38,310 ERROR [STDERR] at $Proxy24.hi(Unknown Source)
00:21:38,311 ERROR [STDERR] at HelloWorldServlet.doGet(HelloWorldServlet.java:48)
00:21:38,311 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
00:21:38,311 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
(and more stack trace) followed by
00:21:38,323 ERROR [STDERR] Caused by: javax.ejb.CreateException: always throw an exception
00:21:38,324 ERROR [STDERR] at HelloWorldEJB.ejbCreate(HelloWorldEJB.java:19)
00:21:38,324 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
00:21:38,324 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
(and again more stack trace).
So the create exception is in there.
I've made a zip file containing my changes -- it can be found at http://homepage.mac.com/afyfe/
I've tried this both under Solaris as well as Mac OSX.
I see what the problem is.
For a stateless session bean the
create() operations just creates the local
proxy, it does not invoke ejbCreate()
This is done by pool as real requests come in,
in your case hi().
The pool couldn't create an instance to process
hi() because you threw the CreateException
which isn't on the definition of hi()
I changed the remote interface to throw both RemoteException and CreateException. The call to the remote interface method in the servlet will now catch a CreateException with the appropriate message.
I understood that a remote interface method should only have to deal with a RemoteException. Should the container be catching the CreateException and throwing a RemoteException in its place?