Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Plugin init method is not called

 
as chhipa
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
I create struts plugin from Profession Jakarta Struts 1.1. I also have replaced ApplicationConfig with ModuleConfig as ApplicationConfig has been deprecated. After the changes my program is as follwing

package ch03;
import java.util.Properties;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

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

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

public class WroxPlugin implements PlugIn
{
public WroxPlugin(){}
public void init(ActionServlet servlet, ModuleConfig applicationConfig) throws javax.servlet.ServletException
{
System.out.println("--------The Plugin is starting");
Properties properties =new Properties();
try
{
File file=new File("db.properties");
FileInputStream fis=new FileInputStream(file);
properties.load(fis);
ServletContext context=servlet.getServletContext();
context.setAttribute("PROPERTIES",properties);

}
catch(FileNotFoundException fnfe)
{
throw new ServletException(fnfe.getMessage());
}
catch(IOException ioe)
{
throw new ServletException(ioe.getMessage());
}
}
public void destroy()
{
System.out.println("----- THe Plugin is stopping------");
}
}


plug in entry in struts-config file is as follwing

<plg-in className="ch03.WroxPlugin" />

But when I restart the tomcat and start the application I dont find the --------The Plugin is starting message on Tomcat console.

The tomcat version is 4.1.31
THe java version is j2sdk1.4.2

Can any body suggest any alternative to call the plaugin init method
Thanks
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change:

<plg-in className="ch03.WroxPlugin" />

to

<plug-in className="ch03.WroxPlugin" />
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic