[jboss-user] [Beginners Corner] - Digester problem...ClassNotFoundException

desenho do-not-reply at jboss.com
Thu Apr 3 17:41:01 EDT 2008


Hi all, 

I have a problem using the class com.sun.org.apache.commons.digester.Digester:


  | public class HibernateConfig {
  |          private String name;
  | 
  |          public String getName() {
  |                  return name;
  |          }
  | 
  |          public void setName(String name) {
  |                  this.name = name;
  |          }
  | }

And this method in another class

  | public Configuration digest() throws MappingException, ClassNotFoundException, IOException, SAXException {
  | 		Digester digester = new Digester();
  | 		
  | 		digester.push(this);
  | 		
  | 		digester.addObjectCreate("classes/class", br.com.ze.configuration.HibernateConfig.class);
  | 		digester.addBeanPropertySetter("classes/class/name");
  | 		
  | 		digester.addSetNext("classes/class", "addClass");
  | 		
  | 		HibernateConfigurationApplier hconf = null;
  | 		if(xmlClassesConfigFile != null)
  | 			hconf = (HibernateConfigurationApplier) digester.parse(xmlClassesConfigFile);
  | 		else
  | 			hconf = (HibernateConfigurationApplier) digester.parse(xmlClassesConfigInputStream);
  | 
  | 		Configuration configuration = new Configuration();
  | 		
  | 		for(HibernateConfig clazz: hconf.classes)
  | 			configuration.addClass( Class.forName(clazz.getName()) );
  | 		
  | 		return configuration.configure();
  | 	}
  | 

And the following XML file:

  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <classes>
  | 	<class>
  | 		<name>br.com.ze.common.model.Banco</name>
  | 	</class>
  | 	<class>
  | 		<name>br.com.ze.common.model.Contrato</name>
  | 	</class>
  | 	<class>
  | 		<name>br.com.ze.common.model.Produto</name>
  | 	</class>
  | 	<class>
  | 		<name>br.com.ze.common.model.Segmento</name>
  | 	</class>
  | </classes>
  | 

When I execute the following:

  | public static void main(String[] args) throws MappingException, FileNotFoundException, ClassNotFoundException, IOException, SAXException {
  | 	Configuration conf = new HibernateConfigurationApplier("WebContent/WEB-INF/persistent-classes.xml").digest();
  | }
  | 

It runs just fine, but when I execute the same line in a javax.servlet.Filter I´ve done:

  | public void init(FilterConfig filterConfig) throws ServletException {
  | 		Configuration config;
  | 		try {
  | 			config = new HibernateConfigurationApplier(filterConfig.getServletContext().getResourceAsStream("WEB-INF/persistent-classes.xml")).digest();
  | 		} catch (Exception e) {
  | 			throw new ServletException(e);
  | 		}
  | }
  | 

I get this exception:
anonymous wrote : 
  | java.lang.ClassNotFoundException: No ClassLoaders found for: br.com.ze.configuration.HibernateConfig
  | 	at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212)
  | 	at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
  | 	at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
  | at java.lang.ClassLoader.loadClass(Unknown Source)
  | 	at com.sun.org.apache.commons.digester.ObjectCreateRule.begin(ObjectCreateRule.java:252)
  | 	at com.sun.org.apache.commons.digester.Rule.begin(Rule.java:200)
  | 	at com.sun.org.apache.commons.digester.Digester.startElement(Digester.java:1273)
  | 	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
  | .
  | .
  | .
  | 

The exception is thrown at digester.parse()

I´m using Eclipse Europa, JAVA 6 and JBOSS 4.2.2

Any help??!?!?!
Thanks in advance.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4141509#4141509

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4141509




More information about the jboss-user mailing list