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.

Similar Messages

  • Passing contents of file as an argument while calling class from shell scri

    I am calling a class from shell script. One fo arguments which i want to pass to this class is the content of a text file. like:
    /opt/java/bin/javac CLASS_NAME "FILE_CONTENTS"
    if i give "cat FILE_NAME" it will take literally
    and if i dont use quotes then it will be considered as seperate arguments, how do i slve this?

    double-post http://forum.java.sun.com/thread.jspa?threadID=684422

  • 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);
              > > > > }
              > > > > }
              > > >
              > >
              > >
              

  • Calling JBean from Servlet

    Have a java bea located at \web-inf\classes\mybeans called UserData.java
    And would like to call it from my servlet to pass data located at \web-inf\classesHow would I do that?

    If your using webLogic server, then the below link may help you.
    http://edocs.bea.com/workshop/docs81/doc/en/core/index.html

  • Calling Class from Class

    Hi,
    I am sure this is a very basic question but I don't have anyone to ask, have tried a few formats but it does'nt like it. I have two compiled classes and wish to call one from the other, can anyone give me the format to do this?
    Thanks,
    Neil Mc

    class WotifReff {
        public static void main(String[] args) {
            WotifReft wotifreft = new WotifReft();
            wotifreft.call();
            WotifRef2 wotifref2 = new WotifRef2();
            wotifref2.call();
    }The only method that exists in your class is called "main". However you are attempting to call a method called "call". It does not exist. You can only call methods that do exist. So try adding that method to your class.
    class WotifReff {
        public static void main(String[] args) {
            WotifReft wotifreft = new WotifReft();
            wotifreft.call();
            WotifRef2 wotifref2 = new WotifRef2();
            wotifref2.call();
        public void call() {
            System.out.println("Now the code will compile");
    }OOPS! Misread your class names.
    class WotifReff {
        public static void main(String[] args) {
            WotifReft wotifreft = new WotifReft();
            wotifreft.call();
    class WotifReft {
        public void call() {
            System.out.println("Now the code will compile");
    }That should work.

  • How to call JSp from Servlet??

    Hello,
    I want to call JSP page from servlet.I am using Visual Age For java 3.4. What is wrong in my code??
    if (userExists) {
    f.setErrors("userName","Duplicate User: Try a different username");
    getServletConfig().getServletContext().
    getRequestDispatcher("/jsp/forms/retry.jsp").
    forward(request, response);
    I am not able to get the o/p. Pls help.

    I can't see anything obvious, but did you take any steps towards doing output before this code (like openning an output stream)?
    Not clear what f.setErrors does - presumably stuffs the error message in an attribute of the request.

  • Calling method from servlet

    hi,
    I want to call a method of an object that is available in a program already running, with parameters passed from the servlet.
    How to do it .
    Thanks.

    Pls be patient with me. I tried my best and couldn't achieve what I want.
    I provide the skeleton of what I have done and what I want to do.
    I have my core part in /home/raja/Service/Core.java, the only java file in Service folder. When I compile it I get some four class files(which are used in Core.java file internally). I don't compile it as a package but as a single file.
    I run the program in the same folder and in main method I use an infinite loop to keep the program running infinitely.
    And I have a html as, usr/local/jakartaTomcat../webapps/servlets-examples/input.html. which simply gets an input string and submits to /servlet/Insert servlet class which is in ../servlets-examples/classes/Insert.class.
    It put the string in DB which works fine. Also I made a package in ...servlet-examples/classes/Service in which I uploaded Core.java and compiled it and got the class files in it as a package.
    In Insert class file I imported Service.*. In Insert class file I put a line like this. Core.putInPool(submittedString) which is a static method.
    When I submit input.html , the string is put in DB, but it is not submitting to the program already running.
    What I want to do is, I want to submit the string to the program that is running in /home/raja/Service/.
    This is the program running in /home/raja/Service.
    public class Core {
         static ThreadPool bc= new ThreadPool(10);
         public static void putString(String someStr) {
              bc.putInPool(someStr);
         public static void main(String args[]) throws InterruptedException {
              BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in) );
              while(true) {
                   System.out.println("\f 1.Insert\n2.option2Enter Ur choice:");
                   try{
                        ch = Integer.parseInt(dataIn.readLine());
                                   String string="";
                        switch(ch) {
                             case 1: System.out.println("\nEnter the String:");
                                  string = dataIn.readLine();
                                  bc.putInPool(string);
                                 .....In Insert.class servlet,
                                    string = req.getParameter("userInputString");
                                    out.println("Submitted");
                        Core.putInPool(string);

  • Calling Exe from Servlet

    I need to call 1 exe from a servlet. I tried giving <FORM ACTION="Path for that Exe">
    But its not working. Can't I call exe or any other file other than .class file ?
    Help me out.

    I need to call 1 exe from a servlet. I tried giving
    <FORM ACTION="Path for that Exe">
    But its not working. Can't I call exe or any other
    file other than .class file ?
    Help me out.Here goes my Code
    import java.io.*;
    import java.util.Hashtable;
    import java.util.Date.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    * Date Servlet
    * This is a simple servlet to demonstrate server-side include
    * It returns a string representation of the current time. And also client IP and Name
    * @author
    * 16 Oct. 2003
    public class PrintDate extends HttpServlet{
         public void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException{
              response.setContentType("text/plain");
              PrintWriter out = response.getWriter();
              //ServletOutputStream out = response.getOutputStream();
              String host = request.getRemoteAddr();
              //out.println("I am printing the host:" + host);
              out.println("<HTML>");
              out.println("<HEAD></HEAD>");
              out.println("<BODY>");
              out.println("<FORM METHOD=get ACTION=/servlet/Kudremukh_pan>");
              out.println("<INPUT TYPE=text SIZE=15>");
              out.println("<INPUT TYPE=submit VALUE=submit>");
              out.println("</FORM></BODY></HTML>");

  • Call classes from another project

    Hi,
    i have a (i hope) simple question.
    Meanwhile i have a lot of custom coding which i uploaded to my J2EE as PAR files from NWDS.
    For several projects i have similar requirements (e.g. read customers information etc.), so I generated a "base" project in nwds and deployed it.
    In NWDS project properties i can set the "Java Build Path" to this project and i am able to call the methods that i wrote in this project. But only in NWDS.
    When i deploy the project to J2EE i get runtime errors that classes are not found, so i think i have to customize sth. in portalapp.xml to set the reference
    I tried several things with "SharingReference" etc. but nothing worked.
    Could anyone tell me the steps i have to do?
    I know i could create a jar file which i link in my project but i want a central project where i can change coding, deploy it again, and all projects automatically use the actual classes.
    Many thanks
    regards
    Alex

    Hi Min,
    i tried this but get errors.
    The project par with the baseclasses has the name "com.xxx.baseclasses.par", the package in the project where the classes are placed is "com.xxx.baseclasses.usermanagement;"
    So i tried it in portalapp.xml of my other project with the following lines
    <application-config>
        <property name="SharingReference" value="usermanagement,com.xxx.baseclasses"/>
        <property name="SharingAccess" value="shared"/>
      </application-config>
    I also tried com.xxx.baseclasses.usermanagement, but no luck. In default trace i get:
    java.lang.NoClassDefFoundError: com.xxx.baseclasses.usermanagement.ZBVUser
    Do i have to set the reference in a different way or do i have to change sth. in my baseclasses project?
    Many thanks
    Regards
    Alex

  • Calling Classes From JSP pages

    I am importing an application specific class in a JSP page and calling it
              (Win NT). It compiles the servlet successfully but cannot appear to find the
              class during execution.
              I have tried placing the class file / jar file containing the class in
              CLASSPATH environment / weblogic JAVAPATH variable / weblogic ServletClasses
              directory .. so far without any luck.
              I would appreciate any suggestions.
              Regards,
              Pradeep
              

    Put it in WEBLOGICCLASSPATH variable. And make sure it is only in
              WEBLOGICCLASSPATH , nowhere else.
              Cheers - Wei
              John Brown <[email protected]> wrote in message
              news:39693f9e$[email protected]..
              > I am importing an application specific class in a JSP page and calling it
              > (Win NT). It compiles the servlet successfully but cannot appear to find
              the
              > class during execution.
              > I have tried placing the class file / jar file containing the class in
              > CLASSPATH environment / weblogic JAVAPATH variable / weblogic
              ServletClasses
              > directory .. so far without any luck.
              > I would appreciate any suggestions.
              >
              > Regards,
              >
              > Pradeep
              >
              >
              >
              

  • Calling SessionBean from Servlet

    Hi ,
    I am using Weblogic11g server .
    In my application I am calling SessionBean (EJB3.0) from my servlet using MappedName#PackageName.RemoteBean Name , its working fine .
    But Can you please tell me if i can use @EJB in servlets for this purpose .
    Thanks in advance

    for now that is server specific. I believe in the EJB 3.1 standard it is specified that you should be able to inject EJBs into servlets, but for now it is not mandatory. If any application server is able to do it, it would be Glassfish.

  • 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
              >
              >
              >
              >
              

  • Call "Class" from MII

    Hi Gurus,
    I am a starter to MII system. I know that we have an option to call ECC R/3 remote enabled function modules and BAPI from MII. My question is, can we call ECC Class / methods?
    Thanks
    Nagarajan

    Thanks for your reply.
    I have an example standard SAP class / method. Class is CL_GUI_FRONTEND_SERVICES and method is GET_IP_ADDRESS. This method is used to get the IP address of the current system.
    Is there a way we call the above method from MII?
    Apart from standard Class/ methods, I have huge number of custom "Z" classes / methods. In order to call from MII, I need to create a wrapper function module with matching import / export and changing parameters. This is the non value added process and future changes in the class / methods involves changes in MII remote enabled function modues.
    Please let me know your thoughts.
    best regards
    Nagarajan

  • 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 URL from servlet

    Hi!
    I am trying to find a solution to this scenario:
    1) A cron job will call a servlet.
    2) Servlet calls a URL on remote server.
    3) Remote server returns an XML document.
    4) Servlet processes/parses the XML document.
    5) Servlet stores XML fields into DB.
    6) Servlet response (entry to log file) indicates status of transaction.
    I'm stuck @ #2. What mechanism can I use to make a call to remote URL? I do not want the returning XML document to display on the client's browser; I want to process it on the back-end.
    Thx!

    http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html

Maybe you are looking for