Servlet classes folder
hello everyone
im new in servlet, my question is which folder should i dump my servlet file in tomcat-4.0.1
and how can i invoke this servlet from my html files.my servlet compile good but i dont know which folder should i put this file
thankz
If your servlet is in package "yourpackage", place the class file in
.../WEB-INF/classes/yourpackage/YourServlet
where WEB-INF is under your app's document root.
To invoke this servlet from HTML, code
href="servlet/yourpackage.YourServlet"
or
ACTION="servlet/yourpackage.YourServlet"You could also use a servlet mapping in web.xml if you wish to hide the full name.
For more info, see http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html
Similar Messages
-
Access servlets from subdirectory of classes folder
Hi,
This is my directory structure.
Tomcat home dir>webapps\lessons\WEB-INF \classes\examples\HelloClientServlet.class
and here is my web.xml
<servlet>
<servlet-name>HelloClientServlet</servlet-name>
<servlet-class>examples.HelloClientServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloClientServlet</servlet-name>
<url-pattern>/servlet/examples.HelloClientServlet</url-pattern>
</servlet-mapping>
Now I run run Tomcat and try to access the URL
http://localhost:8083/lessons/servlet/examples.HelloClientServlet
It gives this ERROR:
javax.servlet.ServletException: Error allocating a servlet instance
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:534)
root cause
java.lang.NoClassDefFoundError: examples/HelloClientServlet (wrong name: HelloClientServlet)
java.lang.ClassLoader.defineClass0(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:539)
Now here is the problem. I tried putting HelloClientServlet.class in classes directory and made appropriate changes to web.xml and it works.
But not in the subdirectory classes. I find it very strange. I feel there is no problem with my web.xml file. Am I am missing some configuration here.
Please give you inputs.
Thanks,
Tick_TickWhen you put the HelloClientServlet class in the examples folder and reference it using examples.HelloClientServlet then the class needs to be compiled in the examples package.
Check out the Java tutorial on packages:
http://java.sun.com/docs/books/tutorial/java/interpack/index.html -
How can i make a servlet (class) temporarily unavailable, except for ADMIN
Hello All!
I am rather new to the programming field and have already completed a web-project in Java only with Servlets. (no jsp). I have a login procedure, means I have a user management for users and admins. If an admin is logged in, he/she should be able to deactivate the servlet with a mouse-click as long he activates it again with the same. if the servlet is deactivated, other users/admins trying to access the servlet should get a "servlet is currently unavailable" message. but the admin, who is logged in, still should be able to work with the servlet! how can i realise that?
in other words, by clicking that particular button, the servlet should be made "non-multi-thread" and other way round by activating it.
any ideas??? how can the standard "servlet currently unavailable" page be displayed? I have tomcat 4 on a linux machine! i'd be really grateful if someone oculd help me.
another question i have is, how to define a "pseudo" link address to the servlet. now, the servlet can only be accessed by typing like this: http://servername.xy.com:8080/ProjectName/servlet/ServletName (because I have activated the servlet mapping in the server.xml/web.xml with /servlet/*)
but I want a link like this: http://servername.xy.com:8080/shortname
How can I do this in an easy way?? I have treid to create a web.xml in der WEB-INF folder of the servlet with following content, but it is not working:
<?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>
<servlet>
<servlet-name>
shortname
</servlet-name>
<servlet-class>
ClassName
</servlet-class>
</servlet>
</web-app>
Thanks a lot in advance for your kind help,
lisaOk,
You'll need to find a tutorial on servlet filters. Its not that hard a concept.
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Servlets8.html#wp64572
Filters need to be configured in the web.xml.
Basically they are a buffer between a request and your servlet.
Any requests for the servlet, go through the filter first. It lets you do some processing before/after the servlet gets called. Its a good way of putting in some generic code that need to be run for many servlets - security checks are often implemented in this fashion.
This should give you an idea of the sort of thing you need. I haven't really written one before, so I copied this out of the tutorial and did some basic framework for it....
public final class TestFilter implements Filter {
private FilterConfig filterConfig = null;
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
public void destroy() {
this.filterConfig = null;
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
// if you want to get the session will need to cast request to an HttpServletRequest
Session session = request.getSession();
String requestURL = request.getRequestURL();
// check if this URL is for a servlet that is disabled for this user
// somehow you have to keep track of this ... maybe in the servletContext ?
User user = (User) session.getAttribute("user")
boolean disabled = checkDisabled(requestURL, user);
// if its not disabled, go ahead
if (!disabled)
chain.doFilter(request, response);
else{
// send the servlet off somewhere else - requestDispatcher maybe?
} -
Can anybody tell me what is the exact path to put the servlet class file in
tomcat 4. I was reading a book called more servelet by Marty Hall and its metioned there that i can put them in install_dir/webapps/ROOT/WEB-INF/classes but when i browse to WEB-INF folder there is no folder named classes there.
Please help.firsly i installed jdk 1.3 on my computer. Then i installed tomcat 4. Then i changed port 8080 in server.xml to 80. Then i set the JAVA_HOME path to point to jdk1.3 folder. Then i setup the class path to D:\Documents and Settings\Ashi\Desktop\tomcat\apache-tomcat-4.1.34\apache-tomcat-4.1.34\common\lib\servlet.jar
Then i downloaded a source file named HelloServlet.java from author's website and compiled it. It compiled successfully. I copied the HelloServlet.class file to the classes directory that you asked me to create. Then i opened my browser and typed http://localhost/servlet/HelloServlet and getting error HTTP Status 404 -
Where to store the servlet class files ?
If, I store the class files for servlets under WEB-INF/classes folder,
i get file not found exception while using WL 6.1 sp2. But, if i store
the class file under DefaultWebApp folder, it works fine.
Any help about where to store the class files for servlets would be
great help.
Thanks.
hiren
Copy Servlet in DefaultWebApp/Web-Inf/classes directory.
Configure Servlet in web.xml deployment descriptor.
<servlet>
<servlet-name></servlet-name>
<servlet-class></servlet-class>
</servlet>
<servlet>
<servlet-name></servlet-name>
<servlet-class></servlet-class>
</servlet>
<servlet-mapping>
<servlet-name></servlet-name>
<url-pattern></url-pattern>
</servlet-mapping>
hiren dossani wrote:
> If, I store the class files for servlets under WEB-INF/classes folder,
> i get file not found exception while using WL 6.1 sp2. But, if i store
> the class file under DefaultWebApp folder, it works fine.
> Any help about where to store the class files for servlets would be
> great help.
>
> Thanks.
>
> --
> hiren
-
Where to store the servlet classes
can anyone tell me where to store the servlet classes(inside a package)in oracle9iAS used with oracle8i database ?
Also how to deploy an ejb in oracle9iAS. should we have to use oracle8i deployment guide or any other procedure??
thanks in advanceCopy Servlet in DefaultWebApp/Web-Inf/classes directory.
Configure Servlet in web.xml deployment descriptor.
<servlet>
<servlet-name></servlet-name>
<servlet-class></servlet-class>
</servlet>
<servlet>
<servlet-name></servlet-name>
<servlet-class></servlet-class>
</servlet>
<servlet-mapping>
<servlet-name></servlet-name>
<url-pattern></url-pattern>
</servlet-mapping>
hiren dossani wrote:
> If, I store the class files for servlets under WEB-INF/classes folder,
> i get file not found exception while using WL 6.1 sp2. But, if i store
> the class file under DefaultWebApp folder, it works fine.
> Any help about where to store the class files for servlets would be
> great help.
>
> Thanks.
>
> --
> hiren
-
Wrapper cannot find servlet class error
Hi all!
I'm receiving a mysterious error when I try to run my web ap. "Wrapper cannot find servlet class com.ruffalocody.report.ReportServlet or a class it depends on"
I'm running it on JBoss 3.2.7, and I have another web ap, made almost identical to this one which does not display the same error/exception.
If anyone could give me advice on what I should do to fix this, I'd very much appreciate it. :)
Full exception message:
javax.servlet.ServletException: Wrapper cannot find servlet class com.ruffalocody.report.ReportServlet or a class it depends on
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66)
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:162)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:535)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:534)
root cause
java.lang.ClassNotFoundException: com.ruffalocody.report.ReportServlet
java.net.URLClassLoader$1.run(URLClassLoader.java:199)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:187)
java.lang.ClassLoader.loadClass(ClassLoader.java:289)
java.lang.ClassLoader.loadClass(ClassLoader.java:235)
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66)
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:162)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:535)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:534)the servlet class file ReportServlet.class is located in:
WEB-INF\classes\com\ruffalocody\report
web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>RprtSrvlt</servlet-name>
<servlet-class>com.ruffalocody.report.ReportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RprtSrvlt</servlet-name>
<url-pattern>/reports</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>
<!-- Context Param -->
<context-param>
<param-name>crystal_image_uri</param-name>
<param-value>crystalreportviewers10</param-value>
</context-param>
<!-- Context Param End -->
</web-app>It's called from the index.jsp page w/ ulr: "reports?goTo=view"
Servlet code (not sure if it's useful, but including just in case):
* ReportServlet.java
* Created on February 1, 2007, 11:04 AM
package com.ruffalocody.report;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.crystaldecisions.reports.reportengineinterface.JPEReportSourceFactory;
import com.crystaldecisions.sdk.occa.report.reportsource.IReportSourceFactory2;
import com.crystaldecisions.sdk.occa.report.reportsource.IReportSource;
import com.crystaldecisions.report.web.viewer.CrystalReportViewer;
import com.crystaldecisions.sdk.occa.report.lib.ReportSDKExceptionBase;
* @author aerohner
* @version
public class ReportServlet extends HttpServlet
String rptLoc = "CR10_JRC_BeginHere.rpt";
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
response.setContentType("text/html;charset=UTF-8");
String goTo = request.getParameter("goTo");
if(goTo != null && goTo.equals("view"))
viewReport(request, response);
}// end goTo view
else if(goTo != null && goTo.equals("export"))
exportReport(request, response);
}// end go to export
else
RequestDispatcher view = request.getRequestDispatcher("index.jsp");
view.forward(request,response);
private void viewReport(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
IReportSource rptSrc = setUpReportSource(request);
if (rptSrc != null)
// create viewer
CrystalReportViewer viewer = new CrystalReportViewer();
try
viewer.setReportSource(rptSrc);
forward(request, response, viewer);
catch(ReportSDKExceptionBase e)
e.printStackTrace();
}// if rptsrc not null
else
log("rptSrc is null");
}// end else not null
}// end viewReport(.)
private void exportReport(HttpServletRequest request, HttpServletResponse response)
}// end exportReport(.)
private IReportSource setUpReportSource(HttpServletRequest request)
IReportSourceFactory2 rptFact = new JPEReportSourceFactory();
IReportSource rptSrc = null;
try
rptSrc = (IReportSource)
rptFact.createReportSource(rptLoc, request.getLocale());
}// end try
catch (Exception e)
return rptSrc;
}// end setUpReportSource()
private void forward(HttpServletRequest request,
HttpServletResponse response, Object viewer)
throws ServletException, IOException
request.setAttribute("viewer", viewer);
RequestDispatcher view = request.getRequestDispatcher("viewer.jsp");
view.forward(request,response);
}// end forward(...)
// <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
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
processRequest(request, response);
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
processRequest(request, response);
/** Returns a short description of the servlet.
public String getServletInfo()
return "Short description";
// </editor-fold>
}Thanks :)I'm curious. Could you strip off the "java." part of the package, so both in your sourcefile as in the directory structure? It may be that the java package is not allowed, but then I wouldn't know why you didn't get a compile error...
-
Wrapper cannot find servlet class
Hi all
Can anyone please help me to resolve this error. It come about since I've provided the package (pa_sodev.pr_add_user_diary_event). My Java file is in Java Resources:src folder .
I don't have a folder called classes in my WEB_INF directory.
Many thanks
Zed
exception
javax.servlet.ServletException: Wrapper cannot find servlet class addEveProcess or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.ClassNotFoundException: addEveProcess
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1484)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1329)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)Edited by: Zed420 on Jan 31, 2010 6:09 PMThanks for your reply, can I ask if my setup is correct ?
I'm using Eclipse, on my left in Dynamic Web Perspective I have Servers and myProject.
In myProject ->Java Resources:src (this is where all my java files are with package) and WebContent.
In WebContent ->META-INF and WEB-INF
In WEB-INF ->(this is where I have lib folder and my xml & jsp files)
In lib I have Oracle connector .jar
Can someone confirm if this is the right setup please.
thanks
Zed -
War file not loading - Offending class: javax/servlet/Servlet.class
Hello;
I've got a war file for an app that I've been building for the past several weeks. I created a new version and uploaded it to the server and received a 404 error when trying to call a servlet in the war. The catalina.out file had the following message:
WebappClassLoader: validateJarFile(/usr/local/apache/tomcat/webapps/optintelligence/WEB-INF/lib/j2ee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
I've not changed my libraries at all and I don't see any conflict with another appliacation. The war file works on my local windows machine but has this error on a RedHat server. Both are running tomcat 4.x
I would appreciate any information on this problem.
Thanks;
MarshallYou might still get the warning when you start Tomcat:
WebappClassLoader: validateJarFile(/usr/local/apache/tomcat/webapps/optintelligence/WEB-INF/lib/j2ee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
That's because you have the j2ee.jar as part of the web application. The servlet specficiation forbids a web application trying to override core java, j2ee classes. Thererfore Tomcat prints the warning message that the particular jar could not be loaded as it is trying to override a core java-j2ee class.
If you remove the j2ee.jar from the web app WEB-INF/lib folder, the warning will disappear. -
Unable to load servlet class specified in the module.
Hi,
Hope that I am in the right Forum to ask this question.
I tried to develop basic servlet example as specified in http://java.sun.com/developer/onlineTraining/J2EE/Intro2/servlet/servlet.html.
When I create WAR file in Deployment tool I get the following error. How can I rectify this?
Thank you very much for any help.
Regards,
Indika
Error :
Unable to load servlet class specified in the module.
Please contact online help for assistance.
java.lang.UnsupportedClassVersionError : bonus/controller/BonusCalculationServlet (Unsupported major.minor version 49.0)Hi Yohan_co,
I haven't used Application Server 8.2, but I think the problem is because the jdk that AS is using is previous to the jdk that your are using to compile your source files.
I hope that it helps you.
Regards -
Failed to load servlet Class: org.apache.jasper.servlet.JspServlet
I am evaluating Weblogic 12c and is stuck in deployment of an application.
My application is locally developed and is working fine in Oracle Glassfish. I have install glassfish and deploy application multiple time.
In weblogic I can deploy the application successfully and the state= Prepared while Health=OK.
When I access applicaiton from web browser, it says:
Error 503--Service Unavailable
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.4 503 Service Unavailable
The server.log is having messages similar to following:
When processing WebService module 'SHMA'. Failed to load servlet Class: org.apache.jasper.servlet.JspServlet
Ignoring: unable to load class:java.lang.ClassNotFoundException: org.apache.jasper.servlet.JspServlet at: weblogic.xml.schema.binding.util.ClassUtil.loadClass(ClassUtil.java:76)
Jun 4, 2013 5:59:36 PM com.sun.xml.ws.model.JavaMethodImpl freeze
WARNING: Input Action on WSDL operation RegisterOperation and @Action on its associated Web Method registerOperation did not match and will cause problems in dispatching the requests
Any idea about how to fix this??
Application is working fine in Glassfish 3.2
I am having RHEL6-3 x86 with JDK 1.6u45 for Bea Weblogic 12c.
ThanksProbably not the right forum. But you have the honour of being the first person to ask a specific WebLogic Server question here.
The BEA dev-2-dev site still seems to be active. Try here hunting for a category here: http://forums.bea.com/index.jspa
-steve- -
How to publish a servlet class to web server?
background:
web server: tomcat apache 4
context path: webapp\test\
servlet path: webapp\test\WEB-INF
servlet name: HelloWorld.class
i tried to placed the servlet class file to above servlet path,
but i can't invoke the servlet by http://localhost:8080/test/HelloWorld
what should i do in order to invoke the servlet at browser?
Is a web.xml necessary a must to provided a mapping between request name and actual class name?First of all you need a *.war structure which look like this
/app-name
/app-name/WEB-INF/
/app-name/WEB-INF/lib
/app-name/WEB-INF/classes
When you have created this structure you add your servlet (HelloWorld.class) in the classes directory (Create the package structure first).
When this is done you need to map the servlet to a given uri which is done in the web.xml. An example is found below:
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>package.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hello/*</url-pattern>
</servlet-mapping>
Hopefully this will help :-)
best regards
Stig -
Problem in compiling servlet class - using Tomcat
Hi,
I have a servlet pgm that I'm trying to compile.I using Tomcat application server.I have my servlet class in D:\servlet_wrk\project1\src
and my deployment descriptor in D:\servlet_wrk\project1\etc
my CLASSPATH var is set to C:\Sun\AppServer\jdk\bin
and
my PATH var is set to C:\Sun\AppServer\bin.
When I compile my servlet class Ch1Servlet.java in the command line from the directory
D:\servlet_wrk\project1 using the command
javac -classpath D:\applications\tomcat-5.5.12\common\lib\servlet-api.jar -d classes src/Ch1Servlet.java,
it says error:cannot read: src/Ch1Servlet.java
Can somebody help me to solve this problem and help me to compile my servlet class.
Thanks.Thanks...as u said I tried putting dir & found that
my file was saved as Ch1Servlet.java.txt instead for
Ch1Servlet.java......So that was a problem.Now I'm
able to compile.Oh, yeah. Notepad will do that to you. I think when you save in Notepad if you put quotes around the name "Whatever.java" then it won't add the .txt.
But on compiling I'm getting the following error
package java.servlet.* does not exist
package java.servlet.http.* does not exist
package java.io.* does not exist
Do u the reason for this??? The servlet stuff is java[b]x.servlet. For the io stuff, I don't know, I'd have to see your code. Either you have a typo or a corrupt installation. -
Class not found in web-inf/classes folder of war file within ear file
Hi all,
I am using Weblogic 8.1 sp4. I have a war file within an ear file. I am trying to deploy the war file with a few classes within its web-inf/classes folder, however when the classes are in that folder I consistently get a class not found exception when trying to instantiate them. If I package the classes in a jar file and then put that jar file within the web-inf/lib folder of the war, the classes are also not found.
If I put these two classes in the app-inf/classes folder of the ear file, everything works as expected and the classes are found.
Any ideas of why this is happening. This seems to be a very simple thing that should work, but appears to not be working at all.
thanks in advance for any suggestions or ideas.Hi,
This is a known limitation/issue with WL. There is also no way around this.
Regards,
LG -
Non-servlet class in servlet program
hi,
I declare a non-servlet class which is defined by myself in a servlet class. I passed the complie but got an runtime error said NoClassDefFoundError. Does anyone can help me? Thanks.
The following is my code.
//get the search string from web form
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.*;
import java.util.*;
public class SearchEngines extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String searchString = (String) request.getParameter("searchString");
String searchType = (String) request.getParameter("searchType");
Date date = new java.util.Date();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Vector doc_retrieved = new Vector();
BooleanSearch bs = new BooleanSearch();
doc_retrieved=bs.beginSearch(searchString, searchType);
out.println("<HTML><HEAD><TITLE>Hello Client!</TITLE>" +
"</HEAD><BODY>Hello Client! " + doc_retrieved.size() + " documents have been found.</BODY></HTML>");
out.close();
response.sendError(response.SC_NOT_FOUND,
"No recognized search engine specified.");
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
// a search engine implements the boolean search
import java.io.*;
import java.util.*;
import au.com.pharos.gdbm.GdbmFile;
import au.com.pharos.gdbm.GdbmException;
import au.com.pharos.packing.StringPacking;
import IRUtilities.Porter;
public class BooleanSearch{
BooleanSearch(){;}
public Vector beginSearch(String searchString, String searchType){
Vector query_vector = queryVector(searchString);
Vector doc_retrieved = new Vector();
if (searchType.equals("AND"))
doc_retrieved = andSearch(query_vector);
else
doc_retrieved = orSearch(query_vector);
return doc_retrieved;
private Vector queryVector(String query){
Vector query_vector = new Vector();
try{
GdbmFile dbTerm = new GdbmFile("Term.gdbm", GdbmFile.READER);
dbTerm.setKeyPacking(new StringPacking());
dbTerm.setValuePacking(new StringPacking());
query = query.toLowerCase();
StringTokenizer st = new StringTokenizer(query);
String word = "";
String term_id = "";
while (st.hasMoreTokens()){
word = st.nextToken();
if (!search(word)){
word = Stemming(word);
if (dbTerm.exists(word)){
// System.out.println(word);
term_id = (String) dbTerm.fetch(word);
query_vector.add(term_id);
catch(GdbmException e){
System.out.println(e.getMessage());
return query_vector;
private Vector orSearch(Vector query_vector){
Vector doc_retrieved = new Vector();
try{
GdbmFile dbVector = new GdbmFile("Vector.gdbm", GdbmFile.READER);
dbVector.setKeyPacking(new StringPacking());
dbVector.setValuePacking(new StringPacking());
int doc_num = dbVector.size();
String doc_id = "";
String temp = "";
for (int i = 1; i <= doc_num; i++){
boolean found = false;
doc_id = String.valueOf(i);
temp = (String) dbVector.fetch(doc_id);
StringTokenizer st = new StringTokenizer(temp);
while (st.hasMoreTokens() && !found){
temp = st.nextToken();
StringTokenizer st1 = new StringTokenizer(temp, ",");
String term = st1.nextToken();
if (query_vector.contains(term)){
doc_retrieved.add(doc_id);
found = true;
catch(GdbmException e){
System.out.println(e.getMessage());
return doc_retrieved;
private Vector andSearch(Vector query_vector){
Vector doc_retrieved = new Vector();
try{
GdbmFile dbVector = new GdbmFile("Vector.gdbm", GdbmFile.READER);
dbVector.setKeyPacking(new StringPacking());
dbVector.setValuePacking(new StringPacking());
int doc_num = dbVector.size();
String doc_id = "";
String temp = "";
for (int i = 1; i <= doc_num; i++){
Vector doc_vector = new Vector();
boolean found = true;
doc_id = String.valueOf(i);
temp = (String) dbVector.fetch(doc_id);
StringTokenizer st = new StringTokenizer(temp);
while (st.hasMoreTokens()){
temp = st.nextToken();
StringTokenizer st1 = new StringTokenizer(temp, ",");
String term = st1.nextToken();
doc_vector.add(term);
for (int j = 0; j < query_vector.size(); j++){
temp = (String) query_vector.get(j);
if (doc_vector.contains(temp))
found = found & true;
else
found = false;
if (found)
doc_retrieved.add(doc_id);
catch(GdbmException e){
System.out.println(e.getMessage());
return doc_retrieved;
private String Stemming(String str){
Porter st = new Porter ();
str = st.stripAffixes(str);
return str;
private boolean search(String str){
//stop word list
String [] stoplist ={"a","about","above","according","across","actually","adj","after","afterwards","again",
"against","all","almost","alone","along","already","also","although","always","am","among",
"amongst","an","and","another","any","anyhow","anyone","anything","anywhere","are",
"aren't","around","as","at","away","be","became","because","become","becomes","becoming",
"been","before","beforehand","begin","beginning","behind","being","below","beside",
"besides","between","beyond","billion","both","but","by","can","cannot","can't",
"caption","co","co.","could","couldn't","did","didn't","do","does","doesn't","don't",
"down","during","each","eg","eight","eighty","either","else","elsewhere","end","ending",
"enough","etc","even","ever","every","everyone","everything","everywhere","except",
"few","fifty","first","five","for","former","formerly","forty","found","four","from",
"further","had","has","hasn't","have","haven't","he","he'd","he'll","hence","her","here",
"hereafter","hereby","herein","here's","hereupon","hers","he's","him","himself","his",
"how","however","hundred","i'd","ie","if","i'll","i'm","in","inc.","indeed","instead",
"into","is","isn't","it","its","it's","itself","i've","last","later","latter","latterly",
"least","less","let","let's","like","likely","ltd","made","make","makes","many","maybe",
"me","meantime","meanwhile","might","million","miss","more","moreover","most","mostly",
"mr","mrs","much","must","my","myself","namely","neither","never","nevertheless","next",
"nine","ninety","no","nobody","none","nonetheless","noone","nor","not","nothing","now",
"nowhere","of","off","often","on","once","one","one's","only","onto","or","other","others",
"otherwise","our","ours","ourselves","out","over","overall","own","per","perhaps","pm",
"rather","recent","recently","same","seem","seemed","seeming","seems","seven","seventy",
"several","she","she'd","she'll","she's","should","shouldn't","since","six","sixty",
"so","some","somehow","someone","sometime","sometimes","somewhere","still","stop",
"such","taking","ten","than","that","that'll","that's","that've","the","their","them",
"themselves","then","thence","there","thereafter","thereby","there'd","therefore",
"therein","there'll","there're","there's","thereupon","there've","these","they","they'd",
"they'll","they're","they've","thirty","this","those","though","thousand","three","through",
"throughout","thru","thus","to","together","too","toward","towards","trillion","twenty",
"two","under","unless","unlike","unlikely","until","up","upon","us","used","using",
"very","via","was","wasn't","we","we'd","well","we'll","were","we're","weren't","we've",
"what","whatever","what'll","what's","what've","when","whence","whenever","where",
"whereafter","whereas","whereby","wherein","where's","whereupon","wherever","whether",
"which","while","whither","who","who'd","whoever","whole","who'll","whom","whomever",
"who's","whose","why","will","with","within","without","won't","would","wouldn't",
"yes","yet","you","you'd","you'll","your","you're","yours","yourself","you've"};
int i = 0;
int j = stoplist.length;
int mid = 0;
boolean found = false;
while (i < j && !found){
mid = (i + j)/2;
if (str.compareTo(stoplist[mid]) == 0)
found = true;
else
if (str.compareTo(stoplist[mid]) < 0)
j = mid;
else
i = mid + 1;
return found;
}please show us the full error message.
it sounds like a classpath problem...
Maybe you are looking for
-
Need help on name of an extension.
I can't remember the name of an extension I had, maybe some one knows the name. The extension was one where when I clicked on a new tab, I could customize the tab page with short cuts to my favorite sites from a list of sites or type in my own. I any
-
FCC in receiver side in idoc to file scenario
Hi all, I am doing an idoc to file scenario using FCC .I am using FCC in receiver side ,but i am getting my output file in only one line while i want structre to be seprated by new line.for more information i am giving muy file structre. R
-
When splitting a document, in output options you can select the target folder to be "the same folder selected at start", but where is that folder? I assumed it would be the original location of the source file but in my test the split files are not
-
HT1461 how do i know if my mac works with 32 or 64 bit of windows 7
Any clue? Thanks
-
Thrid party application wont delete in trash- comes back
i have downloaded a thrid party applciation named 4easy dvd ripper; the free version . I tried to get rid of it by droping in into the trash but not all files deleted.. I had to search for every single file that went with it ... The problem is that t