Many thanks for those that have replied to my earlier emails for
help... Hopefully once I get this one figured out I'll be on the way
to getting my perl to Struts conversion complete... FYI... I've taken
the time to migrate from Struts v1.1 to v1.2.9 so this issue is
based on that code base.
Part of the app I'm converting already had some Java/Struts v1.1
code. Some of that code included some custom plugins which worked as
expected with v1.1. Here's the snippet from the struts-config.xml
file that defines a plugin:
<plug-in className="com.sun.myPlugin.plugins.LoggingPlugin">
<set-property property="logging.config.file"
value="/WEB-INF/classes/logging-config.xml"/>
</plug-in>
Here's the actual custom plugin:
package com.sun.myPlugin.plugins;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.PlugInConfig;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.config.impl.ModuleConfigImpl;
import javax.servlet.ServletException;
import javax.xml.parsers.FactoryConfigurationError;
import org.apache.log4j.Logger;
import org.apache.log4j.LogManager;
import org.apache.log4j.xml.DOMConfigurator;
/**
* Plugin for initializing logging for the SS-CDS implementation. Will
configure
* logging for the entire VM for a given logging API implementation.
*/
public abstract class LoggingPlugin implements PlugIn {
private final static String DEFAULT_CONFIG_FILE = "/sso/
myPlugin6/WEB-INF/classes/logging-config.xml";
private final Logger log_ = LogManager.getLogger(getClass());
/** Creates a new instance of LoggingPlugin */
public LoggingPlugin() {
}
/**
* Attempt to finalize the logging component before system
shutdown. Basically
* we're trying to get complete log files before shutdown. In
the case of
* an XMLFormatter, this is necessary to try to get complete XML
output in
* the log file. Will help with reading the log file output.
*/
public void destroy() {
log_.info("Finalizing log4j.");
try {
// attempt to finalize logging
LogManager.shutdown();
}
catch (Exception ignore) {
// unable to finalize logging, may have
// corrupt or incomplete log files
}
}
/**
* Initialize the plugin. Reads the configuration file from the
file system
* and attempts to configure log4j using that file.
*/
public void init(ActionServlet actionServlet, ModuleConfigImpl
applicationConfig) throws ServletException {
log_.info(" start initializing the Log4j");
//get the log configuration file
PlugInConfig[] configs = applicationConfig.findPlugInConfigs();
String configFile = DEFAULT_CONFIG_FILE;
// obtain the configuration file information from the plug-in
// if no file is defined, an error will be generated and
logging will not
// be configured for this system.
// See the Struts Configuration file (struts-config.xml) and
the struts
// api documentation for instructions on how to define
plugins and
// properties on plugins.
for(int i = 0; i < configs.length; i ++) {
if(configs[i].getClassName().equals(this.getClass
().getName())) {
configFile = (String)configs[i].getProperties().get
("logging.config.file");
}
}
if (configFile == null || configFile.length() ==0) {
String msg = "log configuration file name (" +
configFile + ") is not in configuration file";
log_.fatal(msg);
throw new ServletException(msg);
}
//get the real path by concatenating the web xml directory
String fullName = actionServlet.getServletContext
().getRealPath("/") + configFile;
//Configure log4j
try {
DOMConfigurator.configure(fullName);
}
catch( FactoryConfigurationError fce) {
System.out.println("Unable to configure log4j error is");
fce.printStackTrace(System.out);
throw new ServletException("DOMConfiguration failed");
}
log_.info(" finished initializing the Log4j");
}
}
And here's the error(s) when starting the app:
failure: WEB2798: [] ServletContext.log(): action: null
java.lang.InstantiationException
at
sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance
(InstantiationExceptionConstructorAccessorImpl.java:30)
at java.lang.reflect.Constructor.newInstance
(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at org.apache.struts.util.RequestUtils.applicationInstance
(RequestUtils.java:143)
at org.apache.struts.action.ActionServlet.initModulePlugIns
(ActionServlet.java:846)
at org.apache.struts.action.ActionServlet.init
(ActionServlet.java:336)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet
(StandardWrapper.java:921)
at org.apache.catalina.core.StandardWrapper.load
(StandardWrapper.java:813)
at org.apache.catalina.core.StandardContext.loadOnStartup
(StandardContext.java:3478)
at org.apache.catalina.core.StandardContext.start
(StandardContext.java:3760)
at com.iplanet.ias.web.WebModule.start(WebModule.java:251)
at org.apache.catalina.core.ContainerBase.start
(ContainerBase.java:1133)
at org.apache.catalina.core.StandardHost.start
(StandardHost.java:652)
at org.apache.catalina.core.ContainerBase.start
(ContainerBase.java:1133)
at org.apache.catalina.core.StandardEngine.start
(StandardEngine.java:355)
at org.apache.catalina.startup.Embedded.start(Embedded.java:
995)
at com.iplanet.ias.web.WebContainer.start(WebContainer.java:
431)
at com.iplanet.ias.web.WebContainer.startInstance
(WebContainer.java:500)
at com.iplanet.ias.server.J2EERunner.confPostInit
(J2EERunner.java:161)
warning: StandardWrapper[:action]: WEB2795: Marking servlet action as
unavailable
failure: WebModule[]: WEB2783: Servlet threw load() exception
javax.servlet.UnavailableException
at org.apache.struts.action.ActionServlet.initModulePlugIns
(ActionServlet.java:880)
at org.apache.struts.action.ActionServlet.init
(ActionServlet.java:336)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet
(StandardWrapper.java:921)
at org.apache.catalina.core.StandardWrapper.load
(StandardWrapper.java:813)
at org.apache.catalina.core.StandardContext.loadOnStartup
(StandardContext.java:3478)
at org.apache.catalina.core.StandardContext.start
(StandardContext.java:3760)
at com.iplanet.ias.web.WebModule.start(WebModule.java:251)
at org.apache.catalina.core.ContainerBase.start
(ContainerBase.java:1133)
at org.apache.catalina.core.StandardHost.start
(StandardHost.java:652)
at org.apache.catalina.core.ContainerBase.start
(ContainerBase.java:1133)
at org.apache.catalina.core.StandardEngine.start
(StandardEngine.java:355)
at org.apache.catalina.startup.Embedded.start(Embedded.java:
995)
at com.iplanet.ias.web.WebContainer.start(WebContainer.java:
431)
at com.iplanet.ias.web.WebContainer.startInstance
(WebContainer.java:500)
at com.iplanet.ias.server.J2EERunner.confPostInit
(J2EERunner.java:161)
I found a Struts web site earlier that talks about migrating to
different versions, but I'll need to track it down again. Once I find
it I'll start reading there to seed if there is something concerning
this. But, any pointers this fine alias could pass on would be
appreciated.
Thanks, ajTreece
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]