i want to create pdf in java from xls file using FOP? - java

i am using the code at for creating pdf using Apache FOP
but i am getting these exceptions when i run the code
Hi Testing
javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: class com.testFOP.Employee nor any of its super class is known to this context.
javax.xml.bind.JAXBException: class com.testFOP.Employee nor any of its super class is known to this context.]
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown Source)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(Unknown Source)
at com.testFOP.PDFHandler.getXMLSource(PDFHandler.java:97)
at com.testFOP.TestPDF.main(TestPDF.java:37)
Caused by: com.sun.istack.internal.SAXException2: class com.testFOP.Employee nor any of its super class is known to this context.
javax.xml.bind.JAXBException: class com.testFOP.Employee nor any of its super class is known to this context.
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(Unknow n Source)
at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(Unknown Source)
... 5 more
Caused by: javax.xml.bind.JAXBException: class com.testFOP.Employee nor any of its super class is known to this context.
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getBeanInfo(Unknown Source)
... 13 more
Error on line 1 column 1
SXXP0003: Error reported by XML parser: Premature end of file.
net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:420)
at net.sf.saxon.event.Sender.send(Sender.java:169)
at net.sf.saxon.Controller.transform(Controller.java:1890)
at com.testFOP.PDFHandler.createPDFFile(PDFHandler.java:64)
at com.testFOP.TestPDF.main(TestPDF.java:39)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(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 net.sf.saxon.event.Sender.sendSAXSource(Sender.java:396)
... 4 more
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(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 net.sf.saxon.event.Sender.sendSAXSource(Sender.java:396)
at net.sf.saxon.event.Sender.send(Sender.java:169)
at net.sf.saxon.Controller.transform(Controller.java:1890)
at com.testFOP.PDFHandler.createPDFFile(PDFHandler.java:64)
at com.testFOP.TestPDF.main(TestPDF.java:39)
can any one help me to solve these issues.
thanks in advance

The problem can be sloved .. Please make following changes to "PDFHandler.java"..
try {
context = JAXBContext.newInstance(EmployeeData.class,Employee.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.marshal(data, outStream);
} catch (JAXBException e) {
e.printStackTrace();
}
And generated pdf will be placed in this location (in windows 7 os )
"C:\Users\narendar.g\AppData\Local\Temp" like 13891730308241855417914089056114.pdf

Related

Spring app runs in eclipse, not on jvm outside eclipse

Okay, this is weird. I have a regular java console application. It uses spring and hibernate and works as expected when is do Run As... from inside eclipse. When I package a runnable JAR with all the dependencies and export that, it fails while initializing the spring context with the below exception.
I strongly suspect that the difference is that because I work for the government, our security folks must have an exception that allows eclipse to go to the internet and get the xsd, while the jvm outside eclipse does not. I confirmed this using curl...it cannot get the xsd, being rejected by the firewall.
There's no chance I'm going to get a firewall exception as it's very bureaucratic and they are inclined to say 'no' unless you have a really compelling reason. I found an article talking about putting the xsd's local in meta-inf, but that seems aimed as web projects. Mine is a console app. I'm not sure how to do something similar in the console project.
I tried just creating a meta-inf directory off the root and adding it to the classpath, but that didn't work. So how can i get spring to consume local copies of the xsd files in a console application?
WARNING: Ignored XML validation warning
org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 115; schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaWarning(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument1(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(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.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:77)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:428)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:223)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:194)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:258)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:128)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:621)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:522)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:85)
at gov.usdoj.afms.umc.cli.DoUmc.initializeSpring(DoUmc.java:191)
at gov.usdoj.afms.umc.cli.DoUmc.<init>(DoUmc.java:102)
at gov.usdoj.afms.umc.cli.DoUmc.main(DoUmc.java:77)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(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.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser.parse(Unknown Source)
... 37 more

XPath query in jlibs-xmldog throws NegativeArraySizeException

I have a project in which I try to run queries on XML files using in.jlibs.jlibs-xmldog.2.2.1.
The XPath that I'm using is
(//server[#id=123])[1]
and the file to be queried looks like this
<servers>
<server id="123" name="servername3">
<cpu_count>3</cpu_count>
<ram_gb>3</ram_gb>
<mac>aabbccaabbcc</mac>
<domain>test.internal</domain>
<ip>192.168.1.20</ip>
</server>
<server id="124" name="servername4">
<cpu_count>4</cpu_count>
<ram_gb>4</ram_gb>
<mac>aabbccaabbcc</mac>
<domain>test.internal</domain>
<ip>192.168.1.20</ip>
</server>
<server id="125" name="servername5">
<cpu_count>5</cpu_count>
<ram_gb>5</ram_gb>
<mac>aabbccaabbcc</mac>
<domain>test.internal</domain>
<ip>192.168.1.20</ip>
</server>
</servers>
As you can see, there is already only one result that is returned by the inner xpath statement, but I have some reasons for which I need to do the query like this. Anyway, the same behaviour happens if I have more results returned by the inner statement. I've tested the xpath online and it seems to be valid.
Code:
public static void main(String[] args) throws Exception{
final String filePath = "C:\\Users\\NCsorba\\Desktop\\xml\\sample_11433_entries.xml";
final String xPathExpression = "(//server[#id=123])[1]";
DefaultNamespaceContext namespaceContext = new DefaultNamespaceContext();
namespaceContext.declarePrefix("xsd", Namespaces.URI_XSD);
XMLDog xmlDog = new XMLDog(namespaceContext);
Expression compiledXPath = xmlDog.addXPath(xPathExpression);
XPathResults xPathResults = xmlDog.sniff(new InputSource(filePath)); // exception thrown
// System.out.println(xPathResults.getResult(compiledXPath));
}
Here is the stack trace:
Exception in thread "main" java.lang.NegativeArraySizeException
at jlibs.core.util.LongTreeMap$Values.toArray(LongTreeMap.java:534)
at java.util.ArrayList.<init>(ArrayList.java:178)
at jlibs.xml.sax.dog.expr.nodset.PathEvaluation.finished(PathExpression.java:218)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.fireFinished(LocationEvaluation.java:215)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.finished(LocationEvaluation.java:208)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.resultPrepared(LocationEvaluation.java:190)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.expired(LocationEvaluation.java:176)
at jlibs.xml.sax.dog.path.EventID.expireList(EventID.java:244)
at jlibs.xml.sax.dog.path.EventID.expire(EventID.java:230)
at jlibs.xml.sax.dog.path.EventID.pop(EventID.java:322)
at jlibs.xml.sax.dog.sniff.Event.firePop(Event.java:266)
at jlibs.xml.sax.dog.sniff.Event.pop(Event.java:712)
at jlibs.xml.sax.dog.sniff.Event.onEndDocument(Event.java:587)
at jlibs.xml.sax.dog.sniff.SAXHandler.endDocument(SAXHandler.java:75)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.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 jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:189)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:174)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:205)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:212)
at com.hp.oo.content.actions.xml.Main.main(Main.java:24)
--------------- linked to ------------------
javax.xml.xpath.XPathException: java.lang.NegativeArraySizeException
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:192)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:174)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:205)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:212)
at com.hp.oo.content.actions.xml.Main.main(Main.java:24)
Caused by: java.lang.NegativeArraySizeException
at jlibs.core.util.LongTreeMap$Values.toArray(LongTreeMap.java:534)
at java.util.ArrayList.<init>(ArrayList.java:178)
at jlibs.xml.sax.dog.expr.nodset.PathEvaluation.finished(PathExpression.java:218)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.fireFinished(LocationEvaluation.java:215)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.finished(LocationEvaluation.java:208)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.resultPrepared(LocationEvaluation.java:190)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.expired(LocationEvaluation.java:176)
at jlibs.xml.sax.dog.path.EventID.expireList(EventID.java:244)
at jlibs.xml.sax.dog.path.EventID.expire(EventID.java:230)
at jlibs.xml.sax.dog.path.EventID.pop(EventID.java:322)
at jlibs.xml.sax.dog.sniff.Event.firePop(Event.java:266)
at jlibs.xml.sax.dog.sniff.Event.pop(Event.java:712)
at jlibs.xml.sax.dog.sniff.Event.onEndDocument(Event.java:587)
at jlibs.xml.sax.dog.sniff.SAXHandler.endDocument(SAXHandler.java:75)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.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 jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:189)
... 4 more
--------------- linked to ------------------
javax.xml.xpath.XPathException: javax.xml.xpath.XPathException: java.lang.NegativeArraySizeException
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:176)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:205)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:212)
at com.hp.oo.content.actions.xml.Main.main(Main.java:24)
Caused by: javax.xml.xpath.XPathException: java.lang.NegativeArraySizeException
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:192)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:174)
... 3 more
Caused by: java.lang.NegativeArraySizeException
at jlibs.core.util.LongTreeMap$Values.toArray(LongTreeMap.java:534)
at java.util.ArrayList.<init>(ArrayList.java:178)
at jlibs.xml.sax.dog.expr.nodset.PathEvaluation.finished(PathExpression.java:218)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.fireFinished(LocationEvaluation.java:215)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.finished(LocationEvaluation.java:208)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.resultPrepared(LocationEvaluation.java:190)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.expired(LocationEvaluation.java:176)
at jlibs.xml.sax.dog.path.EventID.expireList(EventID.java:244)
at jlibs.xml.sax.dog.path.EventID.expire(EventID.java:230)
at jlibs.xml.sax.dog.path.EventID.pop(EventID.java:322)
at jlibs.xml.sax.dog.sniff.Event.firePop(Event.java:266)
at jlibs.xml.sax.dog.sniff.Event.pop(Event.java:712)
at jlibs.xml.sax.dog.sniff.Event.onEndDocument(Event.java:587)
at jlibs.xml.sax.dog.sniff.SAXHandler.endDocument(SAXHandler.java:75)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.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 jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:189)
... 4 more
I'll appreciate any help! Thanks!

Cannot find class in classpath - Error in Selenium TestNG

I tried to run testng code (XML file) and I have following things on the classpath. I have cleaned my project multiple times but still, I m facing the same. Any workarounds?
Cannot find class in classpath: com.cs.selenium.test.AddAnalystTest
at org.testng.xml.XmlClass.loadClass(XmlClass.java:81)
at org.testng.xml.XmlClass.init(XmlClass.java:73)
at org.testng.xml.XmlClass.<init>(XmlClass.java:59)
at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:575)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(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.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.testng.xml.XMLParser.parse(XMLParser.java:39)
at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:16)
at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:9)
at org.testng.xml.Parser.parse(Parser.java:170)
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:298)
at org.testng.TestNG.initializeEverything(TestNG.java:1107)
at org.testng.remote.support.RemoteTestNG6_12.initialize(RemoteTestNG6_12.java:22)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:97)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Getting SecurityException when deserializing object despite using AllPermission java policy

In my XPages application, I backup certain objects by serializing and saving them to MIME entities in backup documents. To reload the objects later, I use the following server-side JavaScript function for deserialization:
var entity:NotesMIMEEntity=doc.getMIMEEntity(field);
if (!entity) return null;
var stream:NotesStream=session.createStream();
entity.getContentAsBytes(stream);
stream.setPosition(0);
var ois:java.io.ObjectInputStream=new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(stream.read()));
var o=ois.readObject(); // ERROR OCCURS IN THIS LINE
ois.close();
entity.recycle();
doc.closeMIMEEntities(false,field);
When I try to read the object from the stream, an exception is raised:
java.lang.SecurityException: Java bridge is not allowed
I have set the java.security.AllPermission in the java.policy file, so I don't know why this exception is raised anyway. I also found that this problem only occurs when I run my application in the Notes Client, but everything works fine when I run it in the browser via the Domino server.
Can anybody tell me how to solve this issue?
PS: Here is the full trace for the SecurityException:
java.lang.SecurityException: Java bridge is not allowed
at com.ibm.jscript.types.JavaAccessObject.<init>(Unknown Source)
at com.ibm.jscript.types.FBSUtility.wrapAsObject(Unknown Source)
at com.ibm.jscript.types.FBSUtility.wrap(Unknown Source)
at com.ibm.jscript.types.FBSValue.readValue(Unknown Source)
at com.ibm.jscript.types.FBSDefaultObject.readExternal(Unknown Source)
at com.ibm.jscript.std.ObjectObject.readExternal(Unknown Source)
at java.io.ObjectInputStream.readExternalData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.ibm.jscript.types.JavaAccessObject.call(Unknown Source)
at com.ibm.jscript.types.FBSObject.call(Unknown Source)
at com.ibm.jscript.ASTTree.ASTCall.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTVariableDecl.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTTry.interpret(Unknown Source)
at com.ibm.jscript.std.FunctionObject._executeFunction(Unknown Source)
at com.ibm.jscript.std.FunctionObject.executeFunction(Unknown Source)
at com.ibm.jscript.std.FunctionObject.call(Unknown Source)
at com.ibm.jscript.types.FBSObject.call(Unknown Source)
at com.ibm.jscript.ASTTree.ASTCall.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTAssign.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTIf.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTTry.interpret(Unknown Source)
at com.ibm.jscript.std.FunctionObject._executeFunction(Unknown Source)
at com.ibm.jscript.std.FunctionObject.executeFunction(Unknown Source)
at com.ibm.jscript.std.FunctionObject.call(Unknown Source)
at com.ibm.jscript.types.FBSObject.call(Unknown Source)
at com.ibm.jscript.ASTTree.ASTCall.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTAssign.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTForIn.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTTry.interpret(Unknown Source)
at com.ibm.jscript.std.FunctionObject._executeFunction(Unknown Source)
at com.ibm.jscript.std.FunctionObject.executeFunction(Unknown Source)
at com.ibm.jscript.std.FunctionObject.call(Unknown Source)
at com.ibm.jscript.types.FBSObject.call(Unknown Source)
at com.ibm.jscript.ASTTree.ASTCall.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTTry.interpret(Unknown Source)
at com.ibm.jscript.std.FunctionObject._executeFunction(Unknown Source)
at com.ibm.jscript.std.FunctionObject.executeFunction(Unknown Source)
at com.ibm.jscript.std.FunctionObject.call(Unknown Source)
at com.ibm.jscript.types.FBSObject.call(Unknown Source)
at com.ibm.jscript.ASTTree.ASTCall.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTUnaryOp.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTIf.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTProgram.interpret(Unknown Source)
at com.ibm.jscript.ASTTree.ASTProgram.interpretEx(Unknown Source)
at com.ibm.jscript.JSExpression._interpretExpression(Unknown Source)
at com.ibm.jscript.JSExpression.access$1(Unknown Source)
at com.ibm.jscript.JSExpression$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
at com.ibm.jscript.JSExpression.interpretExpression(Unknown Source)
at com.ibm.jscript.JSExpression.evaluateValue(Unknown Source)
at com.ibm.jscript.JSExpression.evaluateValue(Unknown Source)
at com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(Unknown Source)
at com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(Unknown Source)
at com.ibm.xsp.component.UIIncludeComposite.initBeforePageContents(Unknown Source)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(Unknown Source)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(Unknown Source)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.addComponent(Unknown Source)
at com.ibm.xsp.component.UIIncludeComposite.buildContents(Unknown Source)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(Unknown Source)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildChildren(Unknown Source)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildAll(Unknown Source)
at com.ibm.xsp.component.UIViewRootEx.buildContents(Unknown Source)
at com.ibm.xsp.component.UIViewRootEx2.buildContents(Unknown Source)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(Unknown Source)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(Unknown Source)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.createViewRoot(Unknown Source)
at com.ibm.xsp.application.ViewHandlerExImpl._createViewRoot(Unknown Source)
at com.ibm.xsp.application.ViewHandlerExImpl.createViewRoot(Unknown Source)
at com.ibm.xsp.application.ViewHandlerExImpl.doCreateView(Unknown Source)
at com.ibm.xsp.application.ViewHandlerEx.createView(Unknown Source)
at com.ibm.xsp.webapp.FacesServlet.serviceView(Unknown Source)
at com.ibm.xsp.webapp.FacesServletEx.serviceView(Unknown Source)
at com.ibm.xsp.webapp.FacesServlet.service(Unknown Source)
at com.ibm.xsp.webapp.FacesServletEx.service(Unknown Source)
at com.ibm.xsp.webapp.DesignerFacesServlet.service(Unknown Source)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(Unknown Source)
at com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(Unknown Source)
at com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(Unknown Source)
at com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(Unknown Source)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(Unknown Source)
at com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(Unknown Source)
at com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(Unknown Source)
at com.ibm.domino.xsp.module.nsf.NSFService.access$0(Unknown Source)
at com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceRequest.call(Unknown Source)
at com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceRequest.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceThread.run(Unknown Source)
Is this in Domino 9.0.x?
In XPiNC the Java security settings are not managed by the server but on the relevant Notes Client. In the User Security settings, on the What Others Do > Using Workstation tab, for each signer a check box was added in R9 for "Load Java Code". This needs to be ticked for the signer of the XPiNC application.

Returning a Java Vector from Server to Client using RMI

I'm new to RMI and I was trying to return a vector of a user-defined class to the client. I am getting an unmarshal exception.
Here is my code.
The exception I'm getting is:-
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: Text
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at HelloServerImplementation_Stub.viewTexts(Unknown Source)
at HelloClient.main(HelloClient.java:30)
Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: Text
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readArray(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at sun.rmi.server.UnicastRef.unmarshalValue(Unknown Source)
... 3 more
Caused by: java.io.NotSerializableException: Text
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeArray(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.access$300(Unknown Source)
at java.io.ObjectOutputStream$PutFieldImpl.writeFields(Unknown Source)
at java.io.ObjectOutputStream.writeFields(Unknown Source)
at java.util.Vector.writeObject(Unknown Source)
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 java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at sun.rmi.server.UnicastRef.marshalValue(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The reason of exception is
Caused by: java.io.NotSerializableException: Text
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
Implement Serializable interface in your Text class.
class Text implements Serializable{
}

Categories

Resources