9 Replies Latest reply on Aug 17, 2004 2:55 AM by 843841

    i need help!

    843841
      i'm pretty new to java so any help is appreciated.

      my group mates are developing an api to connect to a security hardware and i'm in charge of creating the servlet to call the methods. i'd like to know how do i do this using servlet 2.3 and tomcat 4.1. i've been trying out example servlets in books but it seems that my servlets got problems deploying so i need some serious help here. the tomcat servlet examples look more HTML than servlet... = \
        • 1. Re: i need help!
          843841
          Hi

          Could not get whats your exact problem.
          i'm in charge of creating the servlet to call the methods
          So you have an API and you want to call some methods.?
          if yes, import the API, make the class object and call them.
          but it seems that my servlets got problems deploying
          Let us know what problems you are facing in deploying.

          -AP
          • 2. Re: i need help!
            843841
            i always get messed up with the DTD. like where should i put the deployment descriptor and my class file in order to deploy my servlet using tomcat?
            • 3. Re: i need help!
              843841
              i'm using tomcat 4.1.30. i created a folder called "project" in my webapps folder and changed the context path and docbase to "/project" and "project" respectively.

              i placed my web.xml folder in the WEB-INF in "project" and a class file in the "classes" folder in WEB-INF.

              this is my web.xml file
              =====================================================
              <web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4">
              <servlet>
                   <servlet-name>HelloWorld</servlet-name>
                   <servlet-class>HelloWorld</servlet-class>
              </servlet>
              <servlet-mapping>
                   <servlet-name>HelloWorld</servlet-name>
                   <url-pattern>/HelloWorld</url-pattern>
              </servlet-mapping>
              </web-app>
              ======================================================


              and when i start tomcat, this is what i get
              ===============================================================
              Aug 13, 2004 3:27:21 PM org.apache.coyote.http11.Http11Protocol init
              INFO: Initializing Coyote HTTP/1.1 on port 80
              Starting service Tomcat-Standalone
              Apache Tomcat/4.1.30
              Aug 13, 2004 3:27:22 PM org.apache.commons.digester.Digester error
              SEVERE: Parse Error at line 1 column 64: Document root element "web-app", must m
              atch DOCTYPE root "null".
              org.xml.sax.SAXParseException: Document root element "web-app", must match DOCTY
              PE root "null".
              at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Un
              known Source)
              at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
              at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
              at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
              at org.apache.xerces.impl.dtd.XMLDTDValidator.rootElementSpecified(Unkno
              wn Source)
              at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown
              Source)
              at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Sourc
              e)
              at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElemen
              t(Unknown Source)
              at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanR
              ootElementHook(Unknown Source)
              at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
              Dispatcher.dispatch(Unknown Source)
              at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
              known Source)
              at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
              at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
              at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
              at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
              at org.apache.commons.digester.Digester.parse(Digester.java:1548)
              at org.apache.catalina.startup.ContextConfig.applicationConfig(ContextCo
              nfig.java:282)
              at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:63
              9)
              at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
              g.java:243)
              at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
              eSupport.java:166)
              at org.apache.catalina.core.StandardContext.start(StandardContext.java:3
              587)
              at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)

              at org.apache.catalina.core.StandardHost.start(StandardHost.java:754)
              at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)

              at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:363
              )
              at org.apache.catalina.core.StandardService.start(StandardService.java:4
              97)
              at org.apache.catalina.core.StandardServer.start(StandardServer.java:219
              0)
              at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
              at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
              at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
              java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
              sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
              Aug 13, 2004 3:27:22 PM org.apache.commons.digester.Digester error
              SEVERE: Parse Error at line 1 column 64: Document is invalid: no grammar found.
              org.xml.sax.SAXParseException: Document is invalid: no grammar found.
              at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Un
              known Source)
              at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
              at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
              at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
              at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown
              Source)
              at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Sourc
              e)
              at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElemen
              t(Unknown Source)
              at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanR
              ootElementHook(Unknown Source)
              at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
              Dispatcher.dispatch(Unknown Source)
              at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
              known Source)
              at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
              at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
              at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
              at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
              at org.apache.commons.digester.Digester.parse(Digester.java:1548)
              at org.apache.catalina.startup.ContextConfig.applicationConfig(ContextCo
              nfig.java:282)
              at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:63
              9)
              at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
              g.java:243)
              at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
              eSupport.java:166)
              at org.apache.catalina.core.StandardContext.start(StandardContext.java:3
              587)
              at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)

              at org.apache.catalina.core.StandardHost.start(StandardHost.java:754)
              at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)

              at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:363
              )
              at org.apache.catalina.core.StandardService.start(StandardService.java:4
              97)
              at org.apache.catalina.core.StandardServer.start(StandardServer.java:219
              0)
              at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
              at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
              at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
              java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
              sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
              Aug 13, 2004 3:27:23 PM org.apache.struts.util.PropertyMessageResources <init>
              INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=tru
              e
              Aug 13, 2004 3:27:23 PM org.apache.struts.util.PropertyMessageResources <init>
              INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNul
              l=true
              Aug 13, 2004 3:27:24 PM org.apache.struts.util.PropertyMessageResources <init>
              INFO: Initializing, config='org.apache.webapp.admin.ApplicationResources', retur
              nNull=true
              Aug 13, 2004 3:27:26 PM org.apache.coyote.http11.Http11Protocol start
              INFO: Starting Coyote HTTP/1.1 on port 80
              Aug 13, 2004 3:27:26 PM org.apache.jk.common.ChannelSocket init
              INFO: JK2: ajp13 listening on /0.0.0.0:8009
              Aug 13, 2004 3:27:26 PM org.apache.jk.server.JkMain start
              INFO: Jk running ID=0 time=0/40 config=C:\jakarta-tomcat-4.1.30\conf\jk2.proper
              ties
              ==================================================================
              • 4. Re: i need help!
                800345
                The problem doesn't seem to be where you put the web.xml, but how it is formatted.

                post the web.xml you are using.
                • 5. Re: i need help!
                  843841
                  other then the default web.xml in the tomcat "conf" folder, this is my web.xml
                  ============================================================
                  <web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4">

                  <servlet>
                       <servlet-name>HelloWorld</servlet-name>
                       <servlet-class>HelloWorld</servlet-class>
                  </servlet>
                  <servlet-mapping>
                       <servlet-name>HelloWorld</servlet-name>
                       <url-pattern>/HelloWorld</url-pattern>
                  </servlet-mapping>
                  </web-app>
                  ============================================================
                  thx for helping!
                  • 6. Re: i need help!
                    800345
                    Ok, you have to do two things in the web.xml
                    1) declare it as an xml application
                    2) provede the correct format for the xmls:
                    <?xml version="1.0" encoding="ISO-8859-1"?>
                    
                    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
                             version="2.4">
                      <servlet>
                        <servlet-name>HelloWorld</servlet-name>
                        <servlet-class>HelloWorld</servlet-class>
                      </servlet>
                      <servlet-mapping>
                        <servlet-name>HelloWorld</servlet-name>
                        <url-pattern>/HelloWorld</url-pattern>
                      </servlet-mapping>
                    </web-app>
                    • 7. Re: i need help!
                      843841
                      ok i modified my web.xml to be like this,
                      ---------------------------------------------------------------------------------------------------------
                      <?xml version="1.0" encoding="ISO-8859-1"?>

                      <!DOCTYPE web-app
                      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
                      "http://java.sun.com/dtd/web-app_2_3.dtd">

                      <web-app>
                      <display-name>Powermax Project</display-name>
                      <description>
                      Powermax project servlet store
                      </description>

                      <!-- Define servlet-mapped and path-mapped example filters -->

                      <!-- Filter to set character encoding on each request -->

                      <!-- Define filter mappings for the defined filters -->

                      <!-- Define example application events listeners -->
                      <listener>
                      <listener-class>listeners.ContextListener</listener-class>
                      </listener>
                      <listener>
                      <listener-class>listeners.SessionListener</listener-class>
                      </listener>
                      <!-- =========================================================== -->
                           
                      <!-- Define servlets that are in the powermax project -->
                      <servlet>
                           <servlet-name>HelloWorld</servlet-name>
                           <servlet-class>HelloWorld</servlet-class>
                      </servlet>
                      <servlet-mapping>
                           <servlet-name>HelloWorld</servlet-name>
                           <url-pattern>/HelloWorld</url-pattern>
                      </servlet-mapping>
                      <!-- =========================================================== -->

                      </web-app>
                      --------------------------------------------------------------------------------------------------------------------------

                      now when i go into my tomcat manager, i realise that i can't start my "project" folder. why is that?
                      i tried changing my "Context path" in server.xml to "project and "docbase" to "projecf" but it 'doesn't work.
                      • 8. Re: i need help!
                        800345
                        Look at the logs in the /conf directory. What does it give you as a reason?

                        Is there a reason you are using the 2.3 web.xml and not the newer 2.4 I gave you above? (that should not prevent you from starting the webapp, but will play with EL)
                        • 9. Re: i need help!
                          843841
                          i got it running thru trial and error. i'm using 2.3 as i was told that tomcat 5 was still new so tomcat 4.1 was better for project development.
                          ok now i have to figure out how do i call my methods from the api. thanks!