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,
-- 
                                      _/_/_/       _/_/_/        _/_/_/
Ivens Porto                         _/     _/    _/            _/
OSE - Open Systems Engineering     _/     _/    _/            _/
http://www.ose.com.br             _/     _/      _/_/_/      _/_/_/_/
Phone: (55) 34 - 3214-5995       _/     _/            _/    _/
Fax:   (55) 34 - 3214-5994      _/     _/            _/    _/
                                 _/_/_/        _/_/_/       _/_/_/


-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations
Here's your chance to show off your extensive product knowledge
We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to