EasyBeans is an open source implementation by ObjectWeb of the EJB3 container specification. 
X Wiki
  History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: EZB-159
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Florent BENOIT
Reporter: Nicolas Grenier
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
EasyBeans

Argument type mismatch when using embedded EasyBean

Created: 23/May/07 06:39 PM   Updated: 24/May/07 11:23 AM
Component/s: Core
Affects Version/s: EasyBeans 1.0 M6
Fix Version/s: None

Environment:
Java 5
OpenJPA 0.9.8


 Description  « Hide
I'm trying to use the embedded version of EasyBean into a simple Java application.
So I run the server with following code:

Embedded server = EmbeddedConfigurator.create(new URL("file:///config/easybeans.xml"));
server.getServerConfig().setShouldWait(false);
List<File> dirs = new ArrayList<File>();
dirs.add(new File("d:/easybeans-deploy"));
server.getServerConfig().setDeployDirectories(dirs);
server.start();

I've created one stateless session bean (UserManager / UserManagerBean) and one entity bean 3.0 (User) persisted with OpenJPA.
My session bean has a method (addUser) which takes an entity bean as an input parameter.
The issue is about this last thing.

In my simple test application I start the server, create a new instance of User and call the method addUser on UserManager's local interface. When doing so I get the following exception:

Exception in thread "main" javax.ejb.EJBException: java.lang.IllegalArgumentException: argument type mismatch
at org.objectweb.easybeans.rpc.AbsInvocationHandler.handleThrowable(AbsInvocationHandler.java:166)
at org.objectweb.easybeans.rpc.LocalCallInvocationHandler.invoke(LocalCallInvocationHandler.java:181)
at $Proxy5.addUser(Unknown Source)
at test.ejbs.TestEB.main(TestEB.java:33)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.objectweb.easybeans.container.session.stateless.StatelessSessionFactory.localCall(StatelessSessionFactory.java:151)
at org.objectweb.easybeans.rpc.LocalCallInvocationHandler.invoke(LocalCallInvocationHandler.java:173)
... 2 more


I think the problem comes from the fact that the User class I refer into my main program has been loaded by the JVM classloader and that the User class referenced by the EasyBean container has been loaded / instrumented by its own classloader. So from a JVM point of view the two classes are not the same.

 All   Comments   Change History   Related Builds   Subversion Commits      Sort Order:
Florent BENOIT - 23/May/07 11:44 PM
Yes, the "argument type mismatch" is not a well user-friendly error but this is printed because you're using local interfaces with different classloader.

You should use Remote interface I think or to give me more details about the way you call your bean (different JVM or not), etc.


Nicolas Grenier - 24/May/07 11:23 AM
Thanks for your reply.

Of course with remote interface it works. But as I'm co-localized in the same JVM I would like to use local interfaces instead.

For information here is the code of the main application:

package test.ejbs;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.naming.InitialContext;
import org.objectweb.easybeans.server.Embedded;
import org.objectweb.easybeans.server.EmbeddedConfigurator;
import test.ejbs.entity.User;
import test.ejbs.stateless.UserManager;

public class TestEB {

public static void main(String[] args)throws Exception{
Embedded server = EmbeddedConfigurator.create(new URL("file:///Temp/ebreport/config/easybeans.xml"));
server.getServerConfig().setShouldWait(false);
List<File> dirs = new ArrayList<File>();
dirs.add(new File("d:/Temp/ebreport/easybeans-deploy"));
server.getServerConfig().setDeployDirectories(dirs);
server.start();


InitialContext rootCtx = new InitialContext();
UserManager manager = (UserManager)rootCtx.lookup("test.ejbs.stateless.UserManagerBean_test.ejbs.stateless.UserManager@Remote");
User user = new User();
user.setId(1);
user.setFirstName("toto");
user.setLastName("titi");
manager.addUser(user);
}
}


A question : why not create a JVM agent to start the EasyBean server at JVM server when using the embedded version ? The advantage of an agent is that you can register a class transformer which allow you to instrument classes without having to use your own classloader. I think this would solve this issue no ?


Copyright © 2006-2007 EasyBeans / ObjectWeb consortium

http://www.easybeans.org