hi, JB.
thank you for looking at this. The attached zip (rename its extension from .txt
to .zip) contains both the bundle (rename its extension from .txt to .jar) and
its feature file. the bundle should be placed in the /bundles dir, and you know
what to do with the feature file =)
here are some points regarding the bundle:
1) the bundle executes automatically during Karaf startup to make it easier for
you.
2) The bundle contains both the schema and the xml, so you dont have to really
do anything to the bundle itself in order for it to just run
3) The bundle contains props.properties where you can specify external
locations to both schema and xml file if you choose to do so for any reason.
The provided files will be ignored in such case.
4) I have also provided the source .java alongside the binary just in case.
again, really appreciate you taking the time to look at it. thanks!!!
Brock Samson
________________________________
From: Jean-Baptiste Onofre <[email protected]>
Sent: Tuesday, February 23, 2021 11:56 AM
To: [email protected] <[email protected]>
Subject: Re: Karaf 4.2.10 - NullPointerException during xml parsing
Hi Brock,
Maybe you have xerces installed as bundle in your distribution ?
It sounds like a version mismatch.
Can you share the bundles installed ?
Thanks,
Regards
JB
Le 23 févr. 2021 à 16:55, brock samson
<[email protected]<mailto:[email protected]>> a écrit :
Hello,
I am using Karaf 4.2.10 and attempting to perform a rather simple xml parsing:
Caused by: java.lang.NullPointerException
at org.apache.xerces.util.ErrorHandlerProxy.error(Unknown
Source) ~[!/:?]
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:137)
~[?:1.8.0_102]
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
~[?:1.8.0_102]
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
~[?:1.8.0_102]
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
~[?:1.8.0_102]
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1900)
~[?:1.8.0_102]
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:740)
~[?:1.8.0_102]
at
com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.startElement(ValidatorHandlerImpl.java:570)
~[?:1.8.0_102]
at
org.apache.xerces.jaxp.JAXPValidatorComponent$XNI2SAX.startElement(Unknown
Source) ~[!/:?]
at
org.apache.xerces.jaxp.JAXPValidatorComponent.startElement(Unknown Source)
~[!/:?]
at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source) ~[!/:?]
at
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(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.DOMParser.parse(Unknown Source)
~[!/:?]
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown
Source) ~[!/:?]
at
javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) ~[?:1.8.0_102]
After snooping around, I noticed a
/container/lib/endorsed/org.apache.karaf.specs.java.xml-4.2.10.jar lib
containing parser-related libs. My code executed successfully once I ran Karaf
without this particular file, though I don’t feel right just pulling it out of
Karaf blindly, as its absence creates a distinct possibility of unforeseen
issues down the road.
Here are the only imports my bundle references in its manifest:
Import-Package:
javax.xml.transform,javax.xml.transform.stream,org.xml.sax,javax.xml.parsers,javax.xml.validation
There are no entries under Bundle-Classpath
Lastly, here is the java code that performs the xml parsing:
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
SchemaFactory sf =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(new StreamSource(new
FileInputStream("<LOCATION-OF-THE-SCHEMA-FILE>")));
factory.setNamespaceAware(true);
factory.setSchema(schema);
factory.setExpandEntityReferences(false);
factory.setXIncludeAware(false);
factory.setFeature("http://xml.org/sax/features/external-parameter-entities",false);
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl",
true);
factory.setFeature("http://xml.org/sax/features/external-general-entities",false);
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setErrorHandler(null);
byte[] fileContent =
Files.readAllBytes(Paths.get("<LOCATION-OF-THE-XML-FILE-TO-BE-PARSED>"));
InputStream inStream = new ByteArrayInputStream(fileContent);
Document doc = builder.parse(inStream);
Please advise me as to what I am doing wrong, as well as a possible solution.
Thank you for your time!
Sincerely,
Brock Samson
PK {WRÒ? ¹ com.foo.blah.parsetest-1.0.txtXXTY¡g%.ºfhFÁAJJ.IAéf °a¤%G\aaKÙ]÷Û½ï»ï¼w¿óþÿÆ»çÜs
´ A pàe
vüâÜpòvxÚrRí\mE|Ý\uÚ¨BÅ@>ôØ-
ßÙ¾+LÑsñàm¼u]>ø½È7WÐk°æ*÷¨Ø
Áµ§í=.²
¯~ú,(û$0
Ø<7ªìâGzC6ÛZ·fZÎh¬ÉE5ÏOG4}¨¥é|Ës̸öasì«·åyTÀyÁR½"KwïøIÔÂXbøìI°û@ÅÔ¬
Ù8ñ~vü·J1ðM!<©èW¿hþ®q
ú-Êo´Ngê_TþªêaöDÞDzÞýº_S'ZÕ9 à xÿå£Ó'£'«§g©hDæËÝ¢TÞék¡?öw$
¼Büný¤¸÷NÏ&í¾ëO#ç[E
>ȶ÷ÙIø9ðÅã3ïíK¾åaJ
Vl&5´ÙZZØBfI,¨÷Ç¢P@ ²Ö
ý×ÒÚuiõxéäç\8¨K¼âä¨ß/¢n>nÄB·>,Á²Ý#¬wtäM¬µ+
ÂÏ´¸,ÀÛ_|EYÃiD¦U¬øzó`[X
c¸Wó£â´äâîÒNóHÉ
Èq¦6rMtrí>sFúX·§e7¹Nw·l]o¢>æ=z¬z=c
¯a-ÝÝ>´W?!]`q#l£Àf.CâÒ6:%·qøiÞû¼/4GÎM7ä,Ô§rUÆ}²) \k ËCjæP¡Ïw
@üüÂ@áâX
×=yky¾xÙÕüQÕ-«ËòúÆu?õ-Ä7±/{'×VXÔÂî9UxëÇ÷¼Ð, r~Ø[bÖcà?¾ù3/Pz¦3z£¤Ûw}>³4&xâÚUñ
¿ëý£öh²z]©h¢ËÒ
6
}È
íÑ
x#_`ͯµ·¤ è¨o³¦H. 0
&¬ü¹ü\P]Z,>&©X÷¾\ËÁÂä(dÃe´ÔÎöªQ{ães7p2ùK^ó,õ\F|)kS
Ãömb§Øù
f³mÞ}hRÄõ¹-W2Ìãþáù-«+Æj²7Ky4_MâL¾l0J§ÖÊ2ݪÏ2
0upÓ7ob Q[¯xÈ~ hç1ÇUO÷
kn_y;áS1UÖämC÷g) xÉÑ( Úk
vFpiRÓÅNP3rÿsÁ¶¦¼ízÀG0r¹Kõå¦4BËÆ·ÉÝaûêVd!±ä1ãXUÞ7:á¦Ð1
&«vy® 4r-7H#¶!ØÆ¥e#ÉKwFÃclrm
u¬1çЩ)ÅÐÆÔ$¸nHëñâGÇn9
9@òó½e88WQ8ÜÕCL9DÈàcÞA¹=×zªûK¾?dk
Ô9«ÌwXó@
cîòÚÖ)½§±Èdgulñi_ï(Gå0Àůu5°û¿6Rë«ÈÉ\ÅÑsÛmNÈúý.¹#E=ÖöúT«×ÔLvZ¥É§.n}Ø8W0¬h.ãî>ð=®y!̱_¦°=XÇpÞîøðün¦ÎùÌgÙä³{£3r¢ñ5%
ø75YØW%û<yè{-*{Óý"ò%<ûf
ï0èwïç9_Ìw{@Yð¯f(¡åÀ§FlÛÄû´ö\\ꪱkÒy.±:^½Õ9ÚÂÇlK2¦/9+Luý¼JÛOCæ
Q{BphjÑG6¤ïÙÒÒ2
Ñl¢¬;¼àÓÐ~ÞÐÃ=ÁIqÄRw<5'¦O1Iø<r^¬Ó#í&mÇâ®ð-j"öì[v}(Ò*Ö¬WìvͯyÉþØ+Ð|~`Ï¥ÐW/v\÷êÎhW½L¡Ä;ºù×½¥®¿nV¨
â~³53OTçàµ?OÔØ Yì¹îº
qjèl=TLgcq%;FY,Äk¯.Ò0´Vfí&j^e¡ò÷,Jvæ%îÚÆïá\µ£óµKÁõá)~I¹¬d$èO×w2ý<y\Xé
s¾d~FѪ3RJ·%´¼«ùó ½Qª¢NFºc&ö%FòZ?@¹8Yü.çÉ
JB¤lm,fC?ÅI@,¬ +ÐLrd{$Aŵ+%RR0i8«|9ã`24¯e#ªË¾{ÙP:)æ\DDø§»Î}20
åãDX´rÁÄEÍgZ¶RËhJòعGã5ö6£ÚfcUZR&°9Ö1j×ÃO$÷íô¸S9.¶×ÛNX½<FôD#8#«Å>å@jþ
nÕkÂE-;yÏF¢ZrdMàªçO*½}µ4¤4ÜáG>Eu;Ó^¡KëK3b)(Cµ*1§BhÒçk»T¬º\1¸SÙ>ÿ}Ü
ðî~/àÙ«¼â õ2II·Ð¸§á$o=ñù2z.Fqåį»ÇfÁ/è7(
ÛoßíÑ#
=3Cä~îDEuÞ~ ¢)¬í(Â<r=z÷ÑáO"ÅÕ&ؽF©GÁÜH0Ë
±ÅúgÙÍ
t[2ës"XIÜéD$ËÕDôË>N#
)`V@Áu7¾ß6Ûr+ºàQ«E
o{èj}¾<ÀW;ñàw\í )r ò_<¸³·mvÂBXO0ó-4¡õÛRÁsEB&øÒwðÐô%ú4X>§l
þºPð\ÏÖóñ{¡}täî[tEOgé×"¤©f³Í÷ÙüÊÜî_%ËOÙYdUl]ôi¼Ù7w¾ÓÂuQÔmyè
¸Æôa-»vø\ôJÎ+¥j#l~H´ì¦Ïm«h¸©y%¾±BÍÕK^¤vðVÕû3`Z
¾g_Îy{Î#`Æ&JÆýE\ÞçÃD¡ùö{EziI6í Böø¢ÎóèÏ<³eÞ¥
èâOt£v9õÆS\µ£¸×6¹k¦]öÒyõ9yî²>¿ÉvPàHO¬w¿Ü:ÏjÒ3F+0Ù)²g9gt
¸*HZ)[ʲªg
LÎÿ£èÜåµMà#(Ôæ¹þS9Ñæèþ¨"OÑUA¶
JS[´±ý0½}úK69lh_~)¬Qæò%f'G|
sÉK~Rbàüx¨GD_àÆåi*º÷yàJV²»(BE¯ÕüÕN±I·ÜûÁ p ú}²
7è¬õgÚý°VP|TÌIµ3È®MovÛ5={dæ6¬¡¿?¯Ð,é
oU5-(§²êÕUD|vÙ³ÂC¦A;¼«D;·T¢êùO]W_æv&gÜ"W=¼)FÔ:Òy÷3G
SǸTA мvî
Xp@
×SÁpÐ|ãË0u¹î>õà #u]§õØõQ}ÝP6¡Ã2£
ñWÊ3A>5ïaÚê+
F¼gláæõñS¦=´Ñ?dÿ¸X¼8o7ÀLß,yA"ÔIfeéJ²ÌÅ©{À¹0³u¤VzÙûæ5ÁáA.6^ó©ºÓ
àO|~!@Öìa(5y~³âºD£¦¾Ìë)Þc¢&Lki
:k6îéîG¹ù@Lzû²è-\+]j¹ÂÏ2¬åÄår¢$
ýñÅ2jÛÖ7PEãÕ;fÅ÷#¦>XF[Ögá¶LiÜ׳9¹ýßÜ[Wx;p+¨1õÅbxW¹YÅÛcøv¡w'u[óòÏb'±Û+¦¦UG@0©²¨ó:¦/ð+2¬:ð¾nüÙà©zîê6<