alex
Ivens Porto wrote:
Hi,
I'm using JBoss 3.2.2.
I have an entity bean (CMP) with a home method that returns all
instances of the bean, the method is called findAll.
When using a return type of java.util.Collection in the findAll method, my tests run fine.
But when I changed the type to java.util.Set my tests broked. When I call findAll on the home interface of my bean I get a java.lang.ClassCastException when using java.util.Set.
To make it clear, my home interface is:
public interface MyBeanHome extends javax.ejb.EJBHome { public java.util.Collection findAll() throws javax.ejb.FinderException,java.rmi.RemoteException;
/* other home method here */ }
The test I'm doing is very simple:
public void testFindAll() { try { Collection col = beanHome.findAll();
assertEquals(collectionExpectedSize, col.size()); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.toString()); } }
If I use a Collection, as exemplified above, the test works. But if I change to Set, both in the home interface and, of course in the test too, a ClassCastException happens.
The stack trace indicates that it happens inside the home object proxy:
------------------------------------------------------------------------ [junit] java.lang.ClassCastException [junit] at $Proxy0.findAll(Unknown Source) [junit] at br.com.ose.smartmovie.tests.entities.MultiplexBeanTest.testFindAll(MultiplexBeanTest.java:95) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [junit] at java.lang.reflect.Method.invoke(Method.java:324) [junit] at junit.framework.TestCase.runTest(TestCase.java:154) [junit] at junit.framework.TestCase.runBare(TestCase.java:127) [junit] at junit.framework.TestResult$1.protect(TestResult.java:106) [junit] at junit.framework.TestResult.runProtected(TestResult.java:124) [junit] at junit.framework.TestResult.run(TestResult.java:109) [junit] at junit.framework.TestCase.run(TestCase.java:118) [junit] at junit.framework.TestSuite.runTest(TestSuite.java:208) [junit] at junit.framework.TestSuite.run(TestSuite.java:203) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:848) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:556) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:532) [junit] at org.apache.tools.ant.Task.perform(Task.java:341) [junit] at org.apache.tools.ant.Target.execute(Target.java:309) [junit] at org.apache.tools.ant.Target.performTasks(Target.java:336) [junit] at org.apache.tools.ant.Project.executeTarget(Project.java:1339) [junit] at org.apache.tools.ant.Project.executeTargets(Project.java:1255) [junit] at org.apache.tools.ant.Main.runBuild(Main.java:609) [junit] at org.apache.tools.ant.Main.start(Main.java:196) [junit] at org.apache.tools.ant.Main.main(Main.java:235) --------------------------------------------------------------------------------
Can anyone help to clarify this?
Thanks,
------------------------------------------------------- This SF.net email is sponsored by: The SF.net Donation Program. Do you like what SourceForge.net is doing for the Open Source Community? Make a contribution, and help us add new features and functionality. Click here: http://sourceforge.net/donate/ _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
