Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Problem with embedded Tomcat and JSP compilation.

Problem with embedded Tomcat and JSP compilation.

2004-01-08       - By benjamin.cassan@(protected)

 Back
Hi,

I wrote an application running an embedded Tomcat, based on the sample code of
the onJava site (an org.apache.catalina.startup.Embedded Source code of org.apache.catalina.startup.Embedded class with manual
configuration of things usually found in server.xml). I use Tomcat 4.1.27 and
Java 1.3.1.
Tomcat starts well, but is not able to compile JSP page. It displays the
following error:

<code>
org.apache.jasper.JasperException Source code of org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 4 in the jsp file: /index.jsp

Generated servlet error:
   [javac] Compiling 1 source file


C:\test\tomcat\work\_\localhost\_\index_jsp.java:3: package javax.servlet does
not exist
import javax.servlet.*;
^
...
</code>

and so on for all import statements. It looks like a classpath problem, but I
set the classpath with all the jar files in tomcat/common/lib, in tomcat/server
/lib, in tomcat/common/endorsed, bootstrap.jar, the tools.jar of java. I set it
in the environment CLASSPATH variable and in the classpath of the jar of my
application. And the classpath is set, because if not, Tomcat cannot be
launched.

So I probably missed something, but what?


Below you can see the code of my class and the code of the main function:

<code of class EmbeddedTomcat>
import org.apache.catalina.Connector;
import org.apache.catalina.Context Source code of org.apache.catalina.Context;
import org.apache.catalina.Deployer;
import org.apache.catalina.Engine Source code of org.apache.catalina.Engine;
import org.apache.catalina.Host Source code of org.apache.catalina.Host;
import org.apache.catalina.logger.SystemOutLogger;
import org.apache.catalina.startup.Embedded Source code of org.apache.catalina.startup.Embedded;
import org.apache.catalina.Container Source code of org.apache.catalina.Container;

public class EmbeddedTomcat
{
   private String path = null;
   private Embedded embedded = null;
   private Host host = null;

   public EmbeddedTomcat()
   {
   }

   public void setPath( String path)
   {
       this.path = path;
   }

   public String getPath()
   {
       return( path);
   }

   public void startTomcat() throws Exception
   {
       Engine engine = null;
       Context context = null;

       System.setProperty( "catalina.home", getPath());
       System.setProperty( "catalina.base", getPath());

       embedded = new Embedded();
       embedded.setDebug( 0);
       embedded.setLogger( new SystemOutLogger());

       engine = embedded.createEngine();
       engine.setDefaultHost( "localhost");

       host = embedded.createHost( "localhost", "webapps");
       engine.addChild( host);

       context = embedded.createContext( "", "c:/test/root");
       host.addChild( context);

       embedded.addEngine( engine);

       Connector connector = embedded.createConnector( null, 8080, false);
       embedded.addConnector( connector);

       embedded.start();
   }

   public void stopTomcat() throws Exception
   {
       embedded.stop();
   }
}
</code>

<code in main function of my application>
   EmbeddedTomcat tomcat = new EmbeddedTomcat();
   tomcat.setPath( m_config.getString( "tomcat.home"));
   try
   {
       tomcat.startTomcat();
   }
   catch( Exception error)
   {
       logger.fatal( "Unable to start tomcat.", error);
       return;
   }
</code>

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---
NetCourrier, votre bureau virtuel sur Internet : Mail, Agenda, Clubs, Toolbar...
Web/Wap : www.netcourrier.com
T�l�phone/Fax : 08 92 69 00 21 (0,34 � TTC/min)
Minitel: 3615 NETCOURRIER (0,16 � TTC/min)


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)




©2008 junlu.com - Jax Systems, LLC, U.S.A.