Javax servlet servletexception error instantiating servlet class

I am having a following error when a request is made to my Login servlet...... description The server encountered an internal error () that prevented it from fulfilling this request. exception java...

I am having a following error when a request is made to my Login servlet……

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error instantiating servlet class udit.Login
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:556)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:401)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:267)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:245)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:260)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:619)

root cause

java.lang.NoClassDefFoundError: udit/Login (wrong name: Login)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
java.lang.ClassLoader.defineClass(ClassLoader.java:616)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2778)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1139)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:556)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:401)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:267)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:245)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:260)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:619)

……

PLZZ Suggest me what am i doing wrong
I compiled my servlet sucessfully so problem should not be with coding
I think that some jar files may be required BUT EVEN IF I DO THEN PLZZZ TEMME WHICH ALL JAR FILES ARE REQUIRED FOR SERVLETS AND JDBC TO WORK PROPERLY……. I AM USING TOMCAT (latest)…. I hav set all the classpaths and other environment variables….. PLZZ HELP ME OUT>……

Содержание

  1. javax.servlet.ServletException: Error instantiating servlet class
  2. Error instantiating servlet class
  3. javax.servlet.ServletException: Error instantiating servlet class JavaMailS
  4. Error instantiating the servlet class

javax.servlet.ServletException: Error instantiating servlet class

I am having a following error when a request is made to my Login servlet.

description The server encountered an internal error () that prevented it from fulfilling this request.

javax.servlet.ServletException: Error instantiating servlet class udit.Login
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:556)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:401)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:267)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:245)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:260)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:619)

java.lang.NoClassDefFoundError: udit/Login (wrong name: Login)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
java.lang.ClassLoader.defineClass(ClassLoader.java:616)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2778)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1139)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:556)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:401)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:267)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:245)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:260)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:619)

PLZZ Suggest me what am i doing wrong
I compiled my servlet sucessfully so problem should not be with coding
I think that some jar files may be required BUT EVEN IF I DO THEN PLZZZ TEMME WHICH ALL JAR FILES ARE REQUIRED FOR SERVLETS AND JDBC TO WORK PROPERLY. I AM USING TOMCAT (latest). I hav set all the classpaths and other environment variables. PLZZ HELP ME OUT>.

Источник

Error instantiating servlet class

  • Please help me I just can’t find what exactly i’m missing in my code. it’s been three days i’m stuck on it. Please look into it. Also when I first wrote this program it was working and later I was facing issue with get method. i.e post was working but get was not working. Now nothing is working.

    HTTP Status 500 – Internal Server Error
    Type Exception Report

    Message Error instantiating servlet class [com.emandi.loginServlet]

    Description The server encountered an unexpected condition that prevented it from fulfilling the request.

    Exception
    javax.servlet.ServletException: Error instantiating servlet class [com.emandi.loginServlet]

    Root Cause
    java.lang.ClassNotFoundException: com.emandi.loginServlet

  • Dave Tolls wrote: How are you compiling and deploying this?
    Because that error implies the servlet is not being deployed as part of your app.

    Actually, that message can come when there’s an exception thrown by construction code.

    I would like to see a stack trace.

    Blitzlügen — Lies or information broadcast, but when called out the broadcaster does little or nothing is done to correct them, thus allowing those who wish to believe to accept them as truth.

    Lügensturm — A barrage of Blitzlügen fired in such quick succession that it is essentially impossible to correct them all.

    Источник

    javax.servlet.ServletException: Error instantiating servlet class JavaMailS

    I’m using javamail-1.3.1, Tomcat 4.0 with j2sdk1.4.2_04.

    With a main class, I was able to mail successfully, but trying to use the class from Servlet, gives me all kinds of problems with Sealed Jar files.

    Now I’m trying to implement the example Servlet. The Servlet code is below, I only cleaned the deprecated functions from the example and comented the //import javax.activation.*; line.

    I get the following error:
    javax.servlet.ServletException: Error instantiating servlet class JavaMailServlet
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:912)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:668)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:653)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:404)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
    at Validar.vValidar(Validar.java:150)
    at Validar.service(Validar.java:24)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:404)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
    at Entrada.service(Entrada.java:95)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
    at java.lang.Thread.run(Unknown Source)

    /*
    * @(#)JavaMailServlet.java 1.5 01/05/23
    *
    * Copyright 1998, 1999 Sun Microsystems, Inc. All Rights Reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * — Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * — Redistribution in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * Neither the name of Sun Microsystems, Inc. or the names of contributors
    * may be used to endorse or promote products derived from this software
    * without specific prior written permission.
    *
    * This software is provided «AS IS,» without a warranty of any kind. ALL
    * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
    * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
    * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND
    * ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES
    * SUFFERED BY LICENSEE AS A RESULT OF OR RELATING TO USE, MODIFICATION
    * OR DISTRIBUTION OF THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
    * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
    * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
    * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
    * ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS
    * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    *
    * You acknowledge that Software is not designed, licensed or intended
    * for use in the design, construction, operation or maintenance of any
    * nuclear facility.
    */

    import java.io.*;
    import java.util.*;
    import java.text.*;

    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    //import javax.activation.*;

    /**
    * This is a servlet that demonstrates the use of JavaMail APIs
    * in a 3-tier application. It allows the user to login to an
    * IMAP store, list all the messages in the INBOX folder, view
    * selected messages, compose and send a message, and logout.
    *

    * Please note: This is NOT an example of how to write servlets!
    * This is simply to show that JavaMail can be used in a servlet.
    *

    * For more information on this servlet, see the
    * JavaMailServlet.README.txt file.
    *

    * For more information on servlets, see
    * * http://java.sun.com/products/java-server/servlets/index.html
    *
    * @author Max Spivak
    */
    public class JavaMailServlet extends HttpServlet
    <
    String protocol = «imap»;
    String mbox = «INBOX»;

    /**
    * This method handles the «POST» submission from two forms: the
    * login form and the message compose form. The login form has the
    * following parameters: hostname , username ,
    * and password . The send parameter denotes
    * that the method is processing the compose form submission.
    */
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException <

    // get the session
    HttpSession ssn = req.getSession(true);

    String send = req.getParameter(«send»);
    String host = req.getParameter(«hostname»);
    String user = req.getParameter(«username»);
    String passwd = req.getParameter(«password»);
    URLName url = new URLName(protocol, host, -1, mbox, user, passwd);

    ServletOutputStream out = res.getOutputStream();
    res.setContentType(«text/html»);
    out.println(» «);

    if (send != null) <
    // process message sending
    send(req, res, out, ssn);

    Источник

    Error instantiating the servlet class

  • Hello,
    I boque on a simple servlet that I can not invoke, with appal of a JSP page. I have tried everything :
    — parameters of the web.xml
    — JSP

    here is my code:

  • Philippe Ponceblanc wrote: in /src/webcart/WebCartServlet

  • Philippe Ponceblanc wrote: no, in the package webcart

    Well, «src» is clearly a source directory, is it not?

    Regardless, the class file needs to be inside WEB-INF/classes/webcart; is that where it is? Or is it in a jar file that contains all your classes? If so, that would go into WEB-INF/lib

  • Philippe Ponceblanc wrote: eclipse == /src/webcart/WebCartServlet.class

    That’s not Tomcat.
    That’s your IDE.

    How are you deploying your web application to Tomcat?
    Also, what Tomcat is it? Is it embedded as part of Eclipse or standalone?

  • Philippe Ponceblanc wrote: eclipse == /src/webcart/WebCartServlet.class

    That’s not Tomcat.
    That’s your IDE.

    How are you deploying your web application to Tomcat?
    Also, what Tomcat is it? Is it embedded as part of Eclipse or standalone?

    These are the important questions. You need to understand what a WAR is and how it is used.

    Blitzlügen — Lies or information broadcast, but when called out the broadcaster does little or nothing is done to correct them, thus allowing those who wish to believe to accept them as truth.

    Lügensturm — A barrage of Blitzlügen fired in such quick succession that it is essentially impossible to correct them all.

  • I’m using tomcat 8.5, I generated a project as follows:

    WEB-INF / classes / WebCart / WebCartServlet.java

    likewise I added the jsp and the web.xml

    now I have a 404 error!

  • WEB-INF / classes / WebCart / WebCartServlet.java

    1) The package name is «webcart», not «WebCart».

    2) That’s where WebCartServlet.class should be, not WebCartServlet.java.

  • project -Web-INF/classes
    — webcart
    — Cart.java
    — WebCartServlet.java
    — Meta-INF
    — context.xml
    — WEB-INF
    — classes
    — webcart
    — Cart.java
    -WebCartServelet.java
    — panier.jsp
    — web.xml

  • Tim Moores wrote: A source file does no good in WEB-INF/classes — that’s were the class file needs to be.

    I follow a certification EE java, but it is this exercise that is imposed.
    It starts in this form previously written.
    how can i edit my .class files instead of .java

  • Tim Moores wrote: No editing — you compile the .java file which results in a .class file. The IDE does that for you, but it’s possible it doesn’t put the class files where they need to be. But after compilation they should be somewhere in the project folder, provided there were no errors.

    I have no more error after compiling with Tomcat, I can not find the files.class!
    Should you add a «target» directory for the tomcat?
    to generate .class files in the «target» directory?

  • No, you must build a WAR and deploy the WAR to Tomcat.

    You’re trying to let your IDE (Eclipse) do all the thinking for you. If you understood how Java webapps and webapp servers work, you could make everything work without using Eclipse at all.

    In fact, you have to do so in the Real World. No sane IT shop is going to run an IDE on a production server machine.

    Blitzlügen — Lies or information broadcast, but when called out the broadcaster does little or nothing is done to correct them, thus allowing those who wish to believe to accept them as truth.

    Lügensturm — A barrage of Blitzlügen fired in such quick succession that it is essentially impossible to correct them all.

  • Hello,
    I installed my project in the webapps directory of tomcat,
    I have trouble understanding between the compile command and the deployment in tomcat my directory is «/opt/apache-tomcat-8.5.34/webapps/fun/exo103/».
    at the moment my servlet does not display a JSp page via the doGet method, but I have a 404 error!

    how to differentiate the command >> javac myservlet
    how to deploy in tomcat >> catalina

  • First, you don’t install the «project» into Tomcat. As I said, Eclipse is not going to be around on a production Tomcat server. You only install the WAR into Tomcat. Tomcat doesn’t care about and cannot use Eclipse projects. Or IntelliJ projects. Or Netbeans projects. et cetera.

    The WAR can be in the form of a WAR file or an unzipped («exploded») WAR. By default, Tomcat will take WAR files found in the Tomcat webapps directory and explode them into directories having the same base name as the WAR file’s name. So mywebapp.war explodes to directory «mywebapp» and the webapp’s URL context name would be «/mywebapp».

    You cannot deploy WARs into sub-directories of the webapps directory. Only into the webapps directory itself. Tomcat would treat a file named TOMCAT_HOME/webapps/fun/exo103/myjsp.jsp as being deployed in the webapp whose context name was «fun» and the JSP would be accessible via the URL http://localhost:8080/fun/exo101/myjsp.jsp». It would not see that as a webapp named «exo101» — exo101 would simply be seen as a subdirectory of the «fun» webapp.

    Blitzlügen — Lies or information broadcast, but when called out the broadcaster does little or nothing is done to correct them, thus allowing those who wish to believe to accept them as truth.

    Lügensturm — A barrage of Blitzlügen fired in such quick succession that it is essentially impossible to correct them all.

    Источник


    Recommended Answers

    Do you have a package declaration at the top of your servlet? Does the «classes» directory contain the file «getname.class» placed in the folder hierarchy com/mmfsl/web ?

    Jump to Post

    There is something definitely wrong with your setup because I’m able to run the same thing locally without any problems.

    Is your Tomcat installation clean or have you made any modifications to it? Are there any other apps successfully running on the same Tomcat installation? What is the entire …

    Jump to Post

    All 7 Replies

    Member Avatar


    ~s.o.s~

    2,560



    Failure as a human



    Team Colleague



    Featured Poster


    12 Years Ago

    Do you have a package declaration at the top of your servlet? Does the «classes» directory contain the file «getname.class» placed in the folder hierarchy com/mmfsl/web ?

    Member Avatar

    12 Years Ago

    Yes you are right. I have done the same way
    Inside this folder are the two classes
    «C:Program FilesApache Software FoundationTomcat 7.0webappstutWEB-INFclassescommmfslweb«

    <b>1) getname.class </b>

    package com.mmfsl.web;
    import java.io.*;
    import java.text.*; 
    import java.util.*; 
    import javax.servlet.*; 
    import javax.servlet.http.*;
     
    public class getname extends HttpServlet {
     
    	public void init(ServletConfig config) throws ServletException {	
    		super.init(config);
    	}
     
    	public void destroy() {
     
    	}
     
    	public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
    		String name = null;
    		PrintWriter out = response.getWriter();
    		if(request.getParameter("txtname") != null) {
    			name = request.getParameter("txtname");
    		}
                    else {
                           name = "";
                    }
      	        out.println("You have successfully made Ajax Call:" + name);
    	}
    }

    <b>2) gettime.class .</b>

    package com.mmfsl.web;
    import java.io.*; 
    import java.text.*; 
    import java.util.*; 
    import javax.servlet.*; 
    import javax.servlet.http.*;
     
    public class gettime extends HttpServlet {
     
    	public void init(ServletConfig config) throws ServletException {	
    		super.init(config);
    	}
     
    	public void destroy() {
     
    	}
     
    	public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
    		PrintWriter out = response.getWriter();
    		Date df = new Date();
    		out.println(df.getTime());
    	}
     
    	public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
    		doPost(request,response);
    	}
    }

    Member Avatar


    ~s.o.s~

    2,560



    Failure as a human



    Team Colleague



    Featured Poster


    12 Years Ago

    There is something definitely wrong with your setup because I’m able to run the same thing locally without any problems.

    Is your Tomcat installation clean or have you made any modifications to it? Are there any other apps successfully running on the same Tomcat installation? What is the entire directory structure of the «tut» directory in the «webapps» folder? How do you start Tomcat?

    Member Avatar

    12 Years Ago

    You got it…!
    I have another development setup of Tomcat which is of version (Apache Tomcat/6.0.20)
    and it worked well. Below is our stable development server

    DEV

    Server Information
    Tomcat Version 	JVM Version 	JVM Vendor 	OS Name 	OS Version 	OS Architecture
    Apache Tomcat/6.0.20 	1.7.0-ea-b58 	Sun Microsystems Inc. 	Windows 2003 	5.2 	x86

    So far, I was trying in (Apache Tomcat/7.0.2) with my local setup of version
    LOCAL DEV

    Server Information
    Tomcat Version 	JVM Version 	JVM Vendor 	OS Name 	OS Version 	OS Architecture
    Apache Tomcat/7.0.2 	1.6.0_22-b04 	Sun Microsystems Inc. 	Windows XP 	5.1 	x86

    I think the JVM Version in both the servers are different.
    Is that the reason behind this issue……?

    In my LOCAL DEV setup few other applications are running perfectly…
    I did not modified/tweaked any of the settings in my LOCAL DEV
    Directory Structure
    C:Program FilesApache Software FoundationTomcat 7.0webappstut

    Tomcat will run as a service also when windows starts up

    tut_setup.JPG 24.57 KB

    Member Avatar


    ~s.o.s~

    2,560



    Failure as a human



    Team Colleague



    Featured Poster


    12 Years Ago

    That’s strange. Do you have multiple JVM’s installed on your local machine? Which Java version are you using to compile your project i.e. what’s your JAVA_HOME and PATH set to?

    Even if it were related to different JVM versions, I don’t think the error would be NoClassDefFound. Are you sure you have the entire stack trace there? Can you empty the log folder on your local setup, restart the server and paste the *entire* stack trace here?

    Also, space in directory path causes real strange issues so can you relocate your local Tomcat directory to something like «c:/tomcat-7» and then try again?

    Member Avatar

    12 Years Ago

    JAVA_HOME is C:Program FilesJavajdk1.6.0_22bin
    CLASSPATH is C:Program FilesApache Software FoundationTomcat 7.0libservlet-api.jar

    I stopped and started the Tomcat Service completely.

    I’d re Written WEB.XML file over again and again reloaded the application.
    Now it is working.

    It’s very strange for me too…
    Anyways thanks a lot for your suggestions.
    I’ll ensure the tomcat installation directory does not contain spaces also.
    So I’ll have to reinstall. I’ll do that. Thanks

    Member Avatar

    12 Years Ago

    I remember reading somewhere ONLINE that restarting the services will free up the resources and memory leaks. If thats true it worked for me…
    I’ll close this thread.


    Reply to this topic

    Be a part of the DaniWeb community

    We’re a friendly, industry-focused community of developers, IT pros, digital marketers,
    and technology enthusiasts meeting, networking, learning, and sharing knowledge.

    #java #xml #servlets

    Вопрос:

    То, что я пытаюсь сделать, — это создать простое веб-приложение, в котором учитель может записывать оценки учащихся из файлов Excel в базу данных

    Я пытался очистить и перестроить проект, очистить рабочий путь tomcat, но, похоже, ничего не получилось

    Вот мой код сервлета, который вызывает ошибку

     @WebServlet(name = "NhapFileExcelServlet", urlPatterns = {"/nhapFileExcelServlet"})
    public class NhapFileExcelServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, ParseException {
        Part filePart = request.getPart("excel");
        InputStream inputStream = filePart.getInputStream();
        String fileName = filePart.getSubmittedFileName();
        if(fileName.endsWith(".xls") || fileName.endsWith(".xlsx")) {
            // Lấy file excel upload về server
            String uploadFileDirectory = "UsersthanhhieuDesktoptest"   fileName;
            File fileToSave = new File(uploadFileDirectory);
            Files.copy(inputStream, fileToSave.toPath(), StandardCopyOption.REPLACE_EXISTING);
            request.setAttribute("isValid", Boolean.TRUE);
            ExcelController excelController = new ExcelController(uploadFileDirectory);
            excelController.readExcel();
            ArrayList<SinhVien> dsSinhVien = excelController.getDsSinhVien();
            ArrayList<Diem> dsDiem = excelController.getDsDiem();
            request.setAttribute("dsSinhVien", dsSinhVien);
            request.setAttribute("dsDiem", dsDiem);
        }
        else {
            request.setAttribute("isValid", Boolean.FALSE);
        }
        
        //Chuyển request và response sang GDdiem.jsp
        String url = "/GDdiem.jsp";
        RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
        System.out.println("Ma lop gui sang servlet: "   request.getParameter("maLop"));
        dispatcher.forward(request, response);
    }
    
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the   sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, FileNotFoundException {
        try {
            processRequest(request, response);
        } catch (ParseException ex) {
            Logger.getLogger(NhapFileExcelServlet.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, FileNotFoundException {
        try {
            processRequest(request, response);
        } catch (ParseException ex) {
            Logger.getLogger(NhapFileExcelServlet.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
    }
     

    Та часть, которая будет вызывать сервлет

     <div style = "margin: auto">
                <form action="nhapFileExcelServlet" method = "post" enctype="multipart/form-data">
                    <input type="hidden" id="lopID" name="maLop" value= <%= maLop %> />
                    <input type="hidden" id="monID" name="maMon" value= <%= maMon %> />
                    <label for="fileID">Chọn file Excel danh sách điểm:</label>
                    <input type="file" id="fileID" accept=".xls, .xlsx" name="excel"><br>
                    <button type="submit">Nhập</button>
                </form>
            </div>
     

    Мой xml-файл

     <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
        <servlet>
            <servlet-name>NhapFileExcelServlet</servlet-name>
            <servlet-class>servlet.NhapFileExcelServlet</servlet-class>
            <multipart-config/>
        </servlet>
        <servlet>
            <servlet-name>TinhDiemServlet</servlet-name>
            <servlet-class>servlet.TinhDiemServlet</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>LuuDiemLopServlet</servlet-name>
            <servlet-class>servlet.LuuDiemLopServlet</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>NhapFileExcelServlet</servlet-name>
            <url-pattern>/nhapFileExcelServlet</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>TinhDiemServlet</servlet-name>
            <url-pattern>/tinhDiemServlet</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>LuuDiemLopServlet</servlet-name>
            <url-pattern>/luuDiemLopServlet</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
        <jsp-config>
            <jsp-property-group>
                <url-pattern>*.jsp</url-pattern>
                <page-encoding>UTF-8</page-encoding>
            </jsp-property-group>
        </jsp-config>
    </web-app>
     

    И структура моего проекта

    Это трассировка стека

     jakarta.servlet.ServletException: Error instantiating servlet class [servlet.NhapFileExcelServlet]
        org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:353)
        org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
        org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:870)
        org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1696)
        org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        java.base/java.lang.Thread.run(Thread.java:835)
    cause mère
    
    java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
        java.base/java.lang.ClassLoader.defineClass1(Native Method)
        java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
        java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
        org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2470)
        org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:866)
        org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1370)
        org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1224)
        org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:353)
        org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
        org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:870)
        org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1696)
        org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        java.base/java.lang.Thread.run(Thread.java:835)
    cause mère
    
    java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet
        org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1401)
        org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1224)
        java.base/java.lang.ClassLoader.defineClass1(Native Method)
        java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
        java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
        org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2470)
        org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:866)
        org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1370)
        org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1224)
        org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:353)
        org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
        org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:870)
        org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1696)
        org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        java.base/java.lang.Thread.run(Thread.java:835)
     

    Любой совет приветствуется

    Комментарии:

    1. Приложение пытается использовать класс javax.servlet.http. HttpServlet, но он не может его найти. Этот класс можно найти в servlet-api-x.x.jar. Попробуйте добавить эту банку в свой путь к классу.

    2. Я не знаю, правильно ли я это сделал, но я добавил это в зависимости от своего проекта и все еще не работает

    Ответ №1:

    NVM У меня все получилось

    Оказывается, мне нужно не только импортировать файлы jar, но и указать зависимость в pom.xml потому что IDE не делает это автоматически

    Комментарии:

    1. да, это подразумевается, если вы используете инструменты сборки maven или gradle.

    Здравствуйте еще раз, выскочило исключение показанное ниже

    В класспатч добюавил библиотечку j2ee.jar но все равно ругается, в web.xml все нормально
    подскажите если не сложно в чем может быть причина такого рода исключения, а то в гугле кроме того что javax/ejb/EntityBean не видит jvm не нашел, все советуют добавить в класспатч, но jar уже добавлен но все равно выскакивает,

    web.xml правильный, посмотрите:

    XML
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!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 id="WebApp_ID">
        <display-name>Net</display-name>
        
        <servlet>
            <servlet-name>StudentServlet</servlet-name>
            <display-name>StudentServlet</display-name>
            <description></description>
            <servlet-class>myclasses.StudentServlet</servlet-class>
        </servlet>
     
        <servlet-mapping>
            <servlet-name>StudentServlet</servlet-name>
            <url-pattern>/StudentServlet</url-pattern>
        </servlet-mapping>
        <welcome-file-list>
            <welcome-file>index.html</welcome-file>
            <welcome-file>index.htm</welcome-file>
            <welcome-file>index.jsp</welcome-file>
            <welcome-file>default.html</welcome-file>
            <welcome-file>default.htm</welcome-file>
            <welcome-file>default.jsp</welcome-file>
            <welcome-file>student.jsp</welcome-file>
        </welcome-file-list>
        <resource-ref>
         <res-ref-name>jdbc/myoracle</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
           <res-auth>Container</res-auth>
         </resource-ref>
    </web-app>

    Java
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    
    HTTP Status 500 - 
     
    --------------------------------------------------------------------------------
     
    type Exception report
     
    message 
     
    description The server encountered an internal error () that prevented it from fulfilling this request.
     
    exception 
     
    javax.servlet.ServletException: Error instantiating servlet class myclasses.StudentServlet
        org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
        org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
        org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
        org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
        java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)
     
     
    root cause 
     
    java.lang.NoClassDefFoundError: javax/ejb/EntityBean
        java.lang.ClassLoader.defineClass1(Native Method)
        java.lang.ClassLoader.defineClassCond(Unknown Source)
        java.lang.ClassLoader.defineClass(Unknown Source)
        java.security.SecureClassLoader.defineClass(Unknown Source)
        org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2823)
        org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1160)
        org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1655)
        org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
        java.lang.Class.getDeclaredFields0(Native Method)
        java.lang.Class.privateGetDeclaredFields(Unknown Source)
        java.lang.Class.getDeclaredFields(Unknown Source)
        org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
        org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
        org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
        org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
        java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)
     
     
    root cause 
     
    java.lang.ClassNotFoundException: javax.ejb.EntityBean
        org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
        org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
        java.lang.ClassLoader.defineClass1(Native Method)
        java.lang.ClassLoader.defineClassCond(Unknown Source)
        java.lang.ClassLoader.defineClass(Unknown Source)
        java.security.SecureClassLoader.defineClass(Unknown Source)
        org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2823)
        org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1160)
        org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1655)
        org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
        java.lang.Class.getDeclaredFields0(Native Method)
        java.lang.Class.privateGetDeclaredFields(Unknown Source)
        java.lang.Class.getDeclaredFields(Unknown Source)
        org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
        org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
        org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
        org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
        java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)
     
     
    note The full stack trace of the root cause is available in the Apache Tomcat/7.0.23 logs.
     
     
    --------------------------------------------------------------------------------
     
    Apache Tomcat/7.0.23

    Добавлено через 2 минуты
    Это исключение произошло после того как я попытался вызвать один из методов класс который объявлен так: public class StudentEJB implements EntityBean

    естесственно я создал экземпляр класса StudentEJB и вызвал его метод, в итоге исключение

    __________________
    Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь

    When following the Getting Started guide for deploying locally from Eclipse IDE (https://help.hana.ondemand.com/help/frameset.htm?0f16c9db4a9c407abb1b4987c0afe714.html) I got that error after choosing >> SAP > Java Web Tomcat 7 Server as server type in step 3 and Choose Finish in step 4.

    First there were 2 messages from Windows Firewall which were accepted.

    Other details that might be neede for problem determination:

    In the upper frame in the middle shows a windows with these infos:

    Apache Tomcat/7.0.53 — Error report

    HTTP Status 500 — Error instantiating servlet class java.HelloWorldServlet

    type: Exception report

    message: Error instantiating servlet class java.HelloWorldServlet

    description: The server encountered an internal error that preventet it from fulfilling ths request.

    exception

    javax.servlet.ServletException: Error instantiating servlet class java.HelloWorldServlet

    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)

    com.sap.security.auth.service.webcontainer.internal.Authenticator.invoke(Authenticator.java:197)

    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)

    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)

    com.sap.js.statistics.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:25)

    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)

    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)

    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)

    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)

    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

    java.lang.Thread.run(Thread.java:812)

    root cause

    java.lang.ClassNotFoundException: java.HelloWorldServlet

    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)

    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)

    com.sap.security.auth.service.webcontainer.internal.Authenticator.invoke(Authenticator.java:197)

    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)

    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)

    com.sap.js.statistics.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:25)

    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)

    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)

    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)

    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)

    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

    java.lang.Thread.run(Thread.java:812)

    In the lower frame at the Console register is shown:

    log4j:WARN No appenders could be found for logger (com.sap.ecm.gateway.mongodb.connection.EcmConfiguration).

    log4j:WARN Please initialize the log4j system properly.

    Jul 26, 2014 1:48:19 PM org.apache.catalina.core.StandardWrapperValve invoke

    Schwerwiegend: Allocate exception for servlet java.HelloWorldServlet

    java.lang.ClassNotFoundException: java.HelloWorldServlet

    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)

    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)

    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511)

    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139)

    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1148)

    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:864)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)

    at com.sap.security.auth.service.webcontainer.internal.Authenticator.invoke(Authenticator.java:197)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)

    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)

    at com.sap.js.statistics.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:25)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)

    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)

    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)

    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

    at java.lang.Thread.run(Thread.java:812)

    How please may I overcome this problem?

    Я пишу веб-приложение и развертываю его в веб-контейнере apache tomcat. Я следую простому учебнику из http://cse.csusb.edu/turner/java_web_programming/servlets/

    а затем получите эту ошибку. Я вставляю фрагменты и web.xml, website.xml и мои файлы кода соответственно.

    Состав:

    Изображение 198980

    web.xml:

    <?xml version="1.0"?>
    <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>home</servlet-name>
          <servlet-class>website.web.HomeServlet</servlet-class>
       </servlet>
       <servlet-mapping>
          <servlet-name>home</servlet-name>
          <url-pattern>/home</url-pattern>
       </servlet-mapping>
    </web-app>
    

    HomeServlet.java

    package website.web;

    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    public class HomeServlet extends HttpServlet {
    
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
                   throws ServletException, IOException {
                      PrintWriter writer = resp.getWriter();
                      writer.println("<h1>Hello, World!</h1>");
                   }        
    }
    

    Ошибка:

    HTTP Status 500 - Error instantiating servlet class website.web.HomeServlet
    
    type Exception report
    
    message Error instantiating servlet class website.web.HomeServlet
    
    description The server encountered an internal error that prevented it from fulfilling this request.
    
    exception
    
    javax.servlet.ServletException: Error instantiating servlet class website.web.HomeServlet
        org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
        org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
        org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
        org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1517)
        org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1474)
        java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        java.lang.Thread.run(Thread.java:745)
    root cause
    
    java.lang.ClassNotFoundException: website.web.HomeServlet
        org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
        org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
        org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
        org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
        org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
        org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1517)
        org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1474)
        java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        java.lang.Thread.run(Thread.java:745)
    

    Понравилась статья? Поделить с друзьями:
  • Javax servlet error message
  • Javax persistence rollbackexception error while committing the transaction
  • Javax persistence persistenceexception error attempting to apply attributeconverter
  • Javascript обработка ошибок
  • Javascript как изменить цвет текста