Calling ejbs from servlets without using web apps.

i am trying to instantiate and ejb from a servlet but it gives me the
          following error. the configuration and code that generated this error is
          attached below.
          oddly enough the same chunk of code works fine in a stand alone client if
          j2ee.jar;weblogic\classes and weblogicaux.jar are included in the classpath.
          any help would be appreciated.
          peter
          -8787844: in servlet.Webmedx.init
          -8787844: null
          java.lang.ClassCastException
          at
          com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow(Porta
          bleRemoteObject.java:296)
          at
          javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
          at webmedx.servlet.Webmedx.init(Webmedx.java:23)
          at javax.servlet.GenericServlet.init(GenericServlet.java:258)
          at
          weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubIm
          pl.java:474)
          at
          weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStub
          Impl.java, Compiled Code)
          at
          weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubI
          mpl.java:422)
          at
          weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.
          java:187)
          at
          weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
          pl.java:118)
          at
          weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
          textImpl.java:760)
          at
          weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
          textImpl.java:707)
          at
          weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
          ContextManager.java:251)
          at
          weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
          a:369)
          at
          weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:269)
          at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
          Code)
          configuration:
          WebLogic startup settings are presently:
          CLASSPATH Prefix
          \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
          logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar
          CLASSPATH
          \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
          logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar;\weblo
          gic\
          jre1_2\lib\tools.jar;\weblogic\jre1_2\jre\lib\rt.jar;\weblogic\jre1_2\jre\li
          b\i1
          8n.jar;C:\weblogic\license;C:\weblogic\classes\boot;C:\weblogic\classes;C:\w
          eblo
          gic\lib\weblogicaux.jar;C:\weblogic\eval\cloudscape\lib\cloudscape.jar
          JAVA_HOME \weblogic\jre1_2
          WEBLOGIC_LICENSEDIR C:\weblogic\license
          WEBLOGIC_HOME C:\weblogic
          system properties:
          java.security.manager
          java.security.policy=\weblogic\weblogic.policy
          weblogic.system.home=\weblogic
          java.compiler=symcjit
          weblogic.class.path=\weblogic\lib\weblogic510sp5.jar;\weblog
          ic\license;\weblogic\classes;\weblogic\lib\weblogicaux.jar
          INITIAL_HEAP 64 MB
          MAX_HEAP 64 MB
          SERVERCLASSPATH
          \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
          logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar;\weblo
          gic\
          jre1_2\jre\lib\rt.jar;\weblogic\jre1_2\jre\lib\i18n.jar;C:\weblogic\classes\
          boot
          ;C:\weblogic\eval\cloudscape\lib\cloudscape.jar
          Type "wlconfig -help" for program usage.
          code:
          public void init() throws ServletException{
          try{
          Log.debug("in servlet.Webmedx.init");
          Properties h = new Properties();
          h.put(Context.INITIAL_CONTEXT_FACTORY,
          "weblogic.jndi.WLInitialContextFactory");
          h.put(Context.PROVIDER_URL, "t3://localhost:7001");
          Context initial = new InitialContext(h);
          Object objref = initial.lookup("webmedx/pool");
          webmedxpoolhome =
          (WebmedxPoolHome)PortableRemoteObject.narrow(objref,WebmedxPoolHome.class);
          }catch(Exception ex){
          Log.error(ex);
          

The problem before was that you were trying to load the same class from
          2 different class paths. The ClassCastException is very un-intuitive in this
          case.
          Peter Ghosh wrote:
          > however, when i added it to the classpath prefix (not the
          > weblogic.classpath) it seemed to do the trick. very odd.
          > thanks,
          > peter
          >
          > "Peter Ghosh" <[email protected]> wrote in message
          > news:[email protected]...
          > > i tried that but no luck. any other suggestions?
          > > peter
          > >
          > > "Ohad Shany" <[email protected]> wrote in message
          > > news:[email protected]...
          > > > Is your EJB classes on the servlet classpath?
          > > > (weblogic.httpd.servlet.classpath property)
          > > >
          > > > I had some strange casting problem when my EJB classes was on the
          > servlet
          > > > classpath
          > > > and it was gone when i moved them to the weblogic.class.path . Worth a
          > > try.
          > > >
          > > > OHAD
          > > >
          > > > Peter Ghosh wrote:
          > > >
          > > > > i am trying to instantiate and ejb from a servlet but it gives me the
          > > > > following error. the configuration and code that generated this error
          > is
          > > > > attached below.
          > > > > oddly enough the same chunk of code works fine in a stand alone client
          > > if
          > > > > j2ee.jar;weblogic\classes and weblogicaux.jar are included in the
          > > classpath.
          > > > > any help would be appreciated.
          > > > > peter
          > > > >
          > > > > -8787844: in servlet.Webmedx.init
          > > > > -8787844: null
          > > > > java.lang.ClassCastException
          > > > > at
          > > > > com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow(Porta
          > > > > bleRemoteObject.java:296)
          > > > > at
          > > > > javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
          > > > > at webmedx.servlet.Webmedx.init(Webmedx.java:23)
          > > > > at javax.servlet.GenericServlet.init(GenericServlet.java:258)
          > > > > at
          > > > > weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubIm
          > > > > pl.java:474)
          > > > > at
          > > > > weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStub
          > > > > Impl.java, Compiled Code)
          > > > > at
          > > > > weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubI
          > > > > mpl.java:422)
          > > > > at
          > > > > weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.
          > > > > java:187)
          > > > > at
          > > > > weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
          > > > > pl.java:118)
          > > > > at
          > > > > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
          > > > > textImpl.java:760)
          > > > > at
          > > > > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
          > > > > textImpl.java:707)
          > > > > at
          > > > > weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
          > > > > ContextManager.java:251)
          > > > > at
          > > > > weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
          > > > > a:369)
          > > > > at
          > > > > weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:269)
          > > > >
          > > > > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
          > > > > Code)
          > > > >
          > > > > configuration:
          > > > >
          > > > > WebLogic startup settings are presently:
          > > > >
          > > > > CLASSPATH Prefix
          > > > > \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
          > > > > logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar
          > > > > CLASSPATH
          > > > > \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
          > > > >
          > >
          > logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar;\weblo
          > > > > gic\
          > > > >
          > >
          > jre1_2\lib\tools.jar;\weblogic\jre1_2\jre\lib\rt.jar;\weblogic\jre1_2\jre\li
          > > > > b\i1
          > > > >
          > >
          > 8n.jar;C:\weblogic\license;C:\weblogic\classes\boot;C:\weblogic\classes;C:\w
          > > > > eblo
          > > > > gic\lib\weblogicaux.jar;C:\weblogic\eval\cloudscape\lib\cloudscape.jar
          > > > > JAVA_HOME \weblogic\jre1_2
          > > > > WEBLOGIC_LICENSEDIR C:\weblogic\license
          > > > > WEBLOGIC_HOME C:\weblogic
          > > > > system properties:
          > > > > java.security.manager
          > > > > java.security.policy=\weblogic\weblogic.policy
          > > > > weblogic.system.home=\weblogic
          > > > > java.compiler=symcjit
          > > > >
          > > > > weblogic.class.path=\weblogic\lib\weblogic510sp5.jar;\weblog
          > > > > ic\license;\weblogic\classes;\weblogic\lib\weblogicaux.jar
          > > > > INITIAL_HEAP 64 MB
          > > > > MAX_HEAP 64 MB
          > > > > SERVERCLASSPATH
          > > > > \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
          > > > >
          > >
          > logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar;\weblo
          > > > > gic\
          > > > >
          > >
          > jre1_2\jre\lib\rt.jar;\weblogic\jre1_2\jre\lib\i18n.jar;C:\weblogic\classes\
          > > > > boot
          > > > > ;C:\weblogic\eval\cloudscape\lib\cloudscape.jar
          > > > >
          > > > > Type "wlconfig -help" for program usage.
          > > > >
          > > > > code:
          > > > >
          > > > > public void init() throws ServletException{
          > > > > try{
          > > > > Log.debug("in servlet.Webmedx.init");
          > > > > Properties h = new Properties();
          > > > > h.put(Context.INITIAL_CONTEXT_FACTORY,
          > > > > "weblogic.jndi.WLInitialContextFactory");
          > > > > h.put(Context.PROVIDER_URL, "t3://localhost:7001");
          > > > > Context initial = new InitialContext(h);
          > > > > Object objref = initial.lookup("webmedx/pool");
          > > > > webmedxpoolhome =
          > > > >
          > > > >
          > >
          > (WebmedxPoolHome)PortableRemoteObject.narrow(objref,WebmedxPoolHome.class);
          > > > > }catch(Exception ex){
          > > > > Log.error(ex);
          > > > > }
          > > > > }
          > > >
          > >
          > >
          

Similar Messages

  • How to run java servlet without using Web.xml?

    How to run servlet without using Web.xml? From a book, I know that web.xml descriptor is optional, but the book doesn't tell us how to run java servelet without web.xm descriptor. So how to do that? Thanks a lot.

    How to run servlet without using Web.xml?But Tomcat now uses a web.xml for its global server-wide configuration.
    If you'd like to invoke a servlet with:
    http://host/servlet/ServletName
    you have to enable the invoker servlet.
    [from an HTML]
      <FORM METHOD="POST" ACTION="/servlet/HGrepSearchSJ">
    [from resin.conf of Resin Web Server 2.1.12]
      <!--
         - The "invoker" servlet invokes servlet classes from the URL.
         - /examples/basic/servlet/HelloServlet will start the HelloServlet
         - class.  In general, the invoker should only be used
         - for development, not on a deployment server, because it might
         - leave open security holes.
        -->
      <servlet-mapping url-pattern='/servlet/*' servlet-name='invoker'/>
    [from TOMCAT5.0.19/conf/web.xml, a global server-wide web.xml file]
      <!-- The "invoker" servlet, which executes anonymous servlet classes      -->
      <!-- that have not been defined in a web.xml file.  Traditionally, this   -->
      <!-- servlet is mapped to URL pattern "/servlet/*", but you can map it    -->
      <!-- to other patterns as well.  The extra path info portion of such a    -->
      <!-- request must be the fully qualified class name of a Java class that  -->
      <!-- implements Servlet (or extends HttpServlet), or the servlet name     -->
      <!-- of an existing servlet definition.     This servlet supports the     -->
      <!-- following initialization parameters (default values are in square    -->
      <!-- brackets):                                                           -->
      <!--                                                                      -->
      <!--   debug               Debugging detail level for messages logged     -->
      <!--                       by this servlet.  [0]                          -->
        <servlet>
            <servlet-name>invoker</servlet-name>
            <servlet-class>
              org.apache.catalina.servlets.InvokerServlet
            </servlet-class>
            <init-param>
                <param-name>debug</param-name>
                <param-value>0</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet>
    ---comment out below----------------------------------------------------------
        <!-- The mapping for the invoker servlet -->
    <!--
        <servlet-mapping>
            <servlet-name>invoker</servlet-name>
            <url-pattern>/servlet/*</url-pattern>
        </servlet-mapping>
    -->

  • Error in calling EJB from servlet

    I've create a servlet as a client bean to call EJB
              I deploy the EJB, copy the servlet class (in .class format)
              (\config\<domain>\serverclass) and
              jsp to Weblogic 6.0
              When I run the JSP, It said that the EJB class not found.
              Please help
              Fannie
              

    Additional information :
              I added the path where ejb jar file located to the calsspath in
              startWebLogic.sh
              Thanks!!
              Fannie
              Fannie <[email protected]> wrote in message
              news:3ac84447$[email protected]..
              > I've create a servlet as a client bean to call EJB
              > I deploy the EJB, copy the servlet class (in .class format)
              > (\config\<domain>\serverclass) and
              > jsp to Weblogic 6.0
              > When I run the JSP, It said that the EJB class not found.
              >
              > Please help
              >
              > Fannie
              >
              >
              >
              >
              

  • Unable to call EJB from servlet

    Fillowing is my ejb module
    package univesity;
    import java.rmi.RemoteException;
    import javax.ejb.*;
    public interface EnrollmentCartHome extends javax.ejb.EJBHome
         EnrollementCartObject create() throws CreateException,RemoteException;
    package univesity;
    import java.rmi.RemoteException;
    public interface EnrollementCartObject extends javax.ejb.EJBObject
         public void addCourse(int courseID) throws RemoteException;
    package univesity;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    import javax.ejb.EJBException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    public class EnrollementCartEJBBean implements SessionBean
         int courseID;
         public void ejbActivate() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void ejbPassivate() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void ejbRemove() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void setSessionContext(SessionContext arg0) throws EJBException,
                   RemoteException {
              // TODO Auto-generated method stub
         public void addCourse(int courseID)
              System.out.println("i am in add course");
              System.out.println("i am in add course--->"+courseID);
         public void ejbCreate() throws CreateException
              System.out.println("i am in ejbCreate");
              courseID=0;
    }ejb-jar.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
              "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
              <jndi-name>ejb/EnrollmentCartHome</jndi-name>
    <ejb-jar>
         <description>Simplest Statefull Session Bean</description>
         <display-name>University EJB</display-name>
         <enterprise-beans>
           <session>
             <ejb-name>Enrollement</ejb-name>
             <home>university.EnrollementCartHome</home>
             <remote>university.EnrollementCartObject</remote>
             <ejb-class>university.EnrollementCartEJBBean</ejb-class>
             <session-type>Statefull</session-type>
             <transaction-type>Bean</transaction-type>
           </session>
         </enterprise-beans>
    </ejb-jar>here is my servlet
    package university;
    import javax.naming.InitialContext;
    import javax.servlet.*;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class EnrollCourse extends javax.servlet.http. HttpServlet
         public void doGet(HttpServletRequest req,HttpServletResponse res)
         public void doPost(HttpServletRequest req,HttpServletResponse res)
              try {
                        InitialContext ic = new InitialContext();
                        Object objRef = ic.lookup("ejb/EnrollmentCartHome");
                        university.EnrollementCartHome home=(university.EnrollementCartHome)javax.rmi.PortableRemoteObject.narrow(objref, university.EnrollementCartHome.class);
                        university.EnrollementCartObject obj=(university.EnrollementCartObject)home.create();
                        obj.addCourse(5);
              catch (Exception ex)
              { ex.printStackTrace(); }
    }i am getting following error
    java.lang.Error: Unresolved compilation problems:
         university.EnrollementCartHome cannot be resolved to a type
         university.EnrollementCartHome cannot be resolved to a type
         objref cannot be resolved
         university.EnrollementCartHome cannot be resolved to a type
         university.EnrollementCartObject cannot be resolved to a type
         university.EnrollementCartObject cannot be resolved to a type
         university.EnrollCourse.doPost(EnrollCourse.java:24)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

    Thanks for your continuous reply
    i solved all problems i have posted but now i am facing new problem that "EJB is already registerd"
    giving you stack trace
    15:21:22,109 WARN  [ServiceController] Problem creating service jboss.j2ee:module=UniversityProjectEJBModule.jar,uid=22223562,service=EjbModule
    javax.management.InstanceAlreadyExistsException: jboss.j2ee:jndiName=ejb/EnrollmentCartHome,service=EJB already registered.
         at org.jboss.mx.server.registry.BasicMBeanRegistry.add(BasicMBeanRegistry.java:761)
         at org.jboss.mx.server.registry.BasicMBeanRegistry.registerMBean(BasicMBeanRegistry.java:225)
         at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
         at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
         at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
         at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
         at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
         at org.jboss.mx.server.MBeanServerImpl$3.run(MBeanServerImpl.java:1422)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:1417)
         at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:376)
         at org.jboss.ejb.EjbModule.createService(EjbModule.java:373)
         at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
         at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
         at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
         

  • Calling EJB from from a client app

    Hi all,
    I am trying to call an EJB component from portal. The example EJB I have taken is from SDN Bonus Calculator example - Application Server/Web Dynpro/Samples and Tutorials/Using EJBs (20)
    I deployed the EAR file - no issue
    I wrote the following code in a client app and trying to connect to the EJB remotely.
              try {
                   java.util.Properties properties = new Properties();
                   properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
                   properties.put(Context.PROVIDER_URL, "ux0800:55304");
                   InitialContext ctx = new InitialContext(properties);
                   //InitialContext ctx = new InitialContext();
                   // get ejb home
                   home =
                        (BonusCalculatorLocalHome) ctx.lookup(
                             "localejbs/MySessionBean");
                   theCalculator = home.create();
              } catch (Exception namingException) {
                   namingException.printStackTrace();
    I get the following error
    javax.naming.NoInitialContextException: Cannot instantiate class: com.sap.engine.services.jndi.InitialContextFactoryImpl [Root exception is java.lang.ClassNotFoundException: com.sap.engine.services.jndi.InitialContextFactoryImpl]
         at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
         at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
         at javax.naming.InitialContext.init(Unknown Source)
         at javax.naming.InitialContext.<init>(Unknown Source)
         at com.sap.bonus.calculation.sessionBean.MyCommandBean.<init>(MyCommandBean.java:27)
         at com.sap.bonus.calculation.sessionBean.MyCommandBean.main(MyCommandBean.java:68)
    Caused by: java.lang.ClassNotFoundException: com.sap.engine.services.jndi.InitialContextFactoryImpl
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
    Any clue will be appreciated.
    thnx

    Hi Sabbir,
    Following code works for me in calling EJB from normal java application. Did you added the jar files to your application?. see the required jar files in end of code.
    Create simple java applcation do the following steps:
    Give JNDI name to the EJB(HelloJNDI)->Add the HelloEJB to HelloEAR ->deploy
    Proxy Program to call ejb:
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import com.sample.Hello;
    import com.sample.HelloHome;
    public class HelloTest {
         public static void main(String[] args) {
                       Hello remote = null;
                      try {
                        Context ctx = new InitialContext();
                        HelloHome home = (HelloHome) ctx.lookup("HelloJNDI");
                        remote = home.create();
                        String result = remote.hello();
                        System.out.print("Result:" + result);
                         } catch (Exception e) {
                                System.out.println("Exception:" + e.getLocalizedMessage());
    1. Go To  Run > Java Application ->New->select your project and select your main class(java program from which your going to call EJB)
    2. Click  next tab ->(x)=Arguments
    paste the following code in VM Arguments
    -Djava.naming.factory.initial=com.sap.engine.services.jndi.InitialContextFactoryImpl -Djava.naming.provider.url=localhost:50104
    replace the server IP address with your server IP address where your ejbs are running.
    Under Class path settings for the program put the following jar files.
    You can search for them from net weaver soruce folders
    or copy from D:\usr\sap\J2E\JC01\j2ee\j2eeclient
    ejb20.jar
    logging.jar
    exception.jar
    sapj2eeclient.jar
    Add Corresponding ejb.jar
    and RUN >>>
    this makes testing of your client programs easier, you can find the error trace on which line and saves lot of time.
    Regards, Suresh

  • Calling EJB from app client

    Hello, everybody,
    I'm very new at EJB and I'm trying to learn it.
    I have created Enterprise Application using Netbeans IDE, I have EJB and APP client. What I want is to connect to my MySql database and get some info from table.
    For e.g. Login and Password.
    How can I call EJB from my client app which connects to my database and gets information I need?

    What server you are using?
    if you use jboss AS ,here is a simple Main class how to connect EJB and access ejb methods:
    package com.david.ejb.client;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.rmi.PortableRemoteObject;
    import com.david.ejb.domain.Person;
    import com.david.ejb.domain.PersonRemote;
    public class Main {
         public static void main(String[] args) {
              try {
                   Context ctx = getInitialContext();
                   Object obj = ctx.lookup("PersonSessionRemote/remote");
                PersonRemote pr=(PersonRemote)PortableRemoteObject.narrow(obj, PersonRemote.class);
                Person p=new Person();
                p.setName("david");
                pr.addPerson(p);
                pr.findPerson(1);
                   // System.out.print(br.find(pk).getAuthor_name());
              } catch (Exception ex) {
                   ex.printStackTrace();
         private static Context getInitialContext() throws NamingException {
              Properties p = new Properties();
              p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
              p.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
              p.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
              return new InitialContext(p);
    }Person is ant @Entity and PersonRemote is remote interfaces, to connect database you have to make datasource file at jboss-4.2.3.GA\server\default\deploy
    simle mysql-ds.xml looks like this:
    datasources>
       <local-tx-datasource>
          <jndi-name>some name</jndi-name>
          <connection-url>jdbc:mysql://localhost:3306/dbname</connection-url>
          <driver-class>com.mysql.jdbc.Driver</driver-class>
          <user-name>root</user-name>
          <password>root password</password>
          <min-pool-size>5</min-pool-size>
          <max-pool-size>100</max-pool-size>
          <idle-timeout-minutes>15</idle-timeout-minutes>
          <exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
          <valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>
       </local-tx-datasource>
    </datasources>also at resources/META-INF directory you must have persistence.xml like this
    <persistence>
         <persistence-unit name="SimpleEjb">
              <jta-data-source>java:/some name</jta-data-source>
              <properties>
                   <property name="hibernate.hbm2ddl.auto" value="update" />
                   <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
                   <property name="hibernate.show_sql" value="true"/>
                   <property name="hibernate.format_sql" value="true"/>
              </properties>
         </persistence-unit>
    </persistence>

  • Reference EJB from servlet's action/helper classes

    Hello
    How to make a reference to stateless session bean from one of the helper classes of a servlet WITHOUT using any of these:
    * dependency injection (like @EJB) - I think this is not supported in this kind of class, EJB references can be injected only to servlets themselves or some other things (but not objects of classes "accompanying" a servlet)
    * home or local home interfaces (I would like to avoid writing them)
    * using mappedName (either in @Stateless or in ejb-jar) - since meaning of this is application-server dependent and thus not portable.
    By a "class accompanying a servlet" / "helper class" I mean utility or action classes, like MyActionClass, which would be instantiated and then used by a aforementioned servlet.
    Thanks.

    The EJB dependency must be looked up via the java:comp/env namespace since as you point out
    Java EE 5 environment annotations are not supported on POJOs. However, the dependency itself
    can either be defined using @EJB on some other managed class in the .war or within the
    web.xml. We have an entry in our EJB FAQ that has the details :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#POJOLocalEJB
    Also, whenever the client component resides in the same application as the target EJB (which is
    required for Local access but not for Remote access) there is no need to use mappedName to
    resolve the EJB dependency. It is either automatically resolved if the business interface type of
    the EJB dependency is only exposed by a single EJB in the application, OR the beanName()
    / ejb-link attributes can be used to unambiguously identify the target EJB using ejb-name.
    You can find more about this in the FAQ as well.

  • Executing an SSIS package from TSQL without using xp_cmdshell?

    How can I execute an SSIS package from TSQL without using xp_cmdshell?
    I have a web-app which calls some SQL which executes my SSIS package (a DTSX file, but stored in the server). But the security policy for my application won't permit me use to xp_cmdshell.
    I want to do this:-
    DECLARE @returncode int
    EXEC @returncode = xp_cmdshell 'dtexec /sq pkgOne"'
    Is there another way for executing a Package without going to the command line (e.g. is there some other system stored proc)?
    Thanks

    Whoa - don't go taking my words as saying "it should work".  I never said that - I just said I know less than you :)  I'm assuming that since the CLR is .Net, and you can launch a package from .Net code, you may be able to do so from the CLR. 
    But... I also know that CLR has lots of restrictions on it, and some of those may cause you to be unable to run it from the CLR.
    One thing I will say - I've never heard of anyone doing this.  That's got to tell you something about:
    Whether it can be done at all... although I think I'd have heard/seen something about how it's not possible.
    Whether it's a good idea... maybe other routes are less trouble.
    Talk to me now on

  • Call EJB from 10g

    Not familiar with EJB, hope my question makes sense.
    What are the avail. options of calling, from PL/SQL,
    Java program (EJB) that resides on NON-ORACLE app server (JBoss) ?
    thanks !
    10gR2

    Hello,
    You have 2 ways of calling an EJB from the DB:
    - EJB Call out, since it is JBoss you willl have to load the JBoss client API in the DB.
    - or expose the EJB as Web Service and call the Web Service from the DB using Web Services call out. Maybe theis approach is simpler since you do not have dependency on the EJB container and only use SOAP & HTTP protocols.
    Regards
    Tugdual Grall

  • Calling EJB from Java Stored Procedures

    Hi,
    I am trying to call an Enterprise Java Bean from stored procedure. This stored procedure calls a java program. As long as it is a simple java program it works fine and loadjava.exe does not give any problem (neither compile-time nor run-time).
    It is not working when I am trying to call EJB from it. It is giving compile-time error.
    If anybody has implemented the same please suggest how to go forward.
    thanks in advance,
    Shashank Agarwal

    I tried the same thing without any luck. I assume you are using OC4J for your EJB ...
    The compiling issue may be because you don't have the classes in your EJB client jar loaded into the database. Once those classes are loaded, you should loadjava without any problem.
    However, you won't be able to call the EJB server because the EJB client (your Java code in the DB) will need the OC4J environment (oc4j.jar). I have tried to load oc4j.jar into the DB as well, and that was a big mess and nothing worked. My DB is 8.1.7, maybe the new 9i have OC4J libs bundled?!?
    I looked around and only found 2 alternatives:
    1. Write a JSP page that acts like an EJB client, then use URLConnection in your DB java code to send params to the JSP for it to invlode the EJB
    2. Replace the JSP with RMI code, and use RMI instead of URLConnection in your DB code to invloke the EJB client.
    If you find any other solution, please share it here.
    Good luck!
    Hi,
    I am trying to call an Enterprise Java Bean from stored procedure. This stored procedure calls a java program. As long as it is a simple java program it works fine and loadjava.exe does not give any problem (neither compile-time nor run-time).
    It is not working when I am trying to call EJB from it. It is giving compile-time error.
    If anybody has implemented the same please suggest how to go forward.
    thanks in advance,
    Shashank Agarwal

  • Call a external application without using a webservice

    Hi all,
    How can we make a call to external application without using webservice from BPEL or OSB.Please share any links to refer.
    Thanks,
    Kiran

    Hi.
    Probably the options:
    1. Adapters. BPEL PM offers a different set of adapters that allows the process to communicate with external apps
    2. PRobably a basic HTTP POST could be an option
    3. Writing some code inside a Java Embedded activity
    Which application are u trying to communicate with?
    thx
    best

  • Calling class from servlet gives 500

    I have a servlet that works fine by itself, and another class that works fine by itself. However, when I try to create a new instance of the class using the servlet and access a method in the class such as:
    Servlet code
    Object a = new Object()
    a.method
    the server returns 500.
    Is there some security aspect to calling classes from servlets that may be causing this?

    Thanks for the replies which have tracked the problem down.
    The Server log says:
    NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
    This class is needed by the class being called by the servlet.
    The missing class is in a jar file which is put on the classpath when running the class in a standalone environment. I don't know if it's possible to put this jar on the classpath in the Server environment.
    However a solution is to explode the jar file and put the exploded classes in the WEB-INF/classes of the Server. The only disadvantage is that they get wiped out every time I re-deploy the application war file.

  • I have hidden unwanted books from the purchased area of the iBooks store, but they're are still appearing on the front page of iOS as cloud downloads, is there a way to remove these from iBooks without using the hide iCloud books button?

    I have hidden unwanted books from the purchased area of the iBooks store, but they're are still appearing on the front page of iOS as cloud downloads, is there a way to remove these from iBooks without using the hide iCloud books button?
    Let me explain a little more. I had downloaded a lot of free books in the past as a trial when iBooks was first released and since then I have decided I no longer want them, because of this I hid them from the purchased section of the iBooks store. The 5 books left are ones I decided to keep as seen in the following picture.
    This is how it appears in iBooks on my mac. There are 4 books downloaded and 1 book that I have decided not to download at this time. I would still like to keep this book available in the cloud incase I want to download it again in the future. You’ll notice that hide iCloud books is not selected, if I wanted to hide the book that I have chosen to keep in the cloud, but have not downloaded yet I could.
    This is exactly how I think this feature should work. If you have hidden a book from your purchases it should not show up in the mac Ibooks app. (I am aware you can never actually delete a purchase, just hide them and that hidden purchases can be restored to your account from within the account management section of the iBooks store).
    The iOS app is working differently for me. Here is a picture of the purchased tab on the iBooks store in iOS Ibooks. Again notice that pictures of Lilly is still yet to be downloaded. This is how I expected it to look.
    If we visit the front page of iOS iBooks the view is very different from what I expected. Here we can see the 4 books I wanted to keep on my device and have downloaded. We can also see the 1 book I wanted to keep, but did not want to store locally on the device and left in iCloud (Pictures of Lilly). However we can also see all the books I had hidden from the purchased section of my iTunes account and which I believe should no-longer be visible, Dracula, frankenstein etc…
    I am aware of the hide iCloud books button within the iOS app, but I did not need to use this to hide the books I had removed from the my purchased section of the iBooks store on the mac, why are they still appearing in iOS?
    I’m still not sure if this is a software glitch or not. This article suggests to me that books can be hidden, but I had already completed these steps.
    https://support.apple.com/en-us/HT201322
    A browse of google also suggests people may have been able to hide past purchases from the front page of iBooks on iOS in the past.
    In case there was an issue with syncing I tried logging in and out of my iTunes account via settings in iOS. Force closing the app, disabling automatic downloads and removing my device from iTunes in the cloud. Syncing with iTunes on the mac did not correct the issue either.
    Interestingly I have the same issue on my iPhone 6 running iOS 8.3 as I do on my iPad mini suggesting that this might be an issue either with my account or with iOS iBooks software in general.
    If there is a way to remove the already hidden iBooks in your account from the front page of iBooks on iOS without using the hide iCloud downloads button? Please help community!

    My apologies for the lack of photos, here is my post again with photos.
    I have hidden unwanted books from the purchased area of the iBooks store, but they're are still appearing on the front page of iOS as cloud downloads, is there a way to remove these from iBooks without using the hide iCloud books button?
    Let me explain a little more. I had downloaded a lot of free books in the past as a trial when iBooks was first released and since then I have decided I no longer want them, because of this I hid them from the purchased section of the iBooks store. The 5 books left are ones I decided to keep as seen in the following picture.
    This is how it appears in iBooks on my mac. There are 4 books downloaded and 1 book that I have decided not to download at this time. I would still like to keep this book available in the cloud incase I want to download it again in the future. You’ll notice that hide iCloud books is not selected, if I wanted to hide the book that I have chosen to keep in the cloud, but have not downloaded yet I could.
    This is exactly how I think this feature should work. If you have hidden a book from your purchases it should not show up in the mac Ibooks app. (I am aware you can never actually delete a purchase, just hide them and that hidden purchases can be restored to your account from within the account management section of the iBooks store).
    The iOS app is working differently for me. Here is a picture of the purchased tab on the iBooks store in iOS Ibooks. Again notice that pictures of Lilly is still yet to be downloaded. This is how I expected it to look.
    If we visit the front page of iOS iBooks the view is very different from what I expected. Here we can see the 4 books I wanted to keep on my device and have downloaded. We can also see the 1 book I wanted to keep, but did not want to store locally on the device and left in iCloud (Pictures of Lilly). However we can also see all the books I had hidden from the purchased section of my iTunes account and which I believe should no-longer be visible, Dracula, frankenstein etc…
    I am aware of the hide iCloud books button within the iOS app, but I did not need to use this to hide the books I had removed from the my purchased section of the iBooks store on the mac, why are they still appearing in iOS?
    I’m still not sure if this is a software glitch or not. This article suggests to me that books can be hidden, but I had already completed these steps.
    https://support.apple.com/en-us/HT201322
    A browse of google also suggests people may have been able to hide past purchases from the front page of iBooks on iOS in the past.
    In case there was an issue with syncing I tried logging in and out of my iTunes account via settings in iOS. Force closing the app, disabling automatic downloads and removing my device from iTunes in the cloud. Syncing with iTunes on the mac did not correct the issue either.
    Interestingly I have the same issue on my iPhone 6 running iOS 8.3 as I do on my iPad mini suggesting that this might be an issue either with my account or with iOS iBooks software in general.
    If there is a way to remove the already hidden iBooks in your account from the front page of iBooks on iOS without using the hide iCloud downloads button? Please help community!
    iPhone 6, iOS 8.3, Also an issue on my iPad mini iOS 8

  • How can I track my iPod without using an app ?

    Hey I lost my iPod touch in school and I think one of my classmates took it how do I track it down without using an app ?

    The only way to track it at all is to first have enabled an iCloud account on it before it was lost, with the find my iPod setting in that account's setting panel set to "ON".
    If that was done, you can log in to your iCloud account in a web browser and you can try to track it.  It must be on, and it must have an active wifi data connection to be trackable.
    Without an iCloud account already on it though, there is no way to track it.

  • Call ejb from browsers

    Hello Developers!
    I deployed my ejb to OAS4081. I call that
    from JDeveloper so it good. But when I try
    to call from applet in IExpl5 I can't
    instantiate the ORB. I've got a com.ms.security.SecurityException : oracle.oas.orb.CORBA.ORB.init
    I coded the CLASSPATH(oasoorb(yoj),client,
    ejbapi...) perfectly, I think.
    If anybody could help, please...
    Thanx!

    Hi there,
              I saw someone on this group had a problem to locate proper classpath
              to call EJB from JSP. I thought if you call EJB from classpath, you are
              calling the bean. But you loss all the EJB functions. To be able to utilize
              EJB features like object pooling. You need to call it from Weblogic server
              using url/jndi, not from the jar directly.
              Any comment? Am I right?
              BTW, my question about calling EJB from JSP means calling through URL,
              not a local path.
              Thank you
              >-------------------------------------------------------------------->
              Jim wrote in message <[email protected]>...
              >Hi there,
              > Can I call EJB from JSP? Is there a particular security setting or
              >concern for Weblogic? Is there an coding example?
              >
              >Thank you
              >
              >
              

Maybe you are looking for

  • ITunes Match 256 kbps

    I would like to know if there is a way make iTunes match stop coding my songs in the format of 256 kbps, sometimes I want to download songs and they are heavier than the ones that are on my PC 

  • File lock not released

    Hi, I am unable to delete certain files as JDeveloper does not release locks on them. One use case is when I run a build file to create a jar, war or ear file. After executing the builld, I open the file (this is when JDeveloper locks these files, I

  • Won't come back on?

    I have a 13" MacBook. Sometimes, when I turn off my laptop but leave it plugged in to charge... I'll leave and come back a little while later. The light on the magsafe plug is green, indicating a full charge. But when I try to turn on my laptop, noth

  • HT4623 Says I am not connected to the Internet.

    When trying to download update says I am not connected to the Internet.  Also was trying to connect to new online banking account and said safari was not connected.

  • OS X 10.5 Leopard to ML

    How do I upgrade from Leopard to Mountain Lion, with out buying Snow Leopard? I'm fine with wiping out my HDD.