The moose likes Struts and the fly likes Struts Plugins Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Plugins" Watch "Struts Plugins" New topic

Struts Plugins

Ashish Nandan

Joined: Jun 03, 2009
Posts: 22
I am trying to create a plugin in struts 1.3 (I am a newbie to struts) but am getting following error

------>The Plugin is starting<--------- .\WebContent\WEB-INF\props.txt (The system cannot find the path specified)
at Method)
at ch04.WroxPlugin.init(
at org.apache.struts.action.ActionServlet.initModulePlugIns(
at org.apache.struts.action.ActionServlet.init(
at javax.servlet.GenericServlet.init(
at org.apache.catalina.core.StandardWrapper.loadServlet(
at org.apache.catalina.core.StandardWrapper.load(
at org.apache.catalina.core.StandardContext.loadOnStartup(
at org.apache.catalina.core.StandardContext.start(
at org.apache.catalina.core.StandardContext.reload(
at org.apache.catalina.loader.WebappLoader.backgroundProcess(
at org.apache.catalina.core.ContainerBase.backgroundProcess(
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(
at org.apache.catalina.core.ContainerBase$
Jun 16, 2009 6:44:31 PM org.apache.catalina.loader.WebappClassLoader modified
INFO: Additional JARs have been added
------>Plugin Stopped<---------

here is my code

package ch04;

import java.util.Properties;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;

public class WroxPlugin implements PlugIn {

public static final String PROPERTIES = "PROPERTIES";

public void init(ActionServlet servlet, ModuleConfig config)
throws ServletException {

System.err.println("------>The Plugin is starting<---------");
Properties properties = new Properties();

try {
File file = new File("./WebContent/WEB-INF/props.txt");

FileInputStream fis = new FileInputStream(file);


ServletContext context = servlet.getServletContext();
context.setAttribute(PROPERTIES, properties);
} catch (FileNotFoundException fnfe) {
} catch (IOException ioe) {
throw new ServletException(ioe.getMessage());

public void destroy(){
System.err.println("------>Plugin Stopped<---------");


my file is situated at Webcontent/Web-Inf/props.txt

Any help will be hugely appreciated

Ashish Nandan
David Newton

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags.Those are different directories. That aside, if you're attempting to access a file relative to the application context you need to get the real path and build your filename from that.
I agree. Here's the link:
subject: Struts Plugins
It's not a secret anymore!