Skip to main content

AssertionError in QNameMap.getEntry()

6 replies [Last post]
skells
Offline
Joined: 2005-05-20
Points: 0

Hi
I am using 1.2.2 FastInfoset and trying to get EvternalVocubularies working, but without success.

I have been digging thourgh the debugger and it seems that the QNameMap resources are interned, but he parametes are not. Stitcking asserts on generates this error.

In this case the localName is interned, but the URI is not

What am I doing wrong
Exception in thread "main" java.lang.AssertionError
at com.sun.xml.bind.v2.util.QNameMap.getEntry(QNameMap.java:460)
at com.sun.xml.bind.v2.util.QNameMap.get(QNameMap.java:158)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.selectRootLoader(JAXBContextImpl.java:609)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.selectRootLoader(UnmarshallingContext.java:337)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1003)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:452)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:433)
at com.sun.xml.bind.v2.runtime.unmarshaller.FastInfosetConnector.handleStartElement(FastInfosetConnector.java:162)
at com.sun.xml.bind.v2.runtime.unmarshaller.FastInfosetConnector.bridge(FastInfosetConnector.java:105)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:358)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:330)
at client.TestModel.sendFastInfosetStAXEV(TestModel.java:434)
at client.TestModel.main(TestModel.java:76)

What am I doing wrong?

Message was edited by: skells

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
skells
Offline
Joined: 2005-05-20
Points: 0

Basically the question is what am I doing wrong

oleksiys
Offline
Joined: 2006-01-25
Points: 0

Hi,

looks like exception happens on JAXB side. Not sure if it's FI related.
Can you share the code, you're using to initialize JAXB and FI.

Thanks.

skells
Offline
Joined: 2005-05-20
Points: 0

the app is a little test app comparing performance of different options

private static void sendFastInfosetStAXEV(int count) throws JAXBException {

JAXBContext jaxbContext1 = JAXBContext.newInstance(ValidClientRequest.MESSAGE_SET.getContainedClasses()
.toArray(new Class[0]));
JAXBContext jaxbContext2 = JAXBContext.newInstance(ValidClientResponse.MESSAGE_SET.getContainedClasses()
.toArray(new Class[0]));
Marshaller marshaller = jaxbContext1.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);

Unmarshaller unmarshaller = jaxbContext1.createUnmarshaller();

StAXDocumentSerializer staxDocumentSerializer = new StAXDocumentSerializer();

StAXDocumentParser staxDocumentParser = new StAXDocumentParser();
staxDocumentSerializer.setExternalVocabulary(testVocabulary);
staxDocumentParser.setExternalVocabularies(vocabularyByUri);

for (int i = 0; i < count; i++) {
CreateSessionRequest r = build();

ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
staxDocumentSerializer.setOutputStream(out);

marshaller.marshal(r, (XMLStreamWriter) staxDocumentSerializer);

ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
staxDocumentParser.setInputStream(in);

CreateSessionRequest r2 = (CreateSessionRequest) unmarshaller.unmarshal(staxDocumentParser);

r2.__setImmutable(false);
}
}

I have simalar code runing without external vocabularies

the vocabularies were build like this - trying to get the documentation from http://blogs.sun.com/sandoz/entry/fast_infoset_1_1_improvements to work - but I cant see a version for 1.2 and cant see source fo the FastInfoSetUtiliites so it may well be wrong, bu tit shold not affect the parser end I guess

private static void buildVocab() throws Exception {

List urls = new ArrayList();
urls.add(new File ("C:\\codebase\\valid-head5\\vsbuild\\projects\\zz-XML-generator\\xml\\public\\common.xsd").toURL());
urls.add(new File ("C:\\codebase\\valid-head5\\vsbuild\\projects\\zz-XML-generator\\xml\\public\\common-user-credentials.xsd").toURL());
URL testURI = new File ("C:\\codebase\\valid-head5\\vsbuild\\projects\\zz-XML-generator\\xml\\public\\valid-client.xsd").toURL();
urls.add(testURI);
urls.add(new File ("C:\\codebase\\valid-head5\\vsbuild\\projects\\zz-XML-generator\\xml\\public\\valid-service.xsd").toURL());
urls.add(new File ("C:\\codebase\\valid-head5\\vsbuild\\projects\\zz-XML-generator\\xml\\public\\weighted-load-balancing.xsd").toURL());
// http://blogs.sun.com/sandoz/entry/fast_infoset_1_1_improvements

vocabularyByUri = new HashMap();

// e.g. args from main
// Process the schema
com.sun.xml.analysis.frequency.SchemaProcessor sp = new com.sun.xml.analysis.frequency.SchemaProcessor(urls);
sp.process();
// Procese the sample documents
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
SAXParser p = spf.newSAXParser();
for (URL url : urls) {
FrequencyHandler fh = new FrequencyHandler(sp);
p.parse(url.openStream(), fh);

Document d = new org.dom4j.io.SAXReader().read(url);
String targetNamespace = d.getRootElement().attributeValue("targetNamespace");

if (targetNamespace == null) {
throw new IllegalStateException();
}

// Once all information has been generated and sorted a Vocabulary
// instance can be obtained from the FrequenceHandler:
//
Vocabulary v = fh.getVocabulary();
// (Much simpler than before and there is no need to specify an API
// for
// which the vocabulary is intended for).
//
// Next the vocabulary can be set on the SAX serializer as an
// external
// vocabulary:
//
ExternalVocabulary ev = new ExternalVocabulary(targetNamespace, v);
vocabularyByUri.put(targetNamespace, ev);
FastInfosetWriter writer = new SAXDocumentSerializer();
writer.setExternalVocabulary(ev);

if (url == testURI) {
testVocabulary = ev;
}
}

// (Note that FastInfosetWriter interface is being used. I would
// encourage developers when they instantiate concrete instances of Fast
// Infoset parsers/serializers that they use the appropriate API
// interfaces where possible so to minimize possible change if
// upgrading).
//
// Then the external vocabulary can be set on the SAX parser:
//
FastInfosetReader reader = new SAXDocumentParser();
reader.setExternalVocabularies(vocabularyByUri);
// Hopefully you will agree that this is a improvement!
//
//
// Posted at 10:28AM Jun 02, 2006 by Paul Sandoz in Fast Infoset |
// Comments[0]

if (testVocabulary == null) {
throw new Exception();
}

}

oleksiys
Offline
Joined: 2006-01-25
Points: 0

FastinfosetUtils module from version 1.1 should work fine with 1.2.x

Not sure external vocabularies were tested with JAXB, so it could be issue of FastInfoset and JAXB integration.

It could help a lot if you'll be able to send me whole project (Netbeans, ant, maven) I can debug locally and figure out what is the problem there.

From your code I don't see anything suspicious. The marshaller works fine, but looks like exception happens in JAXB code on unmarshalling phase...

WBR.

skells
Offline
Joined: 2005-05-20
Points: 0

Here is all of the code, just a simple test client
the build() method just builds a JAXB generated object, and all of the rest of the code should be self explainitory

the output that I get implies that I am not building the vocabulary well, as there are many attributes that are not being included in the vocabulary.

output (with assertions)
----
start attributes
-- name
-- type
-- value
-- form
-- use
-- base
-- minOccurs
-- default
-- xpath
-- maxOccurs
-- declare
-- ref
-- abstract
-- namespace
-- schemaLocation
-- request-interface
-- {http://java.sun.com/xml/ns/jaxb}version
-- attributeFormDefault
-- request-return
-- {http://java.sun.com/xml/ns/jaxb}extensionBindingPrefixes
-- response-return
-- response-interface
-- javadoc-hint
-- elementFormDefault
-- targetNamespace
-- text4
-- token-activation-timeout-sec
-- complete-information-components
-- time-zone-id
-- port
-- authentication-code-length
-- external-application-id
-- access-rule-reg-ex
-- given-name
-- locale-string
-- profile-group-id
-- dev-summary
-- min-length
-- command-recieved
-- encrypt-response
-- profile-type-id
-- format
-- billing-code
-- seq
-- ticks
-- comment
-- raw1
-- profile-type-ref
-- int3
-- bool5
-- host
-- indexes
-- transaction-reference
-- activated
-- action
-- token-usage-timeout-sec
-- repeat-entry
-- name-order
-- simple-config
-- session-idle-timeout-sec
-- text-encoding
-- session-id-length
-- bool4
-- request
-- question-id
-- contact-management-policy
-- global-question-type-ref
-- user-retry-limit
-- text1
-- code
-- timestamp
-- hide-entry
-- restriction-type
-- int5
-- transaction-value
-- show-dev-info
-- error-id
-- question-type-id
-- info
-- random-number-generation-type
-- schema-validate-inputs
-- max-length
-- input-id
-- family-name
-- int2
-- title
-- session
-- int4
-- int1
-- progress-type
-- prompt
-- suffix
-- characteristic-type-ref
-- weighting
-- mandatory
-- service-user-id
-- characteristic-id
-- order-number
-- class-name
-- text5
-- bool3
-- application-id
-- number-input-characters-required
-- schema-validate-outputs
-- command-start
-- bool2
-- command-end
-- key
-- service-id
-- text2
-- bool1
-- enabled
-- ssl
-- description
-- text3
end attributes
start attributeValues
end attributeValues
start characterContentChunks
end characterContentChunks
start elements
-- {http://www.w3.org/2001/XMLSchema}annotation
-- {http://www.w3.org/2001/XMLSchema}documentation
-- {http://www.w3.org/2001/XMLSchema}element
-- {http://www.w3.org/2001/XMLSchema}attribute
-- {http://www.w3.org/2001/XMLSchema}enumeration
-- {http://www.w3.org/2001/XMLSchema}complexType
-- {http://www.w3.org/2001/XMLSchema}complexContent
-- {http://www.w3.org/2001/XMLSchema}extension
-- {http://www.w3.org/2001/XMLSchema}appinfo
-- {http://java.sun.com/xml/ns/jaxb}class
-- {http://www.w3.org/2001/XMLSchema}simpleType
-- {http://www.w3.org/2001/XMLSchema}restriction
-- {http://www.w3.org/2001/XMLSchema}sequence
-- {http://www.w3.org/2001/XMLSchema}choice
-- {http://uri.validsoft.com/products/valid/common/xjc/message}response
-- {http://uri.validsoft.com/products/valid/common/xjc/message}request
-- {http://www.w3.org/2001/XMLSchema}field
-- {http://www.w3.org/2001/XMLSchema}selector
-- {http://www.w3.org/2001/XMLSchema}unique
-- {http://www.w3.org/2001/XMLSchema}attributeGroup
-- {http://uri.validsoft.com/products/valid/common/xjc/insert}class-insert
-- li
-- {http://www.w3.org/2001/XMLSchema}import
-- {http://java.sun.com/xml/ns/jaxb}schemaBindings
-- {http://www.w3.org/2001/XMLSchema}list
-- b
-- {http://www.w3.org/2001/XMLSchema}key
-- {http://java.sun.com/xml/ns/jaxb}package
-- {http://java.sun.com/xml/ns/jaxb}javadoc
-- i
-- {http://www.w3.org/2001/XMLSchema}schema
-- {http://uri.validsoft.com/products/valid/common/xjc/message}message-types
-- ol
-- access
-- end-user-data-accessor
-- input-request
-- validate-request
-- profile-group-question
-- plain-text
-- client-managed-knowledge
-- encription
-- transaction-data
-- all
-- digest
-- application
-- knowledge
-- plain
-- configuration
-- encrypted
-- contact
-- text
-- encryptable-text
-- state
-- source
-- complex
-- jndi
-- client-managed-contacts
-- simple-object
-- alert
-- entry
-- jdbc
-- logging-data-accessor
-- handler
-- policy
-- value
-- user-details
-- tcp
-- allow
-- question-request
-- key
-- dev-stacktrace
-- client-managed-attributes
-- data
-- standard
-- custom
-- policy-data-accessor
end elements
start encodingAlgorithms
end encodingAlgorithms
start otherNCNames
end otherNCNames
start otherStrings
end otherStrings
start otherURIs
end otherURIs
start prefixes
-- xjc
-- ud
-- local
-- vsm
-- xs
-- vsi
-- common
-- jaxb
end prefixes
start restrictedAlphabets
end restrictedAlphabets
test data

mikesPassword

Size - SAX 438
Size - FIS 313
FIS data à5http://uri.validsoft.com/products/valid/4/valid-clientxÏns2†Ïns3‚ð?Š‚ÀbxusernameCmikexdata-managementEserverxuser-time-zone-idBGMTxuser-locale-stringAenx•Emy-app?Emy-reqð<
password-credentials ’
mikesPasswordÿÿ
warmup
Exception in thread "main" javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: Namespace URIs and local names to the unmarshaller needs to be interned.]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:421)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:330)
at client.TestModelEV.sendFastInfosetStAXEV(TestModelEV.java:264)
at client.TestModelEV.run(TestModelEV.java:59)
at client.TestModelEV.main(TestModelEV.java:51)
Caused by: javax.xml.bind.UnmarshalException: Namespace URIs and local names to the unmarshaller needs to be interned.
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:609)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:244)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:239)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:114)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1015)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:452)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:433)
at com.sun.xml.bind.v2.runtime.unmarshaller.FastInfosetConnector.handleStartElement(FastInfosetConnector.java:162)
at com.sun.xml.bind.v2.runtime.unmarshaller.FastInfosetConnector.bridge(FastInfosetConnector.java:105)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:358)
... 4 more
Caused by: javax.xml.bind.UnmarshalException: Namespace URIs and local names to the unmarshaller needs to be interned.
... 14 more

----

package client;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

import org.dom4j.Document;
import org.jvnet.fastinfoset.ExternalVocabulary;
import org.jvnet.fastinfoset.Vocabulary;
import org.jvnet.fastinfoset.sax.FastInfosetReader;
import org.jvnet.fastinfoset.sax.FastInfosetWriter;

import com.sun.xml.analysis.frequency.FrequencyHandler;
import com.sun.xml.fastinfoset.sax.SAXDocumentParser;
import com.sun.xml.fastinfoset.sax.SAXDocumentSerializer;
import com.sun.xml.fastinfoset.stax.StAXDocumentParser;
import com.sun.xml.fastinfoset.stax.StAXDocumentSerializer;
import com.validsoft.products.valid.generated.client.data4.CreateSessionRequest;
import com.validsoft.products.valid.generated.client.data4.ValidClientRequest;
import com.validsoft.products.valid.generated.client.data4.ValidClientResponse;
import com.validsoft.products.valid.generated.user.data4.DataManagementPolicy;
import com.validsoft.utils.generated.common.EncryptableText;

public class TestModelEV {

private Map vocabularyByUri;

private ExternalVocabulary testVocabulary;

/**
* @param args
* @throws JAXBException
*/
public static void main(String[] args) throws Exception {
new TestModelEV().run();
}

void run() throws Exception {

buildVocab();
showSize();
System.out.println("warmup");
sendFastInfosetStAXEV(10000);
sendFastInfosetStAX(10000);
}

private void showSize() throws JAXBException, XMLStreamException {
JAXBContext jaxbContext1 = JAXBContext.newInstance(ValidClientRequest.MESSAGE_SET.getContainedClasses()
.toArray(new Class[0]));
Marshaller marshaller = jaxbContext1.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);

ByteArrayOutputStream bytes = new ByteArrayOutputStream();
CreateSessionRequest r = build();
System.out.println("test data " + r);

bytes.reset();
marshaller.marshal(r, bytes);
System.out.println("Size - SAX " + bytes.size());

FastInfosetWriter fis = new SAXDocumentSerializer();
bytes.reset();
fis.setOutputStream(bytes);
marshaller.marshal(r, fis);
System.out.println("Size - FIS " + bytes.size());
System.out.println("FIS data " + bytes.toString());

fis = new SAXDocumentSerializer();
fis.setExternalVocabulary(testVocabulary);
bytes.reset();
fis.setOutputStream(bytes);
marshaller.marshal(r, fis);
System.out.println("Size - FIS EV " + bytes.size());

byte[] b = bytes.toByteArray();
System.out.println("FIS EV data " + bytes.toString());

}

private void buildVocab() throws Exception {

List urls = new ArrayList();
urls.add(new File("C:\\codebase\\valid-head5\\vsbuild\\projects\\zz-XML-generator\\xml\\public\\common.xsd")
.toURL());
urls
.add(new File(
"C:\\codebase\\valid-head5\\vsbuild\\projects\\zz-XML-generator\\xml\\public\\common-user-credentials.xsd")
.toURL());
URL testURI = new File(
"C:\\codebase\\valid-head5\\vsbuild\\projects\\zz-XML-generator\\xml\\public\\valid-client.xsd")
.toURL();
urls.add(testURI);
urls.add(new File(
"C:\\codebase\\valid-head5\\vsbuild\\projects\\zz-XML-generator\\xml\\public\\valid-service.xsd")
.toURL());
urls
.add(new File(
"C:\\codebase\\valid-head5\\vsbuild\\projects\\zz-XML-generator\\xml\\public\\weighted-load-balancing.xsd")
.toURL());
// http://blogs.sun.com/sandoz/entry/fast_infoset_1_1_improvements

vocabularyByUri = new HashMap();

// e.g. args from main
// Process the schema
com.sun.xml.analysis.frequency.SchemaProcessor sp = new com.sun.xml.analysis.frequency.SchemaProcessor(urls);
sp.process();
// Procese the sample documents
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
SAXParser p = spf.newSAXParser();
for (URL url : urls) {
FrequencyHandler fh = new FrequencyHandler(sp);
p.parse(url.openStream(), fh);

Document d = new org.dom4j.io.SAXReader().read(url);
String targetNamespace = d.getRootElement().attributeValue("targetNamespace");

if (targetNamespace == null) {
throw new IllegalStateException();
}

// Once all information has been generated and sorted a Vocabulary
// instance can be obtained from the FrequenceHandler:
//
Vocabulary v = fh.getVocabulary();
// (Much simpler than before and there is no need to specify an API
// for
// which the vocabulary is intended for).
//
// Next the vocabulary can be set on the SAX serializer as an
// external
// vocabulary:
//
ExternalVocabulary ev = new ExternalVocabulary(targetNamespace, v);
vocabularyByUri.put(targetNamespace, ev);
FastInfosetWriter writer = new SAXDocumentSerializer();
writer.setExternalVocabulary(ev);

if (url == testURI) {
testVocabulary = ev;
}
}
list("attributes", testVocabulary.vocabulary.attributes);
list("attributeValues", testVocabulary.vocabulary.attributeValues);
list("characterContentChunks", testVocabulary.vocabulary.characterContentChunks);
list("elements", testVocabulary.vocabulary.elements);
list("encodingAlgorithms", testVocabulary.vocabulary.encodingAlgorithms);
list("otherNCNames", testVocabulary.vocabulary.otherNCNames);
list("otherStrings", testVocabulary.vocabulary.otherStrings);
list("otherURIs", testVocabulary.vocabulary.otherURIs);
list("prefixes", testVocabulary.vocabulary.prefixes);
list("restrictedAlphabets", testVocabulary.vocabulary.restrictedAlphabets);

// (Note that FastInfosetWriter interface is being used. I would
// encourage developers when they instantiate concrete instances of Fast
// Infoset parsers/serializers that they use the appropriate API
// interfaces where possible so to minimize possible change if
// upgrading).
//
// Then the external vocabulary can be set on the SAX parser:
//
FastInfosetReader reader = new SAXDocumentParser();
reader.setExternalVocabularies(vocabularyByUri);
// Hopefully you will agree that this is a improvement!
//
//
// Posted at 10:28AM Jun 02, 2006 by Paul Sandoz in Fast Infoset |
// Comments[0]

if (testVocabulary == null) {
throw new Exception();
}

}

private void list(String string, Collection data) {
List xx = new ArrayList(data);
System.out.println("start "+string);
for (Object object : xx) {
System.out.println(" -- "+object);
}
System.out.println("end "+string);

}

private static void sendFastInfosetStAX(int count) throws JAXBException {

JAXBContext jaxbContext1 = JAXBContext.newInstance(ValidClientRequest.MESSAGE_SET.getContainedClasses()
.toArray(new Class[0]));
JAXBContext jaxbContext2 = JAXBContext.newInstance(ValidClientResponse.MESSAGE_SET.getContainedClasses()
.toArray(new Class[0]));
Marshaller marshaller = jaxbContext1.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);

Unmarshaller unmarshaller = jaxbContext1.createUnmarshaller();

StAXDocumentSerializer staxDocumentSerializer = new StAXDocumentSerializer();

StAXDocumentParser staxDocumentParser = new StAXDocumentParser();
for (int i = 0; i < count; i++) {
CreateSessionRequest r = build();

ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
staxDocumentSerializer.setOutputStream(out);

marshaller.marshal(r, (XMLStreamWriter) staxDocumentSerializer);

ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
staxDocumentParser.setInputStream(in);

CreateSessionRequest r2 = (CreateSessionRequest) unmarshaller.unmarshal(staxDocumentParser);

r2.__setImmutable(false);
}
}

private void sendFastInfosetStAXEV(int count) throws JAXBException {

JAXBContext jaxbContext1 = JAXBContext.newInstance(ValidClientRequest.MESSAGE_SET.getContainedClasses()
.toArray(new Class[0]));
JAXBContext jaxbContext2 = JAXBContext.newInstance(ValidClientResponse.MESSAGE_SET.getContainedClasses()
.toArray(new Class[0]));
Marshaller marshaller = jaxbContext1.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);

Unmarshaller unmarshaller = jaxbContext1.createUnmarshaller();

StAXDocumentSerializer staxDocumentSerializer = new StAXDocumentSerializer();

StAXDocumentParser staxDocumentParser = new StAXDocumentParser();
staxDocumentSerializer.setExternalVocabulary(testVocabulary);
staxDocumentParser.setExternalVocabularies(vocabularyByUri);

for (int i = 0; i < count; i++) {
CreateSessionRequest r = build();

ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
staxDocumentSerializer.setOutputStream(out);

marshaller.marshal(r, (XMLStreamWriter) staxDocumentSerializer);

ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
staxDocumentParser.setInputStream(in);

CreateSessionRequest r2 = (CreateSessionRequest) unmarshaller.unmarshal(staxDocumentParser);

r2.__setImmutable(false);
}
}

private static CreateSessionRequest build() {
CreateSessionRequest r = new CreateSessionRequest().withRequest("my-req").withApplication("my-app")
.withUserLocaleString("en").withUserTimeZoneId("GMT").withUsername("mike").withPasswordCredentials(
new EncryptableText().withPlain("mikesPassword")).withDataManagement(
DataManagementPolicy.SERVER);
return r;
}

}

skells
Offline
Joined: 2005-05-20
Points: 0

Did this get fixed or is this raised as an issues somewhere