SchemaFactory.newSchema can't be called more than one with the same sources

I am using Java 5 or Java 6. Did you already observed such behavior? Seems a bug but I didn't find a Bug ID match.
// Create an array of sources
final InputStream xsd = new FileInputStream("src/xml.xsd");
StreamSource[] sources = new StreamSource[1];
sources[0] = new StreamSource(xsd);
// Create the Schema Factory       
final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); // Create a schema
Schema schema1 = schemaFactory.newSchema(sources);
// Create a second schema, it will throw an Excepion
Schema schema2 = schemaFactory.newSchema(sources);
If you are creating a new array of sources before to create the second schema, it works fine. It seems that SchemaFactory.newSchema is making the passed sources as not "reusable"
Thrown Exception :
Exception in thread "main" org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'null', 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(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:2245)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchema(XSDHandler.java:1590)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:438)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:556)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:523)
at com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl.newSchema(SchemaFactoryImpl.java:206)
at javaapplication5.Main.main(Main.java:55)

I've looked further into the matter and the problem is that the newSchema() method closes the underlying input stream, as a result of which there is no way to reuse the same source object if it is based on an input stream. There's another alternative: if it is not necessary for you to provide the schemas in an array, you can use the "newSchema(URL schema)" method. The advantage of using an URL object is that it can hold a reference to files inside a jar file.

Similar Messages

  • How can you set up more than one device on iTunes. I have an iPad, iPod, itouch and iPhone. I don't want the same on all devices.

    How can you set up more than one device on iTunes? I have an iPad, iPod, itouch and iPhone. I don't want the same on all devices. I have all my music/videos on iTunes on my mac book pro. Can you set up separate folders for each device and drop in what ever music/videos from the main iTunes library?

    In itunes it is called syncing and you can choose exactly what content to sync to all devices and it can be different for all of them
    How to sync

  • Can not color label more than one file at a time

    Hi,
    I've had this problem since 10.6.6-ish, i can not color label more than one file at a time in the Finder.
    Wether i select two, twenty or twohundred only one file gets color labeled.
    It doesn't seem to matter if i assign a color label through the File menu or right click > label.
    Figured a re-install might fix this but it hasn't (even a clean install without restoring any kind of backup).
    Does anyone else have this issue and/or a fix for it?
    Thanks,
    Jay

    Aaaaanyone ?

  • My sister has a mac and i want to update my phone onto the computer but i dont want her to see all my stuff can you somehow have more than one itunes account on the same computer so my stuff with save?

    my sister has a mac and i want to update my phone onto the computer but i dont want her to see all my stuff can you somehow have more than one itunes account on the same macbook so my stuff with save?

    How to use multiple iPhone, iPad, or iPod devices with one computer. The only way is for you to have a separate user account to log into on that computer.

  • Can I back up more than one mac to the time machine:

    Can I back up more than one Mac to a time machine? I have a laptop and a Mac Desktop computer can I back up both on the same Time machine

    Absolutely.
    However, quoting from ASC contributor Pondini's excellent Time Machine FAQ:
    It is advisable, though, to partition an external disk that will be connected to your Macs into one volume for each Mac ...

  • Why can´t i have more than one initiator task on my bpm process

    Hi All.
    I am working with BPM 11g and would like to know:
    Why can´t i have more than one initiator task on my bpm process
    In this case, i will have two separeted process where each has its initiator task?
    Regards,
    Diovani

    Hi Diovani
    Two different processes can have different task initiators...task initiator means creation of a process instance which can happen only once

  • I have a PC, Windows 7 x64. I installed a plug-in in Elements 13. I tried to installed another plug-in. It replaced the first plug-in . Can't I have more than one plug-in at a time??? If so, how?

    I have a PC with Windows 7 x64. I have Elements 13. I installed a plug-in (Topaz) which appeared under the Filter Menu.
    Then I tried to install my new Canon Printer software plug-in which put it under FILE > AUTOMATION TOOLS. However, when I tried to use TOPAZ under the FILTER MENU it was gone. In other words, the Canon printer plug-in replaced my Topaz plug-in. When I reinstalled the Topaz plug-in, it replaced the Canon Printer Plug-in.
    QUESTION: Can't I have more than one plug-in installed in Photoshop Elements 13 at a time? So that the Canon printer plug-in is in AUTOMATION TOOLS, and the Topaz plug-in is under the FILTER menu?

    Have a look at this thread.
    http://discussions.apple.com/message.jspa?messageID=2369954#2369954
    Before you try some of the suggestions bear in mind that your iPod is still under warranty.

  • How do I send pictures from iphoto to a group via email instead of to just one individual? I can't type in more than one name or send the pictures to a group.

    How do I send pictures from iphoto to a group via email instead of to just one individual? I can't type in more than one name or send the pictures to a group.

    I had a similar problem in that my wife's iphone 5 could not send pics with imessage.  Had to set the settings to default to SMS or whatever.  After laboring many hours on the web I coincidentally was on the phone with the internet people to question my internet speed.  They changed the router channel, which is something that I am capable of doing myself.  After that, the pics go over imessage.  My own Iphone didn't have the problem.  We are both latest IOS 7.0.6.

  • Iphone6 why can't I save more than one contact?

    iphone 6 why can't i save more than one contact?

    Hi Diovani
    Two different processes can have different task initiators...task initiator means creation of a process instance which can happen only once

  • HT1473 how can I download an more than one audio cd to itunes, scramble all and then transfer all back to a R/W cd?

    how can I download an more than one audio cd to itunes, scramble all and then transfer all back to a R/W cd?

    Import the CDs to iTunes one at a time, following these instructions.
    Once the tracks are in your iTunes library, put them into a playlist, and get them into the order you want.  Or if you by "scramble" you mean a randomly shuffled order, use the crossing arrows at the lower left to do so.
    When you are ready, insert a blank CD, use the command File > Burn Playlist to Disc, and create an audio CD.  I strongly suggest using CD-Rs rather than CD-RWs, since the latter often have trouble in normal CD players.

  • Can oracle  function return more than one value

    Hi All
    please answer can oracle function return more than one value
    need one schenario
    regards

    Can any function, irrespective of the language, return multiple values?
    OF COURSE NOT!!
    So why do you think Oracle will now suddenly do it differently than all other languages? Never mind that it is impossible for a function (a unit/module of code) returning a memory address, to return multiple memory addresses. The machine code that does that, has not been yet been designed/implemented.
    I am continually amazed that this question is asked. It is about something so fundamental in almost every single 3rd and 4th generation language... something that is taught right at the start... the definition of what a procedure and what a function is.
    Sorry, but I simply cannot pull punches on this subject and smooth it over. There is something fundamentally wrong with your training as a programmer if you have to ask such a question about a function.
    And whatever programming skills you build on such a foundation, will be seriously lacking.
    I kindly suggest that you get back to the very basics of programming - and review and revisit until you fully understand it. There are no shortcuts in becomming a good programmer.
    Message was edited by:
    Billy Verreynne

  • HT3924 Can I set up more than one monitor/displays to my Macbook Pro?

    Can I set up more than one monitor/displays to my Macbook Pro?

    OSX Maveric 10.9.1.  I have a 2.9 GHz Intel Core i7 with 8GB memory.  I like the new things I can do with maveric.  I have conected only one external monitor through the thinderbol conecting cable to VGA or HDMI.  I would like to conect 2 monitors and still use the laptop display ( total of three monitors). Can I do that?

  • Can i back up more than one iphone onto the same computer and keep data separate?

    can i back up more than one iphone to the same (pc) computer and keep the data separate?

    http://support.apple.com/kb/HT1495

  • Can numbers sort by more than one column? How?

    Can numbers sort by more than one column? How?

    Open the "Sort & Filter" options:
    Then add columns.  You can set sort ASCENDING or DESCSANDING then drag the items to set the which column is sorted first

  • Can I download Photoshop cc more than twice on the same computer

    I had problems with my computer,can I download Photoshop CC more than twice on the same computer?

    Hi problm,
    Yes, you can , it will be counted as second activation if you have not deactivated the previous install & activation.
    I have checked & found that you have deactivated from one machine & it is active on one computer, this entitles you an install.
    Incase it does not help you, please contact adobe http://adobe.ly/yxj0t6
    Regards,
    Rajshree

Maybe you are looking for

  • GTX 770 2GB Twin Frozr OC does not POST

    Been building new PC over last couple of days. When I do not have the graphics card installed my system works fine.  With the graphics card installed I am unable to reach the POST screen.  I have switched the monitor cable between the graphics card a

  • The grid array of my photo library has disappeared

    iLife 08, iPhoto 6.0.6, Snow Leopard 10.6.8, iMac Intel Core 2 Duo I loaded my 4th of July pictures and began editing them, but in the afternoon of July 5th the screen changed from the scrollable grid array of my entire iPhoto Library to just one big

  • Clustering/HA for Content Server

    Hi. Is it possible to run ACS in clustered environment (providing for all nodes a shared database and storage)? I'd like to prepare a HA solution for ACS and would like to know if I can have two tomcats on two nodes running simultaneously, or in hot

  • Imovie 9

    Hello, I have got the following problem. I put some music in my project. The background turns green. I have put all my itunes music > 1000 songs. I want to delete them in once. Can somebody help. Now i have to remove separtly. and make > 1000 clics??

  • Open differents subvis on own main vi.... is it possible?

    Hi Guys, I have a litle dude. I have a very good application and works well,  i have main vi, it takes differents bottoms to open subvis with differents options or applications, but the problem is when i do the executable file, on xp open 2 files on