Thursday, August 07, 2008

Jaxb Multiple namespace definitions

I was mildly concerned about the number of namespace definitions that Jaxb was printing every time it marshaleld an Xml document.

I'm using Spring-ws with jaxb bindings. In my definition of the Spring Marshaller I declare the jaxb packages which this marshaller will marshall. Each of these is turned into a namespace definiton on the resulting xml doc.

<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.company.package1:com.company.package2:com.company.package3:com.company.package4">
</property>
</bean>

Results in

<ns1:request ns1="http://www.company.com/Package1" ns2="http://www.company.com/Package2" ns3="http://www.company.com/Package3" ns4="http://www.company.com/Package4">
<ns1:data>text
</ns1:data>
</request>

This was mildly irritating.

After a bit of searching I find its a 'performance feature' in Jaxb2

https://jaxb.dev.java.net/issues/show_bug.cgi?id=103

So they won't be fixing it.

The alternative from my point of view is to declare multiple marshallers, and use them where appropriate.

<bean id="jaxb2Marshaller1" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.company.package1">
</property>
</bean>
<bean id="jaxb2Marshaller2" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.company.package2">
</property>
</bean>
..etc..

Tuesday, August 05, 2008

Python gotcha

This Seemingly innocuous indentation error in python was annoying me.

Problem invoking WLST - Traceback (innermost last):
(no code object) at line 0
File "C:\apps\installWls.py", line 249
toDeploy = sys.argv[3]
^
SyntaxError: inconsistent dedent

Looking at my code (wlst code to auto deploy application into weblogic server), it was all indented correctly.

Well of course the computer was right. It wasn't indented correctly, but it was no obvious.

The issue was some copy and paste code I took from the internet.

It was indented using spaces, whereas I was using tabs.

Replacing the space indentation with tabs fixed the issue (but its not obvious uinless you set your editor to display non visible characters.