Calling a newly deployed EJB from an EJB gives a NoSuchMethod Exception if the jar of the newly deployed ejb is not in the classpath

Hi ,
I have an EJB A which is already deployed when the server starts. A second ejb
B is deployed at a later time.
EJB A calls methods in EJB B. I use reflection in EJB A to call methods in EJB
B.
I get a NoSuchMethodException when I call the create method in the Home object
of EJB B. If I add the ejb jar file to the classpath before the server starts
then it is able to resolve the method.
The problem is the EJBs which are called from EJB A is not known before the server
is started. New EJBs can be deployed at runtime and EJB A should be able call
the methods in newly deployed EJB's.
I also use the URLClassLoader to load all the classes in the jar file of the newly
deployed EJB in EJB A and it still gives a NoSuchMethodException because it cannot
resolve the stub class.
My error log is shown below.
This is an urgent issue.
Thanks
SampleConnector::testEJBService called
In Key : P1 Value : Input2
In Key : P3 Value : Input1
In Key : P2 Value : SomeConst
Loaded Class = com.bizwave.samples.rejb.SampleRemote
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_EOImpl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_HomeImpl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_Impl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteHome
java.lang.NoSuchMethodException
at java.lang.Class.getMethod0(Native Method)
at java.lang.Class.getDeclaredMethod(Class.java:1151)
at com.bizwave.samples.ejb.SampleConnectorEJB.testEJBService(SampleCon
ctorEJB.java:181)
at com.bizwave.samples.ejb.SampleConnectorEJB_be5y1v_EOImpl.testEJBSer
ce(SampleConnectorEJB_be5y1v_EOImpl.java:98)
at java.lang.reflect.Method.invoke(Native Method)
at com.bizwave.fc.utils.ClassUtils.invokeEJBMethod(ClassUtils.java:109
at com.bizwave.infra.fjet.engine.EJBServiceStepMgr.executeService(EJBS
viceStepMgr.java:91)

Hi,
I am attaching a test case. This test case actually demonstrates a security bug.
Unzip the file and modify the StartWeblogic.cmd in domainA to not refer to the
SampleRemoteEJB.jar in the classpath. If u run the test client under the client
dir u will see a NoSuchMethodException.
The reason is it is not able to load the dynamically generated stub file.
Initially I had the getMethod and it didn't work. You might have to modify the
files to suit ur env. The easier way is to run th edomain wizard and create 2
domains. Run the servers in development mode and place the jars under the applications
dir
Thanks
Rajesh Mirchandani <[email protected]> wrote:
Do you have any old EJB classes in your classpath? Did you recompile
your EJBs if you
upgraded from a old release or a Service pack?
Bob Lee wrote:
Hmmmm. That's an interesting problem.
Why is it giving you a NoSuchMethodException instead of a
ClassNotFoundException?
Can you post the code from SampleConctorEJB.java, line 181?
Try changing your call to getDeclaredMethod() to getMethod().
getDeclaredMethod() searches only the class you called it on, whereas
getMethod() traverses to the superclasses and interfaces. You onlyneed
getDeclaredMethod() when you're accessing a nonpublic method.
Not sure if this will help, but it's worth a shot.
Bob
Vasu wrote:
Hi ,
I have an EJB A which is already deployed when the server starts.
A second ejb
B is deployed at a later time.
EJB A calls methods in EJB B. I use reflection in EJB A to call methodsin EJB
B.
I get a NoSuchMethodException when I call the create method in theHome object
of EJB B. If I add the ejb jar file to the classpath before the serverstarts
then it is able to resolve the method.
The problem is the EJBs which are called from EJB A is not knownbefore the server
is started. New EJBs can be deployed at runtime and EJB A shouldbe able call
the methods in newly deployed EJB's.
I also use the URLClassLoader to load all the classes in the jarfile of the newly
deployed EJB in EJB A and it still gives a NoSuchMethodExceptionbecause it cannot
resolve the stub class.
My error log is shown below.
This is an urgent issue.
Thanks
SampleConnector::testEJBService called
In Key : P1 Value : Input2
In Key : P3 Value : Input1
In Key : P2 Value : SomeConst
Loaded Class = com.bizwave.samples.rejb.SampleRemote
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_EOImpl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_HomeImpl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_Impl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteHome
java.lang.NoSuchMethodException
at java.lang.Class.getMethod0(Native Method)
at java.lang.Class.getDeclaredMethod(Class.java:1151)
at com.bizwave.samples.ejb.SampleConnectorEJB.testEJBService(SampleCon
ctorEJB.java:181)
at com.bizwave.samples.ejb.SampleConnectorEJB_be5y1v_EOImpl.testEJBSer
ce(SampleConnectorEJB_be5y1v_EOImpl.java:98)
at java.lang.reflect.Method.invoke(Native Method)
at com.bizwave.fc.utils.ClassUtils.invokeEJBMethod(ClassUtils.java:109
at com.bizwave.infra.fjet.engine.EJBServiceStepMgr.executeService(EJBS
viceStepMgr.java:91)
Rajesh Mirchandani
Developer Relations Engineer
BEA Support
[user_projects.zip]

Similar Messages

Maybe you are looking for