Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Log4j, MalformedURLException: no protocol: log4j.dtd

 
Ranch Hand
Posts: 427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using
Jakarta Log4j version 1.2.7
Xerces-J version 2.0.2
I have a configuration file called log4j.xml
The first two lines of log4j.xml are:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
When I invoke
LogFactory.getLog(java.lang.Class)
I observe an exception.
This is the exception stack trace:
java.net.MalformedURLException: no protocol: log4j.dtd
java.lang.Throwable(java.lang.String)
java.lang.Exception(java.lang.String)
java.io.IOException(java.lang.String)
java.net.MalformedURLException(java.lang.String)
java.net.URL(java.net.URL, java.lang.String,
java.net.URLStreamHandler)
java.net.URL(java.net.URL, java.lang.String)
java.net.URL(java.lang.String)
void
org.apache.xerces.impl.XMLEntityManager.startEntity(java.lang.String,
org.apache.xerces.xni.parser.XMLInputSource, boolean, boolean)
void
org.apache.xerces.impl.XMLEntityManager.startDTDEntity(org.apache.xerces.xni
.parser.XMLInputSource)
void
org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(org.apache.xerces.xn
i.parser.XMLInputSource)
boolean
org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(boolean
)
boolean
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(boolean)
boolean org.apache.xerces.parsers.DTDConfiguration.parse(boolean)
void
org.apache.xerces.parsers.DTDConfiguration.parse(org.apache.xerces.xni.parse
r.XMLInputSource)
void
org.apache.xerces.parsers.XMLParser.parse(org.apache.xerces.xni.parser.XMLIn
putSource)
void
org.apache.xerces.parsers.DOMParser.parse(org.xml.sax.InputSource)
org.w3c.dom.Document
org.apache.xerces.jaxp.DocumentBuilderImpl.parse(org.xml.sax.InputSource)
void
org.apache.log4j.xml.DOMConfigurator.doConfigure(org.xml.sax.InputSource,
org.apache.log4j.spi.LoggerRepository)
void
org.apache.log4j.xml.DOMConfigurator.doConfigure(java.io.InputStream,
org.apache.log4j.spi.LoggerRepository)
void org.apache.log4j.xml.DOMConfigurator.doConfigure(java.net.URL,
org.apache.log4j.spi.LoggerRepository)
void
org.apache.log4j.helpers.OptionConverter.selectAndConfigure(java.net.URL,
java.lang.String, org.apache.log4j.spi.LoggerRepository)
org.apache.log4j.Category
org.apache.log4j.Category.getInstance(java.lang.Class)
org.apache.log4j.Category
org.apache.log4j.Category.getInstance(java.lang.Class)
org.apache.commons.logging.Log
org.apache.commons.logging.impl.Log4jFactory.getInstance(java.lang.Class)
org.apache.commons.logging.Log
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(java.lang.Class)
org.apache.commons.logging.Log
org.apache.commons.logging.LogFactory.getLog(java.lang.Class)
How do I fix this?
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean
At some point it's trying to do a

which makes no sense, hence the error.
Your <!DOCTYPE log4j.dtd> line isn't in a url format, you could try file:///tmp/log4j.dtd or wherever it is instead of just log4j.dtd (or host it on a web server and use http:// if you want your dtd to be in a single place.
L
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also am getting a similar error. But by a different route.

The error is:
java.net.MalformedURLException: no protocol: <?xml version="1.0"?>

the error message e that is returned, is the XML input.

I am using the following to attempt to parse the XML input:

String dhlResponse = "The XML response from the web service";

the handler is just that, if it finds a particular tag it stores it in a stringBuffer.

try {
factory = SAXParserFactory.newInstance();
saxParser = factory.newSAXParser();
} catch (Exception e) {
System.out.println("In ShipmentTrackingAction.execute - " + e);
}


saxParser.parse(dhlResponse, handler);

Can we get to some conclusion by this?

edwyn@berrey.com
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!