aspose file tools*
The moose likes Tomcat and the fly likes Error in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Error in Tomcat" Watch "Error in Tomcat" New topic
Author

Error in Tomcat

Kudret Serin
Ranch Hand

Joined: Aug 02, 2005
Posts: 167

Hi
I am trying to deploy a simple web application (HFSJ Chapter 3) but when i launch my application via browser i get 404 Error
type Status report

message /kare/form.html

description The requested resource (/kare/form.html) is not available.

I checked the development and deployment directory structure and everything seems to be ok. (I have application files under tomcat/webapps/kare including form.html, WEB-INF, web.xml, classes etc.)
When i run Tomcat i get some exceptions:
17.12.2005 22:41:35 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Portable Runtime which allows optimal performance in production environments was not found on the java.library.path: C:\Pro
gramme\Apache\Tomcat\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\Java\jdk1.5.0
_04\bin;C:\Programme\apache-ant-1.6.5\bin;C:\Programme\cvsnt;C:\Programme\Sun\AppServer\bin;C:\Programme\Sun\jstudio_ent8\AppServ8.1UR2\bin;
C:\Programme\IDM Computer Solutions\UltraEdit-32;C:\Programme\Sun\jstudio_ent8\ide\uml1\modules\DoorsIntegrationFiles\modules\bin
17.12.2005 22:41:35 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
17.12.2005 22:41:35 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 781 ms
17.12.2005 22:41:35 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
17.12.2005 22:41:35 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.11
17.12.2005 22:41:35 org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
17.12.2005 22:41:36 org.apache.tomcat.util.digester.Digester fatalError
SCHWERWIEGEND: Parse Fatal Error at line 14 column 8: Invalid byte 1 of 1-byte UTF-8 sequence.
org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(ContextConfig.java:339)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1031)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:255)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4076)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:910)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:873)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
at org.apache.catalina.startup.Catalina.start(Catalina.java:540)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
17.12.2005 22:41:36 org.apache.catalina.startup.ContextConfig applicationWebConfig
SCHWERWIEGEND: Parse error in application web.xml
org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(ContextConfig.java:339)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1031)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:255)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4076)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:910)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:873)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
at org.apache.catalina.startup.Catalina.start(Catalina.java:540)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
17.12.2005 22:41:36 org.apache.catalina.startup.ContextConfig applicationWebConfig
SCHWERWIEGEND: Occurred at line 14 column 8
17.12.2005 22:41:36 org.apache.catalina.startup.ContextConfig start
SCHWERWIEGEND: Marking this application unavailable due to previous error(s)
17.12.2005 22:41:36 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Error getConfigured
17.12.2005 22:41:36 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Context [/kare] startup failed due to previous errors
17.12.2005 22:41:36 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
17.12.2005 22:41:36 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
17.12.2005 22:41:36 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/140 config=null
17.12.2005 22:41:36 org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
17.12.2005 22:41:36 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1281 ms

I have uninstalled and reinstalled Tomcat but did not help.
What can i do? What i miss?
Thanks for any help.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42918
    
  68
These following lines give all that clues that should be necessary to track down the problem:
Parse error in application web.xml
org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
Occurred at line 14 column 8
Marking this application unavailable due to previous error(s)


I'll leave the rest as an exercise for the reader No need to uninstall/reinstall Tomcat, or to stop/restart it even. After fixing this problem, restart the web app, and everything should work.
[ December 18, 2005: Message edited by: Ulf Dittmer ]
Kudret Serin
Ranch Hand

Joined: Aug 02, 2005
Posts: 167

ok that was typing error in my DD
But now, when i launch the app in browser, i can see the form and when i submit i get this exception:
javax.servlet.ServletException: Error instantiating servlet class com.example.web.KareBul
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:868)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
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(Unknown Source)


root cause

java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class com.example.web.KareBul with modifiers ""
sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
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:868)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
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(Unknown Source)


The compilation of the servlet was successful and the KareBul.class is in
C:\Programme\Apache\Tomcat\webapps\kare\WEB-INF\classes\com\example\web
Thanks again
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410



And, I trust you're looking at your class named KareBul or one of the classes that calls it's setter methods to see what might be causing an IllegalAccessException, right?
[ December 18, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Kudret Serin
Ranch Hand

Joined: Aug 02, 2005
Posts: 167

Ok i found it. I forgot the "public" modifier in my KareBul class. (It was default) With this mistake i learned that a servlet must always be public (or?) Sorry for the dummy questions , i am new on servlets, Jsp, Tomcat etc. :roll:
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Glad you found it.
Thanks for posting back.
Kudret Serin
Ranch Hand

Joined: Aug 02, 2005
Posts: 167

Another question:

I have a very simple web-app. User gives a number and servlet returns the square of this number.
My DD is under D:\Sqr\etc:
<web-app..>
<servlet>
<servlet-name> FindSquare </servlet-name>
<servlet-class> com.example.web.FindSquare </servlet-class>
</servlet>

<servlet-mapping>
<servlet-name> FindSquare </servlet-name>
<url-pattern> /FindSquare.do </url-pattern>
</servlet-mapping>
</web-app>

My HTML form is under D:\Sqr\web:
<html>
<body>
<h1 align="center"> Find Square </h1>

<form method="POST" action="FindSquare.do" >
<p>
Number:
<input type="text" name="number">

<input type="SUBMIT">

</form>
</body>
</html>

My Servlet (FindSquare.java) is under D:\Sqr\src\com\example\web:
package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class FindSquare extends HttpServlet{

public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException{
response.setContentType("text/html");

PrintWriter out=response.getWriter();


String s=request.getParameter("number");
try{
int i=Integer.parseInt(s);
out.print("Square of the number: ");

SquareFinder k=new SquareFinder();

out.println(k.findSquare(i));
}catch(NumberFormatException e){ out.println("You have to enter a number");
}
}
}

My model class (SquareFinder.java) is under D:\Sqr\src\com\example\model:
package com.example.model;

public class SquareFinder {

public int findSquare(int i){
return i*i;
}
}

I've compiled my model class under D:\Sqr with
javac -d classes src\com\example\model\SquareFinder.java

so that i have D:\Sqr\classes\com\example\model\SquareFinder.class
But, when i want to compile my servlet under D:\Sqr with
javac -classpath c:\programme\apache\tomcat\common\lib\servlet-api.jar -d classes src\com\example\web\FindSquare.java
I get the following error
src\com\example\web\FindSquare.java:3: package com.example.model does not exist
import com.example.model.*;
^
src\com\example\web\FindSquare.java:20: cannot find symbol
symbol : class SquareFinder
location: class com.example.web.FindSquare
SquareFinder k=new SquareFinder();
^
src\com\example\web\FindSquare.java:20: cannot find symbol
symbol : class SquareFinder
location: class com.example.web.FindSquare
SquareFinder k=new SquareFinder();
^
3 errors

What is wrong? Why do i get the same error message two times? (FindSquare.java:20: can not find symbol)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42918
    
  68
The compiled class in not your classpath. Try

javac -classpath classes;c:\programme\apache\tomcat\common\lib\servlet-api.jar -d classes src\com\example\web\FindSquare.java

The class is reported missing every time it's needed, once for the type of field "k", and once for the constructor. javac is not particularly smart about this.
Kudret Serin
Ranch Hand

Joined: Aug 02, 2005
Posts: 167

Thanks a lot Ulf. You helped me so much today
All my problems occur due to my classpath settings
[ December 18, 2005: Message edited by: Kudret Serin ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in Tomcat