Hi,
I am trying to invoke a method on my remote EJB SB using reflection.
This method takes a serilizable object as its parameter,
when trying to access this method with reflection code throws "java.lang.IllegalArgumentException: argument type mismatch"
I cross checked the paramter type its matching with the method in ejb
any help is appreciated
Regards
Shoj
-
Invoking Method reflection (9 messages)
- Posted by: Shoj mr
- Posted on: January 03 2006 08:56 EST
Threaded Messages (9)
- Invoking Method reflection by Debashish Ghosh on January 04 2006 15:08 EST
- Invoking Method reflection by Shoj mr on January 05 2006 01:17 EST
-
Invoking Method reflection by Sowmya Sridhar on January 05 2006 11:26 EST
- Invoking Method reflection by Shoj mr on January 09 2006 06:19 EST
-
Invoking Method reflection by Sowmya Sridhar on January 05 2006 11:26 EST
- Invoking Method reflection by Shoj mr on January 05 2006 01:17 EST
- code snippet plzzzzz by shreenee josh on January 10 2006 04:35 EST
- code snippet plzzzzz by Shoj mr on January 10 2006 08:03 EST
-
code snippet plzzzzz by D S on January 10 2006 08:23 EST
-
code snippet plzzzzz by shreenee josh on January 11 2006 09:46 EST
- EJBObject is the stub by Debashish Ghosh on January 13 2006 10:50 EST
-
code snippet plzzzzz by shreenee josh on January 11 2006 09:46 EST
-
code snippet plzzzzz by D S on January 10 2006 08:23 EST
- code snippet plzzzzz by Shoj mr on January 10 2006 08:03 EST
-
Invoking Method reflection[ Go to top ]
- Posted by: Debashish Ghosh
- Posted on: January 04 2006 15:08 EST
- in response to Shoj mr
Hi,
Just check whether the first argument is the stub object which is used to call the method on it .Hope this helps.
Cheers
Deb -
Invoking Method reflection[ Go to top ]
- Posted by: Shoj mr
- Posted on: January 05 2006 01:17 EST
- in response to Debashish Ghosh
Hi,
Its a value object not a Stub of any sort
Regards
Shoj -
Invoking Method reflection[ Go to top ]
- Posted by: Sowmya Sridhar
- Posted on: January 05 2006 11:26 EST
- in response to Shoj mr
Try to make it work first without using reflection. This eliminates the class version mismatches etc. These errors dont come out as simple errors when we use reflection. Once it works normally, u can try reflection. -
Invoking Method reflection[ Go to top ]
- Posted by: Shoj mr
- Posted on: January 09 2006 06:19 EST
- in response to Sowmya Sridhar
Hi
Its working without reflection !!!! -
code snippet plzzzzz[ Go to top ]
- Posted by: shreenee josh
- Posted on: January 10 2006 04:35 EST
- in response to Shoj mr
hi,
can you dump your code snippet here ? i think that would give us better idea since the exception stack is hardly enough.
shrini -
code snippet plzzzzz[ Go to top ]
- Posted by: Shoj mr
- Posted on: January 10 2006 08:03 EST
- in response to shreenee josh
public void myMethod(ValueObject vo)
{
Method[] methods = ejbObject.getClass().getMethods();
Method method;
int count = methods.length;
try {
Object[] args = new Object[1];
args[0] = vo;
for(int i=0; i<count;i++)
{
method = methods[i];
if(method.getName().equals("myMethod")){
method.invoke(ejbObject,args);
break;
}
}
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} -
code snippet plzzzzz[ Go to top ]
- Posted by: D S
- Posted on: January 10 2006 08:23 EST
- in response to Shoj mr
Is myMethod overloaded? Rather than getting all the methods on ejbObject and then looking for a matching name you might be better off getting the specific one that you want, specifying the parameter types:
Class[] types = { vo.getClass() };
method = ejbObject.getClass().getMethod("myMethod", types);
Object[] args = { vo };
method.invoke(ejbObject, args); -
code snippet plzzzzz[ Go to top ]
- Posted by: shreenee josh
- Posted on: January 11 2006 09:46 EST
- in response to D S
I agree with DS.
Can you try it and let us know ?
Also what is ejbObject ?
I mean is that a remote interface got from home ? Then check what is the ejbObject.getClass() ? I doubt that this may not be a remote interface ?
pls post ur findings.
shrini -
EJBObject is the stub[ Go to top ]
- Posted by: Debashish Ghosh
- Posted on: January 13 2006 10:50 EST
- in response to shreenee josh
EJBObject is the stub I mentioned above . It represents the client side stub to communicate ..
Thanks
Deb