Pls help me.I m using Tomcat5.0 with jdk1.5
I m able to run servlet keept inside "Tomcatroot\webapps\servlets-examples\WEB-INF" folder i also tried to make my own servlet and they are running very well,but now i want to place servlet created by me in a diff folder (say mycode folder).
When i tried to do so i m getting following error
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 allocating a servlet instance
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
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:683)
java.lang.Thread.run(Thread.java:595)
root cause
java.lang.NoClassDefFoundError: mycode/TestingFolder (wrong name: TestingFolder)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
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:683)
java.lang.Thread.run(Thread.java:595)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
[ December 19, 2007: Message edited by: David O'Meara ]
[ December 19, 2007: Message edited by: Bear Bibeault ]
This is basic Java, you should consider asking about packages in the Java in General (beginner) forum
Originally posted by David O'Meara:
To do this you need to package the servlet as mycode.TestingFolder before you can refer to it as mycode.TestingFolder
This is basic Java, you should consider asking about packages in the Java in General (beginner) forum
Hi,
Thanks a lot for prompt reply.
I know packages in java.Now will you pls tell me the steps so that i can put my servlet files in a diff. folder and can run them,just give me the hine i will try it.
Thanks a lot
Originally posted by David O'Meara:
To do this you need to package the servlet as mycode.TestingFolder before you can refer to it as mycode.TestingFolder
This is basic Java, you should consider asking about packages in the Java in General (beginner) forum
Hi,
Thanks a lot for prompt reply.
I know packages in java.Now will you pls tell me the steps so that i can put my servlet files in a diff. folder and can run them,just give me the hint i will try it.
Thanks a lot
------------------------------------------------------------------
Download HelloWorld.java from http://archive.corewebprogramming.com/Chapter19.html to anywhere.
Change directory to the location where you stored HelloWorld.java and compile it with javac HelloWorld.java
Move the resulting .class file to %TOMCAT_HOME%/webapps/examples/WEB-INF/classes.
(Instead of using the %TOMCAT_HOME%/webapps/examples/WEB-INF/classes directory, we could have created an entirely new web app. That would have required adding another Context entry to the server.xml file. Had we done that, we would have had to restart Tomcat. To restart Tomcat, call shutdown and then startup again in the Command Prompt window in which we had originally started Tomcat.)
In a brower, access, http://localhost:8080/examples/servlet/HelloWorld. Your servlet will run.
Sun Certified Java Programmer<br />Sun Certified Web Component Developer <br />National Stock Exchange Certification in Financial Market
Originally posted by Jagadabi Vinay Kumar:
Hi,
Create a folder inside webapps folder and keep WEB-INF folder inside that folder which is creared by you. Now create web.xml file inside WEB-INF with root tag as <web-app>. Then only your application will be qualified as servlet application.
Hi,
Thanks for your kind support.
I just followed what you told i m telling you what i had done it is as:
C:\Tomcat5.0\webapps\mycode(folder created by me)
Inside mycode i created WEB-INF & classes folder.
I just made copy past for web.xml file and put it inside WEB-INF folder created by me ans also put TestingFolder.class file inside classes folder created by me.
After this i deleted all the code for diff. srevlet mapping in web.xml file and added new as
<servlet>
<servlet-name>TestingFolder</servlet-name>
<servlet-class>mycode.TestingFolder</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestingFolder</servlet-name>
<url-pattern>/mycode/TestingFolder</url-pattern>
</servlet-mapping>
So the look of my web.xml file is as
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Servlet 2.4 Examples</display-name>
<description>
Servlet 2.4 Examples.
</description>
<!-- Define servlet-mapped and path-mapped example filters -->
<filter>
<filter-name>Servlet Mapped Filter</filter-name>
<filter-class>filters.ExampleFilter</filter-class>
<init-param>
<param-name>attribute</param-name>
<param-value>filters.ExampleFilter.SERVLET_MAPPED</param-value>
</init-param>
</filter>
<filter>
<filter-name>Path Mapped Filter</filter-name>
<filter-class>filters.ExampleFilter</filter-class>
<init-param>
<param-name>attribute</param-name>
<param-value>filters.ExampleFilter.PATH_MAPPED</param-value>
</init-param>
</filter>
<filter>
<filter-name>Request Dumper Filter</filter-name>
<filter-class>filters.RequestDumperFilter</filter-class>
</filter>
<!-- Example filter to set character encoding on each request -->
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>EUC_JP</param-value>
</init-param>
</filter>
<filter>
<filter-name>Compression Filter</filter-name>
<filter-class>compressionFilters.CompressionFilter</filter-class>
<init-param>
<param-name>compressionThreshold</param-name>
<param-value>10</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
</filter>
<!-- Define filter mappings for the defined filters -->
<filter-mapping>
<filter-name>Servlet Mapped Filter</filter-name>
<servlet-name>invoker</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>Path Mapped Filter</filter-name>
<url-pattern>/servlet/*</url-pattern>
</filter-mapping>
<!-- Example filter mapping to apply the "Set Character Encoding" filter
to *all* requests processed by this web application -->
<!--
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->
<!--
<filter-mapping>
<filter-name>Compression Filter</filter-name>
<url-pattern>/CompressionTest</url-pattern>
</filter-mapping>
-->
<!--
<filter-mapping>
<filter-name>Request Dumper Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->
<!-- Define example application events listeners -->
<listener>
<listener-class>listeners.ContextListener</listener-class>
</listener>
<listener>
<listener-class>listeners.SessionListener</listener-class>
</listener>
<!-- Define servlets that are included in the example application -->
<servlet>
<servlet-name>TestingFolder</servlet-name>
<servlet-class>mycode.TestingFolder</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestingFolder</servlet-name>
<url-pattern>/mycode/TestingFolder</url-pattern>
</servlet-mapping>
<security-constraint>
<display-name>Example Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<!-- Define the context-relative URL(s) to be protected -->
<url-pattern>/jsp/security/protected/*</url-pattern>
<!-- If you list http methods, only those methods are protected -->
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<!-- Anyone with one of the listed roles may access this area -->
<role-name>tomcat</role-name>
<role-name>role1</role-name>
</auth-constraint>
</security-constraint>
<!-- Default login configuration uses form-based authentication -->
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Example Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/jsp/security/protected/login.jsp</form-login-page>
<form-error-page>/jsp/security/protected/error.jsp</form-error-page>
</form-login-config>
</login-config>
<!-- Security roles referenced by this web application -->
<security-role>
<role-name>role1</role-name>
</security-role>
<security-role>
<role-name>tomcat</role-name>
</security-role>
<!-- Environment entry examples -->
<!--env-entry>
<env-entry-description>
The maximum number of tax exemptions allowed to be set.
</env-entry-description>
<env-entry-name>maxExemptions</env-entry-name>
<env-entry-value>15</env-entry-value>
<env-entry-type>java.lang.Integer</env-entry-type>
</env-entry-->
<env-entry>
<env-entry-name>minExemptions</env-entry-name>
<env-entry-value>1</env-entry-value>
<env-entry-type>java.lang.Integer</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>foo/name1</env-entry-name>
<env-entry-value>value1</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>foo/bar/name2</env-entry-name>
<env-entry-value>true</env-entry-value>
<env-entry-type>java.lang.Boolean</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>name3</env-entry-name>
<env-entry-value>1</env-entry-value>
<env-entry-type>java.lang.Integer</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>foo/name4</env-entry-name>
<env-entry-value>10</env-entry-value>
<env-entry-type>java.lang.Integer</env-entry-type>
</env-entry>
</web-app>
After this i requested like "http://localhost:8080/mycode/TestingFolder"
But i m getting following error.
HTTP Status 404 - /mycode/TestingFolder
--------------------------------------------------------------------------------
type Status report
message /mycode/TestingFolder
description The requested resource (/mycode/TestingFolder) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
Pls tell me now what should i do.
Thanks a lot for healping me
Please use real words when posting to the forums. Abbreviations such as "pls" in place of "please" only serve to make your posts more difficult to read and less likely to generate useful responses.Pls tell me now what should i do.
Please read this for more information.
thanks,
bear
JavaRanch sheriff
