struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukas_oesterreic...@sonynetservices.com
Subject can't find out why the digester doesnt find method in class
Date Tue, 17 Dec 2002 10:33:10 GMT
Hi there.

I'm using the struts digester to load some configuration parameters from an
xml file.
The digester source is:

Digester dig = new Digester();
dig.push(this);
dig.setValidating(false);
// log file configuration

dig.addObjectCreate("mls-config/logconfigfile",
"net.morkeleb.mls.type.ConfigParam");
dig.addSetProperties("mls-config/logconfigfile");
dig.addSetNext("mls-config/logconfigfile", "setLogConfigFile");

// create database config data
dig.addObjectCreate("mls-config/database",
"net.morkeleb.mls.type.DatabaseConfig");
//dig.addSetProperties("mls-config/database"); i guess i dont need this
here, but makes no change to exception
dig.addCallMethod("mls-config/database/driver", "setDriver", 0);
dig.addCallMethod("mls-config/database/url", "setURL", 0);
dig.addCallMethod("mls-config/database/user", "setUser", 0);
dig.addCallMethod("mls-config/database/password", "setPassword", 0);
dig.addCallMethod("mls-config/database/max-connections",
"setMaxConnections", 0);
dig.addCallMethod("mls-config/database/idle-timeout", "setIdleTimeout", 0);
dig.addCallMethod("mls-config/database/checkout-timeout",
"setCheckoutTimeout", 0);
dig.addCallMethod("mls-config/database/max-checkout", "setMaxCheckout", 0);
dig.addCallMethod("mls-config/database/monitoring-level",
"setMonitoringLevel", 0);
dig.addSetNext("mls-config/database", "configDatabase");

// let's start parsing
dig.parse(bis);
//close stream
bis.close();

The logconfigfile part goes well but the database part doesnt, with the
first method (setDriver) it tries
to call. Here's the class DatabaseConfig:

package net.morkeleb.mls.type;

import net.morkeleb.mls.tools.MLSLogger;

public class DatabaseConfig {

      private String m_strDriver = "";
      private String m_strUrl = "";
      private String m_strUser = "";
      private String m_strPassword = "";

      private int m_iMaxConn = 0;
      private int m_iIdleTimeout = 0;
      private int m_iCheckoutTimeout = 0;
      private int m_iMaxCheckout = 0;
      private int m_iMonitoringLevel = 0;

      public DatabaseConfig() {}

      // database driver
      public void setDriver(String strDriver) {
            //MLSLogger.debug("setting Driver");
            m_strDriver = strDriver;
      }

      public String getDriver() {
            return m_strDriver;
      }

      // database url
      public void setURL(String strUrl) {
            //MLSLogger.debug("setting URL");
            m_strUrl = strUrl;
      }

      public String getURL() {
            return m_strUrl;
      }

      // databse user
      public void setUser(String strUser) {
            //MLSLogger.debug("setting User");
            m_strUser = strUser;
      }

      public String getUser() {
            return m_strUser;
      }

      // database password
      public void setPassword(String strPassword) {
            //MLSLogger.debug("setting Password");
            m_strPassword = strPassword;
      }

      public String getPassword() {
            return m_strPassword;
      }


      // database max connections
      public void setMaxConnections(String strMaxCon) {
            //MLSLogger.debug("setting MaxConnections");
            try {
                  m_iMaxConn = (new Integer(strMaxCon)).intValue();
            } catch (NumberFormatException exc) {
                  exc.printStackTrace();
            }
      }

      public int getMaxConnections(){
            return m_iMaxConn;
      }

      // database idle timeout
      public void setIdleTimeout(String strIdleTimeout) {
            //MLSLogger.debug("setting IdleTimeout");
            try {
                  m_iIdleTimeout = (new Integer(strIdleTimeout)).intValue
();
            } catch (NumberFormatException exc) {
                  exc.printStackTrace();
            }
      }

      public int getIdleTimeout(){
            return m_iIdleTimeout;
      }

      // database checkout timeout
      public void setCheckoutTimeout(String strCheckoutTimeout) {
            //MLSLogger.debug("setting CheckoutTimeout");
            try {
                  m_iCheckoutTimeout = (new
Integer(strCheckoutTimeout)).intValue();
            } catch (NumberFormatException exc) {
                  exc.printStackTrace();
            }
      }

      public int getCheckoutTimeout(){
            return m_iCheckoutTimeout;
      }

      // database max checkout
      public void setMaxCheckout(String strMaxCheckout) {
            //MLSLogger.debug("setting MaxCheckout");
            try {
                  m_iMaxCheckout = (new Integer(strMaxCheckout)).intValue
();
            } catch (NumberFormatException exc) {
                  exc.printStackTrace();
            }
      }

      public int getMaxCheckout(){
            return m_iMaxCheckout;
      }

      // database monitoring level
      public void setMonitoringLevel(String strMonitoringLevel) {
            //MLSLogger.debug("setting MonitoringLevel");
            try {
                  m_iMonitoringLevel = (new
Integer(strMonitoringLevel)).intValue();
            } catch (NumberFormatException exc) {
                  exc.printStackTrace();
            }
      }

      public int getMonitoringLevel(){
            return m_iMonitoringLevel;
      }
}

and here's the method which it passes this class to:

// called by digester
public void configDatabase(DatabaseConfig db) {
      JDBCConnectionManager.setDatabaseConfig(db.getDriver(), db.getURL(),
db.getUser(), db.getPassword(),
                                          db.getMaxConnections(),
db.getIdleTimeout(), db.getCheckoutTimeout(),
                                          db.getMaxCheckout(),
db.getMonitoringLevel());
}

and this is the xml file:

<?xml version="1.0" encoding="UTF-8"?>
<mls-config>
      <logconfigfile value="/WEB-INF/log-config.xml"/>
      <database>
            <driver>oracle.jdbc.driver.OracleDriver</driver>
            <url>dburl</url>
            <user>dbuser</user>
            <password>dbpassword</password>
            <max-connections>10</max-connections>
            <idle-timeout>300</idle-timeout>
            <checkout-timeout>120</checkout-timeout>
            <max-checkout>12</max-checkout>
            <monitoring-level>300</monitoring-level>
      </database>
</mls-config>

and here is what it throws:

MLS LogConfigFile: /usr/java/tomcat/webapps/mls/WEB-INF/log-config.xml
End event threw exception
java.lang.NoSuchMethodException
        at java.lang.Class.getMethod0(Native Method)
        at java.lang.Class.getMethod(Class.java:888)
        at
org.apache.struts.digester.CallMethodRule.end(CallMethodRule.java:280)
        at
org.apache.struts.digester.Digester.endElement(Digester.java:379)
        at
org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1392)
        at
org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1180)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1256)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:952)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:143)
        at org.apache.struts.digester.Digester.parse(Digester.java:716)
        at net.morkeleb.mls.MLSInitServlet.init(MLSInitServlet.java:77)
        at javax.servlet.GenericServlet.init(GenericServlet.java:258)
        at
org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
        at org.apache.tomcat.core.Handler.init(Handler.java:215)
        at
org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:296)
        at
org.apache.tomcat.context.LoadOnStartupInterceptor.contextInit(LoadOnStartupInterceptor.java:130)
        at
org.apache.tomcat.core.ContextManager.initContext(ContextManager.java:491)
        at
org.apache.tomcat.core.ContextManager.init(ContextManager.java:453)
        at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:195)
        at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)
MLS Error: Error in mls-config xml-file: null
java.lang.NoSuchMethodException
        at
org.apache.struts.digester.Digester.endElement(Digester.java:382)
        at
org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1392)
        at
org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1180)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1256)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:952)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:143)
        at org.apache.struts.digester.Digester.parse(Digester.java:716)
        at net.morkeleb.mls.MLSInitServlet.init(MLSInitServlet.java:77)
        at javax.servlet.GenericServlet.init(GenericServlet.java:258)
        at
org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
        at org.apache.tomcat.core.Handler.init(Handler.java:215)
        at
org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:296)
        at
org.apache.tomcat.context.LoadOnStartupInterceptor.contextInit(LoadOnStartupInterceptor.java:130)
        at
org.apache.tomcat.core.ContextManager.initContext(ContextManager.java:491)
        at
org.apache.tomcat.core.ContextManager.init(ContextManager.java:453)
        at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:195)
        at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

This runs on a tomcat 3 server, but i've also tried on tomcat 4, where the
exception is slightly different,
but the problem is ofcourse the same.

Do you have an idea why this does not work?
I have copied some of the sources from another project where it works,
and looked through the digester documentation where i quite well follow
how it's ought to be done.

Thank you in advance,
Lukas


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message