TStreamAdapter Error while uploading an xml-file (from url)

Hi,

when I try to add an xml doc to tamino, I always get the following error:

TStreamAdapter could not be intitialized with underlying input stream. Check for XML stream correctness!

You can find the xml-file (po2.xml) as an attachement.

I have a working connection to tamino. the code to create an TXMLObject looks like this:

TXMLObject xmlObject = TXMLObject.newInstance(url);
po2.xml (935 Bytes)

If you start a web browser and type your URL, do you see your xml file?

java.io.File f= new java.io.File(“C:\temp\po2.xml”);
java.net.URL url = f.toURL();

that’s the way I create my url. the file po2.xml exists in c:\temp

A few questions about versions. What JDK are you using (1.3 or 1.4) and, if your code is a servlet, what servlet engine and version are you using. What version is your TaminoAPI4J?

If you instantiate your TXMLObject using:
TXMLObject xmlObject = TXMLObject.newInstance(f);
does it work (ie using a File instead of a URL).

I use jdk 1.3.1_02 and TaminoAPI4J 3.1.2.1 and I can create a TXMLObject from a URL or from a File without problems using a command-line java program.

I have tried this and it works for me as well. I am using the very latest Tamino API for Java that you can download from the “Downloads” link on the left of this frame.

I am using VA Java 3.5 (JDK 1.2.2)

I gonna try to export and run under 1.3.

I get the same error

C:\jaxfront_web\taminoClient>…\JRE1.3\bin\java -noverify -ms8m -mx96m -classpat
h .;.\lib;.\lib\jaxfront.jar;.\lib\jdom.jar;.\lib\log4j-core.jar;.\lib\xmlxerce
s.jar;.\lib\TaminoAPI4J.jar;.\lib\xmlParserAPIs.jar;.\lib\taminoclient.jar com.
jaxfront.tamino.test.InsertPO
Info: com.jaxfront.repository.TaminoRepository Initializing Tamino Database conn
ection (http://10.0.0.120/tamino/JAXFront)
Info: com.jaxfront.repository.TaminoRepository Adding document (XML [2]) to coll
ection.
Exception in thread “main” com.softwareag.tamino.db.api.common.TPreconditionViol
ation: TStreamAdapter could not be intitialized with underlying input stream. Ch
eck for XML stream correctness!
at com.softwareag.tamino.db.api.common.TContractVerifier.precondition(TC
ontractVerifier.java:31)
at com.softwareag.tamino.db.api.objectModel.stream.TStreamAdapter.initia
lize(TStreamAdapter.java:250)
at com.softwareag.tamino.db.api.objectModel.stream.TStreamAdapter.
(TStreamAdapter.java:59)
at com.softwareag.tamino.db.api.objectModel.TXMLObjectFactory.newXMLObje
ct(TXMLObjectFactory.java:143)
at com.softwareag.tamino.db.api.objectModel.TXMLObject.newInstance(TXMLO
bject.java:151)
at com.softwareag.tamino.db.api.objectModel.TXMLObject.newInstance(TXMLO
bject.java:165)
at com.jaxfront.repository.TaminoRepository.addDocument(TaminoRepository
.java)
at com.jaxfront.repository.TaminoRepository.addXML(TaminoRepository.java
)
at com.jaxfront.tamino.test.InsertPO.main(InsertPO.java)

Can you please post your code. Thanks.

public static void main(String args) throws TException {

com.jaxfront.repository.Repository repository = com.jaxfront.repository.RepositoryManager.registerTaminoRepository(“test”, “http://10.0.0.120/tamino/JAXFront”, “po-example”, “purchaseOrder”);

try {
java.io.File f= new java.io.File(“C:\temp\po2.xml”);
com.jaxfront.repository.RepositoryManager.getRepository(“test”).addXML(f.toURL(),“2”);
}
catch (java.net.MalformedURLException ex) {
ex.printStackTrace();
}
}
repository.zip (3.28 KB)

So you aren’t really instantiating a TXMLObject from a URL - you are reading the URL yourself, building a String and instantiating from a String - but that works for me too!

Can you please try this very simple example which uses your xml data and database, and let me know what happens. Please run it from the command line using JDK1.3 as before.

Thanks…
InsertPO.java (2.91 KB)

I tried your example…I am getting still the same error. what can it be?

I am using JRE:
java version "1.3.0"
Java™ 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot™ Client VM (build 1.3.0-C, mixed mode)

Windows XP Home Edition

**************** ERROR
C:\jaxfront_web\taminoClient>…\JRE1.3\bin\java -noverify -ms8m -mx96m -classpat
h .;.\lib;.\lib\jaxfront.jar;.\lib\jdom.jar;.\lib\log4j-core.jar;.\lib\xmlxerce
s.jar;.\lib\TaminoAPI4J.jar;.\lib\xmlParserAPIs.jar;.\lib\taminoclient.jar Inse
rtPO
com.softwareag.tamino.db.api.common.TPreconditionViolation: TStreamAdapter could
not be intitialized with underlying input stream. Check for XML stream correctn
ess!
at com.softwareag.tamino.db.api.common.TContractVerifier.precondition(TC
ontractVerifier.java:31)
at com.softwareag.tamino.db.api.objectModel.stream.TStreamAdapter.initia
lize(TStreamAdapter.java:250)
at com.softwareag.tamino.db.api.objectModel.stream.TStreamAdapter.
(TStreamAdapter.java:59)
at com.softwareag.tamino.db.api.objectModel.TXMLObjectFactory.newXMLObje
ct(TXMLObjectFactory.java:143)
at com.softwareag.tamino.db.api.objectModel.TXMLObject.newInstance(TXMLO
bject.java:151)
at com.softwareag.tamino.db.api.objectModel.TXMLObject.newInstance(TXMLO
bject.java:165)
at InsertPO.main(InsertPO.java)
java.lang.NullPointerException
at InsertPO.main(InsertPO.java)
***********************

I suspect that the problem is the JRE. The prerequisite JRE/JDK is 1.3.1_01. I use JDK 1.3.1_02 and have no such problems with the API.

I was using an older tamino4J.jar than V3.1.2.4

thank you