I realize that this has been brought up a few times before, but I haven't
seen any resolution in the archives beyond pointing the finger at
misconfigured configuration files as being the problem.

I'm attempting to run a junit test on an application (I have the main app
and a single application client for testing) and every time I try something
like:

        InitialContext jndiContext = new InitialContext();
        Object ref  = jndiContext.lookup("java:comp/env/ejb/DynamicWorldObject");

        System.out.println(ref.getClass()); // gives me "__Proxy1"

        Object narrow = PortableRemoteObject.narrow(ref,
DynamicWorldObjectHome.class);
        // and in the line above, it throws the ClassCastException

        System.out.println(narrow.getClass());

        DynamicWorldObjectHome home = (DynamicWorldObjectHome)narrow;
        DynamicWorldObject dwo = home.create();

it fails with the ClassCastException thrown.

I've been through my config files, and I'm obviously just not getting
something. It all looks ok to me...I'd appreciate it if someone could
eyeball my files and point out my error:

-------------begin application.xml-----------------

<?xml version="1.0" ?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE
Application 1.2//EN" "<http://java.sun.com/j2ee/dtds/application_1_2.dtd>">
<application>
        <display-name>Dynamic World</display-name>
        <module>
                <ejb>DWE.jar</ejb>
        </module>
        <module>
                <java>DWE-test-client.jar</java>
        </module>
</application>

-------------end application.xml--------------------

-------------begin application-client.xml-----------

<?xml version="1.0" encoding="UTF-8"?>

<application-client>
        <ejb-ref>
                <ejb-ref-name>ejb/DynamicWorldObject</ejb-ref-name>
                <ejb-ref-type>Entity</ejb-ref-type>

<home>com.twilightminds.dynamicworld.ejbinterface.DynamicWorldObjectHome</ho
me>

<remote>com.twilightminds.dynamicworld.ejbinterface.DynamicWorldObject</remo
te>
                <ejb-link>DynamicWorldObject</ejb-link>
        </ejb-ref>

        <ejb-ref>
                <ejb-ref-name>ejb/TransactionTestA</ejb-ref-name>
                <ejb-ref-type>Session</ejb-ref-type>

<home>test.com.twilightminds.dynamicworld.ejbinterface.TransactionTestAHome<
/home>

<remote>test.com.twilightminds.dynamicworld.ejbinterface.TransactionTestA</r
emote>
                <ejb-link>TransactionTestA</ejb-link>
        </ejb-ref>

</application-client>

------------end application-client.xml------------------

------------begin ejb-jar.xml---------------------------

<?xml version="1.0" encoding="UTF-8"?>

<ejb-jar>
     <description>Dynamic World Engine</description>
     <display-name>Dynamic World Engine</display-name>
     <enterprise-beans>

       <entity>
         <ejb-name>DynamicWorldObject</ejb-name>

<home>com.twilightminds.dynamicworld.ejbinterface.DynamicWorldObjectHome</ho
me>

<remote>com.twilightminds.dynamicworld.ejbinterface.DynamicWorldObject</remo
te>

<ejb-class>com.twilightminds.dynamicworld.ejbinterface.DynamicWorldObjectBea
n</ejb-class>
         <persistence-type>Bean</persistence-type>
         <prim-key-class>java.lang.String</prim-key-class>
         <reentrant>True</reentrant>
       </entity>

        <session>
                <ejb-name>TransactionTestA</ejb-name>

<home>test.com.twilightminds.dynamicworld.ejbinterface.TransactionTestAHome<
/home>

<remote>test.com.twilightminds.dynamicworld.ejbinterface.TransactionTestA</r
emote>

<ejb-class>test.com.twilightminds.dynamicworld.ejbinterface.TransactionTestA
Bean</ejb-class>
                <session-type>Stateful</session-type>
                <transaction-type>Bean</transaction-type>

                <ejb-ref>
                        <ejb-ref-name>ejb/TestB</ejb-ref-name>
                        <ejb-ref-type>Session</ejb-ref-type>

<home>test.com.twilightminds.dynamicworld.ejbinterface.TransactionTestBHome<
/home>

<remote>test.com.twilightminds.dynamicworld.ejbinterface.TransactionTestB</r
emote>
                        <ejb-link>TransactionTestB</ejb-link>
                </ejb-ref>

        </session>

        <session>
                <ejb-name>TransactionTestB</ejb-name>

<home>test.com.twilightminds.dynamicworld.ejbinterface.TransactionTestBHome<
/home>

<remote>test.com.twilightminds.dynamicworld.ejbinterface.TransactionTestB</r
emote>

<ejb-class>test.com.twilightminds.dynamicworld.ejbinterface.TransactionTestB
Bean</ejb-class>
                <session-type>Stateful</session-type>
                <transaction-type>Bean</transaction-type>
        </session>

     </enterprise-beans>
</ejb-jar>

----------------end ejb-jar.xml----------------------------

Reason
http://www.exratio.com/



Reply via email to