AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with embedded Tomcat and JSP compilation.

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> comp.lang.java.developer
View previous topic :: View next topic  
Author Message
bcassand
Guest





PostPosted: Wed Jan 07, 2004 1:51 pm    Post subject: Problem with embedded Tomcat and JSP compilation. Reply with quote



Hi,

I wrote an application running an embedded Tomcat, based on the sample
code of the onJava site (an 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: 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:testtomcatwork_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;
import org.apache.catalina.Deployer;
import org.apache.catalina.Engine;
import org.apache.catalina.Host;
import org.apache.catalina.logger.SystemOutLogger;
import org.apache.catalina.startup.Embedded;
import 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>
Back to top
Martin Moessner
Guest





PostPosted: Mon Jan 12, 2004 12:38 pm    Post subject: Re: Problem with embedded Tomcat and JSP compilation. Reply with quote



check if "JDK_TOOLS/lib/tools.jar" is in the CLASSPATH and also
"TOMCAT_HOME/common/lib/servlet.jar"

hope this helps

martin

"bcassand" <benjamin.cassan (AT) netcourrier (DOT) com> schrieb im Newsbeitrag
news:80df2c26.0401070551.67675726 (AT) posting (DOT) google.com...
Quote:
Hi,

I wrote an application running an embedded Tomcat, based on the sample
code of the onJava site (an 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: 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:testtomcatwork_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;
import org.apache.catalina.Deployer;
import org.apache.catalina.Engine;
import org.apache.catalina.Host;
import org.apache.catalina.logger.SystemOutLogger;
import org.apache.catalina.startup.Embedded;
import 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



Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> comp.lang.java.developer All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.