Java

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentJava

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old April 28th, 2010, 10:48 AM
Preethi_Reddy Preethi_Reddy is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2010
Posts: 1 Preethi_Reddy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 49 sec
Reputation Power: 0
Digester Errors parsing web.xml

I'm using weblogic server, struts framework.

When I try yo parse the web.xml using org.apache.commons.digester.Digester using this code

public void setServletConfigFile(String pathname) {
URL url = null;
HttpSession session = this.getSession();
context1 = (ServletContextSimulator) session.getServletContext();
Digester digester1 = new Digester();
digester1.push(this.config);
digester1.setValidating(false);
digester1.addCallMethod("web-app/servlet/init-param", "setInitParameter", 2);
digester1.addCallParam("web-app/servlet/init-param/param-name", 0);
digester1.addCallParam("web-app/servlet/init-param/param-value", 1);
try {

try{
for (int i = 0; i < registrations.length; i += 2) {
try{
url = context1.getResource(registrations[i + 1]);
System.out.println("url is " + url);
} catch (Throwable t){
System.out.println(registrations[i+1]);
System.out.println("url is " + url);
System.out.println("there was an error in the registrations ------- "+ t.getMessage() );
t.printStackTrace();
}
if (url != null)

digester1.register(registrations[i], url.toString());

}
}catch (Exception e){
System.out.println("there was an error in the registrations "+ e.getMessage() );
}


InputStream input = null;
try{
input = context1.getResourceAsStream(pathname);
} catch (Exception e){
System.out.println("there was an error the context1.getResourceAsStream(pathname) " + e.getMessage());
}

if(input == null)
throw new AssertionFailedError("Invalid pathname: " + pathname);
try{
digester1.parse(input);
}catch (SAXException spe) {
// Error generated by the parser
System.out.println("\n** Parsing error"
+ ", Message " + spe.getMessage());
// + ", uri " + ;
System.out.println(" " + spe.getMessage() );

} catch (Throwable t) {
t.printStackTrace();
}

input.close();
} catch (Exception e) {
throw new AssertionFailedError("Received an exception while loading web.xml - " + e.getClass() + " : " + e.getMessage());
}
}



It fails to parse with the following error.


java.lang.NullPointerException
at org.apache.commons.digester.Digester.getXMLReader( Digester.java:1058)
at org.apache.commons.digester.Digester.parse(Digeste r.java:1887)
at dep.wrm.srf.tests.SRFStrutsTestCase.setServletConf igFile(SRFStrutsTestCase.java:212)
at dep.wrm.srf.tests.SRFStrutsTestCase.setUp(SRFStrut sTestCase.java:103)
at dep.wrm.srf.tests.FilterAction1Test.setUp(FilterAc tion1Test.java:26)
at junit.framework.TestCase.runBare(TestCase.java:125 )
at junit.framework.TestResult$1.protect(TestResult.ja va:106)
at junit.framework.TestResult.runProtected(TestResult .java:124)
at junit.framework.TestResult.run(TestResult.java:109 )
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
at junit.framework.TestSuite.run(TestSuite.java:203)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.junit.JUnitTestSet.execu te(JUnitTestSet.java:213)
at org.apache.maven.surefire.suite.AbstractDirectoryT estSuite.executeTestSet(AbstractDirectoryTestSuite .java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryT estSuite.execute(AbstractDirectoryTestSuite.java:1 27)
at org.apache.maven.surefire.Surefire.run(Surefire.ja va:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.ru nSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.ma in(SurefireBooter.java:1009)


Any help is greatly appreciated.
ThanK you

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentJava > Digester Errors parsing web.xml


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap