You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Sinkinson,Andrew [NCR]" <An...@ec.gc.ca> on 2003/03/14 16:02:08 UTC
Need help with struts
Unfortunaly I am using JB8 and have been experiencing nothing but problems.
If I dont add struts.jar as a required lib for Tomcat4.06 I get the
"java.lang.NoClassDefFoundError: org/apache/struts/action/ActionMessage".
When I add struts.jar as a required lib for my web container my message
resources show up as ???en_CA.ver???. I am working with interchanging
message resources depending on the locale. (Struts1.1b1). When I upgrade my
Struts.jar to Struts1.1b3 I get the following error:
StandardWrapper[/sitegenerator:default]: Loading container servlet default
StandardContext[/sitegenerator]: Servlet /sitegenerator threw load()
exception: javax.servlet.ServletException: Servlet.init() for servlet action
threw exception
javax.servlet.ServletException: Servlet.init() for servlet action threw
exception
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:94
6)
Here is my StartupInitServlet code:
package ca.gc.ec.sitegenerator.servlets;
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.*;
import java.util.*;
import java.util.MissingResourceException;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.util.MessageResources;
import org.apache.struts.action.Action;
import org.jdom.*;
import org.jdom.output.*;
import org.jdom.input.*;
import org.xml.sax.*;
import org.apache.log4j.*;
import ca.gc.ec.sitegenerator.util.OptionLabelValue;
import ca.gc.ec.sitegenerator.resource.Constants;
import ca.gc.ec.sitegenerator.user.*;
import ca.gc.ec.sitegenerator.project.*;
import ca.gc.ec.sitegenerator.lf.*;
import ca.gc.ec.sitegenerator.publisher.*;
import ca.gc.ec.sitegenerator.mail.*;
import ca.gc.ec.sitegenerator.resource.*;
public final class StartupInitServlet extends HttpServlet {
public final static String CONFIG_FILE_PATH =
"/WEB-INF/config/config.xml";
public final static String XSLT_PROCESSOR =
"com.icl.saxon.TransformerFactoryImpl";
private static Logger logger =
Logger.getLogger(StartupInitServlet.class);
private int debug = 0;
private String pathname = null;
private MessageResources messages = null;
private ServletContext servletContext = null;
public void destroy() {
if (debug >= 1) {
log("Finalizing database servlet");
}
}
public void init() throws ServletException {
String value = getServletConfig().getInitParameter("debug");
servletContext = getServletContext();
messages = (MessageResources)
servletContext.getAttribute(Action.MESSAGES_KEY);
try {
debug = Integer.parseInt(value);
} catch (Throwable t) {
debug = 0;
}
if (debug >= 1) {
log("Initializing database servlet");
}
setConfigurationInfo();
setExportList();
}
public int getDebug() {
return debug;
}
public void setDBPath() {
/*pathname = getServletContext().getRealPath("/") +
"WEB-INF" + File.separator + "db"; */
/*pathname = getServletContext().getRealPath("/")+ "db";
servletContext.setAttribute(Constants.DB_PATH_ROOT_KEY,
pathname);
servletContext.setAttribute(Constants.RELATIVE_DB_PATH_ROOT_KEY, "db");
*/
}
/**
* Reads the config.xml file, converts into JDOM tree and saves it
in app context
* --- if the file is not found error is thrown
*/
public void setConfigurationInfo() {
System.setProperty(
"javax.xml.transform.TransformerFactory",
XSLT_PROCESSOR);
try {
InputStream is =
getServletContext().getResourceAsStream(CONFIG_FILE_PATH);
if (is == null) {
log("StartupInitServlet: inputStream for
config file is null");
} else {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(is);
servletContext.setAttribute(
Constants.CONFIG_PARAMS_KEY,
doc.getRootElement());
is.close();
}
} catch (JDOMException e) {
logger.fatal("Configuartion Properties cannot be
loaded", e);
} catch (IOException e) {
logger.fatal("Configuartion Properties cannot be
loaded", e);
}
}
/**
* Sets up the list that would contain exporters from various
sessions and then
* starts up the cleaner thread.
*/
public void setExportList() {
Vector exportList = new Vector();
servletContext.setAttribute(Constants.EXPORT_THREAD_LIST,
exportList);
// sleepTime = 1 Hour, disposalTime = 30 min or older
CleanerThread cleaner =
new CleanerThread(exportList, 1000 * 60 * 60, 1000 *
60 * 30);
servletContext.setAttribute(Constants.EXPORT_LIST_CLEANER,
cleaner);
cleaner.start();
}
}
//end StartupInitServlet class
-----Original Message-----
From: David Graham [mailto:dgraham1980@hotmail.com]
Sent: Thursday, March 13, 2003 5:32 PM
To: struts-user@jakarta.apache.org
Subject: Re: java.lang.NoClassDefFoundError:
org/apache/struts/action/ActionMessage
NoClassDefFoundError almost always means you have struts.jar on Tomcat's
classpath. struts.jar should *only* live in each project's /WEB-INF/lib
directory.
David
>From: "Sinkinson,Andrew [NCR]" <An...@ec.gc.ca>
>Reply-To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>To: 'Struts Users Mailing List' <st...@jakarta.apache.org>
>Subject: java.lang.NoClassDefFoundError:
>org/apache/struts/action/ActionMessage
>Date: Thu, 13 Mar 2003 15:55:05 -0500
>
>
>I'm using Tomcat 4.06 and Struts 1.1b I am getting the following error
>below. I am trying to use message resources. I think the problem is that
>I am missing the configuration for ActionMessage in web.xml or
>Struts_config.xml. Any help would be greatly appreciated.
>
>
>StandardWrapper[/sitegenerator:default]: Loading container servlet default
>2003-03-13 15:29:40,948 ERROR [main] util.MessageResourcesFactory
>(MessageResourcesFactory.java:174) - MessageResourcesFactory.createFactory
>java.lang.NoClassDefFoundError: org/apache/struts/action/ActionMessage
> at
>org.apache.struts.util.MessageResourcesFactory.createFactory(MessageResourc
e
>sFactory.java:169)
> at
>org.apache.struts.util.MessageResources.getMessageResources(MessageResource
s
>.java:557)
> at
>org.apache.struts.action.ActionServlet.initInternal(ActionServlet.java:989)
> at
>org.apache.struts.action.ActionServlet.init(ActionServlet.java:411)
> at javax.servlet.GenericServlet.init(GenericServlet.java:258)
> at
>org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:9
1
>8)
> at
>org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:810)
> at
>org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java
:
>3279)
> at
>org.apache.catalina.core.StandardContext.start(StandardContext.java:3421)
> at
>org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
> at
>org.apache.catalina.core.StandardHost.start(StandardHost.java:638)
> at
>org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
> at
>org.apache.catalina.core.StandardEngine.start(StandardEngine.java:343)
> at
>org.apache.catalina.core.StandardService.start(StandardService.java:388)
> at
>org.apache.catalina.core.StandardServer.start(StandardServer.java:506)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:781)
> at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
> at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Nat
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org