My code is something like:
public static void transform(InputStream in, Source xslt, OutputStream out) throws TransformerException {
//com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer t = tFactory.newTransformer(xslt);
Source xmlSource = new StreamSource(in);
Result outResult = new StreamResult(out);
t.transform(xmlSource, outResult);
}
And when I try to transform my xml:
java.net.MalformedURLException
ERROR: 'Cannot compile stylesheet'
CRITICAL ERROR: 'java.net.MalformedURLException'
:null
javax.xml.transform.TransformerConfigurationException: java.net.MalformedURLException
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(Unknown Source)
at it.unimaticaspa.digipark.utils.XmlUtils.transform(XmlUtils.java:42)
at it.unimaticaspa.digipark.utils.XmlUtilsTest.testTransform(XmlUtilsTest.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.net.MalformedURLException
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source)
... 27 more
Caused by: java.lang.NullPointerException
... 41 more
at the line:
tFactory.newTransformer(xslt);
I think it's about the fact that both xml and xslt declare namespaces that didn't point to an existing xsd, so i thought to disable the validation of the schema, and i saw the function setAttribute and setFeature, but i can't find any working example, or a list of attributes/features available.
Debugging the code i found that the implementation class of the xml transformer is:
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
-- edit --
As suggested I post my files also:
xml:
<?xml version="1.0" encoding="utf-8"?>
<test:Root xmlns:test="http://www.mysite.it/test/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mysite.it/test/xsdTest.xsd">
<test:Branch>
<test:Leaf>someValue1</test:Leaf>
</test:Branch>
<test:Branch>
<test:Leaf>someValue2</test:Leaf>
<test:Leaf>someValue3</test:Leaf>
</test:Branch>
<test:Branch>
<test:Sub-Branch>
<test:Leaf>someValue4</test:Leaf>
</test:Sub-Branch>
<test:Leaf>someValue5</test:Leaf>
</test:Branch>
</test:Root>
xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
xmlns:test="http://www.mysite.it/test/"
xsi:schemaLocation="http://www.unimaticaspa.it/test/xsdTest.xsd">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="test:Root">
<sincro:IdC xmlns:sincro="http://www.uni.com/U3011/sincro/"
xmlns:somenamespace="http://www.mysite.it/mysite-metadata/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.uni.com/U3011sincro/IdC.xsd http://www.mysite.it/mysite-metadata/Metadata.xsd"
sincro:url="http://www.uni.com/U3011/sincro/"
sincro:version="1.0">
<sincro:VdC>
<sincro:ID sincro:scheme="local">asd</sincro:ID>
</sincro:VdC>
<xsl:for-each select="test:Branch">
<sincro:FileGroup>
<sincro:File sincro:encoding="BASE64" sincro:format="TXT">
<sincro:ID>asd</sincro:ID>
<sincro:MoreInfo sincro:XMLScheme="http://www.mysite.it/mysite-metadata/Metadata.xsd">
<sincro:EmbeddedMetadata>
<somenamespace:Metadata>
<somenamespace:mytag>asd</somenamespace:mytag>
</somenamespace:Metadata>
</sincro:EmbeddedMetadata>
</sincro:MoreInfo>
</sincro:File>
</sincro:FileGroup>
</xsl:for-each>
</sincro:IdC>
</xsl:template>
</xsl:stylesheet>
-- EDIT --
added missing declaration: xsi:schemaLocation on tag xsl:stylesheet.
Still doesn't work, it keep giving the same error.
I tried to run my xslt with XMLSpy and it worked fine, i really think that the problem is on the TransformerFactory Configuration.
This is probably because the XSLT Source (system id) is defined by an URL earlier in the code. This URL is malformed (or null maybe, hence null pointer exception in the stacktrace).
XML Namespace names don't have to point to XSDs, or indeed point to anything. They do have to be syntactically correct URIs, and if they're URLs they have to be absolute URLs rather than relative. You haven't shown us your stylesheet, but that's the first thing to look at fixing.
EDITED TO ADD:
Looking at what you've shown us (in the comments on this answer), one error jumps out immediately:
xmlns:test="mysite.it/test/";
Wrong. Namespace names must be absolute URIs, not relative. Change it to
xmlns:test="http://mysite.it/test/";
Also, the semicolons don't belong there. Remove them, and review proper XML syntax.
Related
I am a new to Selenium, running my first TestNG with configured ReportNG. I have performed all the following required steps. Please help with your inputs. Thanks!
Added the following JARs into the project
guice 3.0
Velocity 1.4
reportng 1.1.4
Disabled default listeners for TestNG
Added ReportNG listeners to the xml
XML file:
After running the .xml as TestNG suite, getting the following error. The class definition looks fine...a snapshot below...
package SeleniumProject;
<<Import statements go here>>
public class Test1DemoautBookTicket {
--------
}
Error:
java.lang.NoClassDefFoundError:
org/apache/commons/collections/ExtendedProperties
at org.apache.velocity.runtime.RuntimeInstance.<init>
(RuntimeInstance.java:160)
at org.apache.velocity.runtime.RuntimeSingleton.<clinit>
(RuntimeSingleton.java:95)
at org.apache.velocity.app.Velocity.setProperty(Velocity.java:117)
at org.uncommons.reportng.AbstractReporter.<init>(AbstractReporter.java:62)
at org.uncommons.reportng.HTMLReporter.<init>(HTMLReporter.java:83)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.testng.internal.ClassHelper.newInstance(ClassHelper.java:50)
at org.testng.TestNG.initializeConfiguration(TestNG.java:914)
at org.testng.TestNG.run(TestNG.java:1022)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.collections.ExtendedProperties
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="FirstSelenium">
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter"/>
<listener class-name="org.uncommons.reportng.JUnitXMLReporter"/>
</listeners>
<test name="Test1">
<classes>
<class name="SeleniumProject.Test1DemoautBookTicket"></class>
</classes>
</test>
</suite>
I downloaded the ReportNG jars from jar-download.com.
Among the files was also a file named velocity-dep-1.4.jar. Before I added it to the project I got the same error as you.
(Disabling the default listeners doesn't seem necessary.)
I am using Docbook 1.78 and xsltproc (libxslt 1.1.26 with libxml 2.7.8) in command line to generate a fo-file from an XML file. My aim is to generate a PDF using Apache formatted output processor (fop; version 1.1).
My XML-Input file:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE book SYSTEM "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<book lang="de" id="MyBook">
<chapter id="Introduction">
<title>Introduction</title>
<section id="sec_intro_1">
<title>Test</title>
<para>para1_sec_intro_1 (see also glossary: <xref linkend="gloss_etm-datei"/>).</para>
<para>para2_sec_intro_1</para>
</section>
<section id="sec_intro_2">
<title>Another Test</title>
<para>para1_sec_intro_2 (glossary: <xref linkend="gloss_etm-datei"/>).</para>
<para>para2_sec_intro2</para>
</section>
</chapter>
<xi:include href="glossar_test.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
</book>
If I run the following command
xsltproc -o ./test.fo --xinclude --stringparam paper.type A4 --stringparam fop1.extensions 1 ./docbook/fo/docbook.xsl ./test.xml 2> fo_out.txt
The fo-file is generated but it contains fo:wrapper elements with IDs which are not unique. This is the generated fo-file:
...
(see also glossary: <fo:basic-link internal-destination="gloss_etm-datei"><fo:inline>
<fo:wrapper id="idp8751564240"><!--ETM-Datei--></fo:wrapper>
<fo:inline font-weight="bold">ETM-Datei</fo:inline>
</fo:inline></fo:basic-link>)
....
(glossary: <fo:basic-link internal-destination="gloss_etm-datei"><fo:inline>
<fo:wrapper id="idp8751564240"><!--ETM-Datei--></fo:wrapper>
<fo:inline font-weight="bold">ETM-Datei</fo:inline>
</fo:inline></fo:basic-link>).
...
Now, if I try to generate a pdf file from that fo-file, fop throws an Exception:
SEVERE: Exception
org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: Property ID "idp8751564240" (found on "fo:wrapper") previously used; ID values must be unique within a document! (See position 6:48)
javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Property ID "idp8751564240" (found on "fo:wrapper") previously used; ID values must be unique within a document! (See position 6:48)
at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:303)
at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
at org.apache.fop.cli.Main.startFOP(Main.java:177)
at org.apache.fop.cli.Main.main(Main.java:208)
Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Property ID "idp8751564240" (found on "fo:wrapper") previously used; ID values must be unique within a document! (See position 6:48)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:300)
... 3 more
Caused by: org.apache.fop.fo.ValidationException: Property ID "idp8751564240" (found on "fo:wrapper") previously used; ID values must be unique within a document! (See position 6:48)
at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:58)
at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
at com.sun.proxy.$Proxy2.idNotUnique(Unknown Source)
at org.apache.fop.fo.FObj.checkId(FObj.java:173)
at org.apache.fop.fo.FObj.startOfNode(FObj.java:154)
at org.apache.fop.fo.flow.Wrapper.startOfNode(Wrapper.java:65)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:325)
at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:175)
at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
... 4 more
Am I doing anything wrong here?
I appreciate any help!
Thanks in advance!
EDIT
Here is the glosar_test.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE glossary PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<glossary id="glossar">
<title>Glossar</title>
<glossdiv id="gloss_E">
<title>E</title>
<glossentry id="gloss_etm-datei">
<glossterm id="glossterm_etm_datei">
<indexterm>
<primary>ETM-Datei</primary>
</indexterm>
<emphasis role="bold">ETM-Datei</emphasis>
</glossterm>
<glossdef>
<para>
Glossary_Text
</para>
</glossdef>
</glossentry>
</glossdiv>
</glossary>
I've found a solution!
At http://www.sagehill.net/docbookxsl/LinkToGlossary.html it is described how to reference to a gloassary. Normally, you would use the glossterm-tag, e.g.:
<para>Set your <glossterm linkend="NetAddr">network address</glossterm>.
</para>
...
<glossary>
<glossentry id="NetAddr">
<glossterm>Network address</glossterm>
<glossdef><para>Four numbers separated by periods</para></glossdef>
</glossentry>
</glossary>
You also can use the link or xref-tag. If you use the xref-tag you must add an id attribute to the glossterm and add a matching endterm attribute to the xref element. For example:
<xref linkend="ge-xslfoprocessor" endterm="gt-xslfoprocessor"/>
...
<glossentry id="ge-xslfoprocessor">
<glossterm id="gt-xslfoprocessor">XSL-FO processor</glossterm>
<glossdef>
<para>Software component that converts an XSL-FO document into a
formatted document.</para>
</glossdef>
</glossentry>
If you do so, the ids of the fo:wrapper will be removed and fop can parse it to a pdf file.
I am accessing a WebService which give me a valid response. While parsing the response using an XSL Transformation, I am getting SAXParseException. If I tested in the online tools such as freeformatter.com, I am getting a proper parsing without any issues. Any help is greatly appreciated.
The response I have received from the WebService is below
<?xml version="1.0"?><message channel-id="10a60e45-65d4-40c0-826f-1a91d2135da0">
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ns:ITSPResponse xmlns:ns="urn:PegaRULES:SOAP:BNYMDataITSPTest:Services">
<Output>Test IT Service Portal - 1</Output>
</ns:ITSPResponse>
</soap:Body>
</soap:Envelope>
</message>
I am trying to parse the response using XSL Transformation; but receiving an exception. The XSL I am using
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="urn:PegaRULES:SOAP:BNYMDataITSPTest:Services">
<xsl:template match="/">
<message>
<xsl:attribute name="channel-id">
<xsl:value-of select="//#*[local-name()='channel-id']" />
</xsl:attribute>
<send-parameters>
<agent-parameter>
<name>Output</name>
<value> <xsl:value-of select="//*[local-name()='Output']" /> </value>
</agent-parameter>
</send-parameters>
</message>
</xsl:template>
</xsl:stylesheet>
The exception I am getting is
org.xml.sax.SAXParseException: Premature end of file. at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124) at com.newscale.bfw.util.XMLValidator.validate(XMLValidator.java:147) at com.newscale.is.core.MessageExecutor.processNSTaskTransportMessage(MessageExecutor.java:135) at com.newscale.is.core.MessageExecutor.processTransportMessage(MessageExecutor.java:431) at com.newscale.is.core.MessageExecutor.processSynchronousOutboundMessage(MessageExecutor.java:526) at com.newscale.is.adk.OutboundAdapterUtil.processSynchronousResponse(OutboundAdapterUtil.java:44) at com.newscale.is.adapter.http.HTTPOutboundAdapter.call(HTTPOutboundAdapter.java:190) at com.newscale.is.adapter.http.HTTPOutboundAdapter.processMessage(HTTPOutboundAdapter.java:147) at com.newscale.is.core.MessageRouter.routeMessage(MessageRouter.java:115) at com.newscale.is.core.MessageExecutor.processOutboundMessage(MessageExecutor.java:604) at com.newscale.is.core.MessageExecutor.processMessage(MessageExecutor.java:125) at com.newscale.is.core.QueueListener.handleTextMessage(QueueListener.java:91) at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:340) at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:237) at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:168) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99) at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:73) at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:101) at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71) at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115) at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285) at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322) at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213) at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303) at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150) at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86) at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:105) at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:561) at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:499) at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1059) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1051) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:948) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
I am not sure whether I am missing anything anywhere?
There are two possibilities: Either the document you're reading is ending unexpectedly (and is not well formed), or the stylesheet is ending unexpectedly (and is not well formed). The stylesheet is itself an XML document, after all, and can produce the same exceptions. Looking at the call stack for the exception may help you determine which is true. Running the program under a debugger might also help, by letting you see which URI the parser was trying to read from when it failed.
Or the exception could be coming from parsing some other part of your program and an XML document unrelated to this transformation. Again, look at the exception's call stack, or fire up the program under a debugger, to see what document is causing trouble.
If the parser tells you a file is ending prematurely, it's ending prematurely.
I am new to Spring, so my apologies if this seems obvious. I am trying to create a JUnit test case that calls my webservice. I think I finally got the gist of wat I am suppose to do, but keep getting errors. I have a basic test class:
#RunWith(SpringJUnit4ClassRunner.class)<br>
#ContextConfiguration(locations={"/test.xml"})
public class Tester {
private WebServiceTemplate service;
#Test
public void testEntityWS(){
EntityDetailsRequest request = new ObjectFactory().createEntityDetailsRequest();
EntityDetailsRequest.CallerReference callerReference = new EntityDetailsRequest.CallerReference();
callerReference.setAuthenticationToken("ASD345F8F9");
callerReference.setRequestingEntity(123456l);
request.setCallerReference(callerReference);
request.setSchemaVersion(new Float(1.0));
request.setLegalReferenceNumberType("123456");
EntityDetailsResponse response = (EntityDetailsResponse) service.marshalSendAndReceive(request);
System.out.println("DONE");
System.out.println(response.getEntityNumber());
}
}
This is my Spring configuration:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd">
<oxm:jaxb2-marshaller id="Jaxb2.marshaller" contextPath="za.co.discovery.finance.card.xml"/>
<bean class="org.springframework.ws.client.core.WebServiceTemplate" id="entityService">
<property name="defaultUri" value="http://localhost:7001/entities/services/entityWebservice"/>
<property name="marshaller" ref="Jaxb2.marshaller"/>
<property name="unmarshaller" ref="Jaxb2.marshaller"/>
</bean>
<bean class="za.co.discovery.services.TestEntitiesWS" id="testEntitiesWS">
<property name="service" ref="entityService"/>
</bean>
First of all - is this correct? Is this all I have to do to call the webservice (exposed by another party). Then - I am getting the error below. It is a null pointer exception on the service attribute. So looks like the config file never injects into the service? Is this possible? Any ideas why this happens? (I use to get JaxB exceptions - so I know it went to the config file).
PS: This is the full stack trace if anyone is interested:
java.lang.NullPointerException
at Tester.testEntityWS(Tester.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:199)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Hi i have the following configuration.
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.3.v20120416</version>
</plugin>
and in my jetty-env.xml I have
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
</Configure>
When i run with mvn jetty:run i get the following error.
Caused by: java.lang.ClassNotFoundException: org.mortbay.jetty.webapp.WebAppCont
ext
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:92)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.nodeClas
s(XmlConfiguration.java:349)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configur
e(XmlConfiguration.java:314)
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.jav
a:279)
at org.mortbay.jetty.plugin.AbstractJettyMojo.applyJettyXml(AbstractJett
yMojo.java:449)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMo
jo.java:467)
How do i fix this?
I suspect you have a jetty-web.xml or some old jetty configuration files floating around
org.mortbay.jetty.webapp.WebAppContext = org.eclipse.jetty.webapp.WebAppContext
the packaging is different in jetty7 and 8 since we moved to the eclipse foundation a few years ago.
http://wiki.eclipse.org/Jetty/Starting/Porting_to_Jetty_7