|
|
| Re: Marshalling attributes as node, why ? [message #521912 is a reply to message #521808] |
Fri, 19 March 2010 05:34   |
Nicola Messages: 4 Registered: July 2009 |
Junior Member |
|
|
Hi, I have the same issue, I'm using EclipseLink OSGI version 2.0.1.
I have tested with the model you proposed and a blank project, this is the Activator class:
public void start(BundleContext context) throws Exception
{
JAXBContext jaxbContext = null;
jaxbContext = JAXBContext.newInstance("my.models", new BundleProxyClassLoader(context.getBundle()));
Node n = new Node();
n.setAttribute0("mioatt0");
n.setAttribute1("mioatt1");
// Step 2 - Convert the Domain Model to XML
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(new ObjectFactory().createNode(n), System.out);
}
I have found BundleProxyClassLoader somewhere in another user thread to let MOXy find ObjectFactory inside my models package.
This is the output of ss:
Framework is launched.
id State Bundle
0 ACTIVE org.eclipse.osgi_3.5.1.R35x_v20090827
Fragments=9
1 ACTIVE org.eclipse.persistence.core_2.0.1.v20100213-r6600
Fragments=2
2 RESOLVED org.eclipse.persistence.oracle_2.0.1.v20100213-r6600
Master=1
3 ACTIVE javax.xml_1.3.4.v200902170245
4 ACTIVE javax.activation_1.1.0.v200906290531
5 ACTIVE org.eclipse.persistence.moxy_2.0.1.v20100213-r6600
6 ACTIVE javax.persistence_2.0.0.v201002051058
7 ACTIVE javax.mail_1.4.0.v200905040518
8 ACTIVE provaxml_1.0.0.qualifier
9 RESOLVED org.eclipse.persistence.jpa.equinox.weaving_2.0.1.v20100213-r6600
Master=0
10 ACTIVE javax.resource_1.5.0.v200906010428
11 ACTIVE org.eclipse.persistence.asm_2.0.1.v20100213-r6600
12 ACTIVE javax.xml.stream_1.0.1.v201001131653
13 ACTIVE javax.jms_1.1.0.v200906010428
14 ACTIVE javax.transaction_1.1.0.v201002051055
15 ACTIVE org.eclipse.persistence.antlr_2.0.1.v20100213-r6600
16 ACTIVE javax.xml.bind_2.1.12.v200912160909
bundle 8 is my testbundle.
and this is the output:
osgi> <START>
org.eclipse.persistence.jaxb.JAXBContext
<?xml version="1.0" encoding="UTF-8"?>
<ns0:node xsi:type="node" xmlns:ns0="http://my.models" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<attribute0>mioatt0</attribute0>
<attribute1>mioatt1</attribute1>
</ns0:node>
<END>
If I use non OSGI version of EclipseLink MOXy the XML output is OK :-\
[Updated on: Fri, 19 March 2010 05:35] Report message to a moderator
|
|
|
| Re: Marshalling attributes as node, why ? [message #521963 is a reply to message #521808] |
Fri, 19 March 2010 09:31  |
Nicola Messages: 4 Registered: July 2009 |
Junior Member |
|
|
Uhmm, seems like I have solved my issue ...
I added javax.xml.bind.annotation in manifest.mf, Import-Package section, it appears strange to me since I didn't get class not found error or others problems inspecting the package and its imported packages from osgi console commands.
well hope this help
[Updated on: Fri, 19 March 2010 09:31] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.15455 seconds