Results 1 to 3 of 3

Thread: ClassCastException using EJB+Spring on Websphere AS

  1. #1
    Join Date
    May 2007
    Posts
    5

    Default ClassCastException using EJB+Spring on Websphere AS

    Hi ,

    I am using Spring + EJB on websphere. My applicationContext.xml looks like the below:
    Code:
    <bean id="aseSearchService" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
        <property name="jndiEnvironment">
            <props>
    		<prop key="java.naming.factory.initial">com.ibm.websphere.naming.WsnInitialContextFactory</prop>
    		<prop key="java.naming.provider.url">iiop://10.210.37.130:2809</prop>
            </props>
        </property>    
        <property name="jndiName" value="ejb/ASESearchService" />
    	</bean>
    I am invoking this using the below piece:
    Code:
    context = new ClassPathXmlApplicationContext("/WEB-INF/applicationContext-ase-client.xml");
    aseSearchService = (SearchService) context.getBeanFactory().getBean("aseSearchService");
    When I try to run this client on Websphere, I get the below error:

    Code:
    [6/7/07 20:52:29:042 IST] 00000024 SystemErr     R java.lang.ClassCastException: org.omg.stub.javax.ejb._EJBHome_Stub
            at com.ni.archive.controller.ASESearchClient.setUp(Unknown Source)
            at com.ni.archive.controller.ASESearchClient.service(Unknown Source)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
            at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled Code))
            at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
            at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2841)
            at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220)
            at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204)
            at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1681)
            at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
            at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
            at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
            at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
            at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback
    java:201)
            at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:103)
            at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548)
            at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
            at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934)
            at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021)
            at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
    This is really getting frustrating to debug . Please guide.

  2. #2
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    What is the classname of the object returned? Is it the same object type as a direct JNDI lookup?
    Bill

  3. #3
    Join Date
    Mar 2005
    Location
    The Netherlands
    Posts
    121

    Default

    Looks pretty obvious to me: you're telling Spring to look up the Home interface from the JNDI registry and then you're casting it to a SearchService, which it isn't.
    To have Spring perform the creating and narrowing of the SearchService interface for you, have a look at Spring's support for accessing EJB's as descibed in the reference manual.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •