1 Reply Latest reply: May 27, 2012 4:53 AM by Ashishshinde-Oracle RSS

    Unable to Connect EJB 3.1  from Client in WebLogic Server 11g R1.

    user11995226
      Hi,
      I am trying to connect EJB from local client but i am unable to connect. I am getting the following error.

      java.lang.ClassCastException: weblogic.jndi.internal.WLContextImpl cannot be cast to tst.HemantRemote
           at cl.Client.main(Client.java:25)

      --------------------------
      Remote Interface:
      -------------------------
      package tst;

      import javax.ejb.Stateless;

      /**
      * Session Bean implementation class Hemant
      */
      @Stateless
      public class Hemant implements HemantRemote {

      /**
      * Default constructor.
      */
      public Hemant() {
      // TODO Auto-generated constructor stub
      }

      public void sayHello(String name)

      {
      System.out.println("Hello " + name + " It’s Working!");

      }

      }
      -------------
      Bean:
      -------------
      package tst;

      import javax.ejb.Stateless;

      /**
      * Session Bean implementation class Hemant
      */
      @Stateless
      public class Hemant implements HemantRemote {

      /**
      * Default constructor.
      */
      public Hemant() {
      // TODO Auto-generated constructor stub
      }

      public void sayHello(String name)

      {
      System.out.println("Hello " + name + " It’s Working!");

      }

      }
      --------------------
      ejb-jar.xml
      -------------------
      <?xml version="1.0" encoding="UTF-8"?>
      <ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1">
      <display-name>test </display-name>
      </ejb-jar>

      ------------------------------
      weblogic-ejb-jar.xml
      ------------------------------

      <?xml version="1.0" encoding="UTF-8"?>
      <wls:weblogic-ejb-jar xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.3/weblogic-ejb-jar.xsd">
      <!--weblogic-version:12.1.1-->
      </wls:weblogic-ejb-jar>



      i had included wlthink3Client.jar in build path.


      Thanks
      With Regards
      Hemant Joshi.