Friday, March 20, 2009

JAXB: Pretty print xml in marshalling

Marshaller marshaller = .....
marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );

That should do the trick.

Thursday, March 19, 2009

svn merge a particular revision

Assuming that you have committed a few changes to trunk and want to merge the same to a branch, you can use the "merge -c xyz" pattern as follows:

Let us say that the revision that I committed my changes on the trunk was "86077". I do a dry run to check what changes will get merged if I do the real thing.

============================
anil@localhost:~/Branch_5_x$ svn merge -c 86077 https://svn.jboss.org/repos/jbossas/trunk/ --dry-run
U component-matrix/pom.xml
U server/src/main/org/jboss/deployment/security/AbstractSecurityDeployer.java
U server/src/main/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java
U server/src/main/org/jboss/web/deployers/WarSecurityDeployer.java
A server/src/main/org/jboss/web/deployers/SecurityActions.java
U server/src/etc/deployers/security-deployer-jboss-beans.xml
A testsuite/src/resources/web/xacml/requestAttrib/WEB-INF/jbossxacml-config.xml
A testsuite/src/resources/security/authorization/xacml-ejb/META-INF/jbossxacml-config.xml
U testsuite/imports/sections/security.xml
U testsuite/imports/sections/web.xml
U security/.classpath
A security/src/main/org/jboss/security/deployers
A security/src/main/org/jboss/security/deployers/XacmlConfigParsingDeployer.java
A security/src/main/org/jboss/security/deployers/JAXBElementParsingDeployer.java
A security/src/main/org/jboss/security/deployers/AclConfigParsingDeployer.java
U security/pom.xml
===============================

Ok. Those are the changes I want it into my branch. Now I do the real merge without the "--dry-run" option.

======================================
anil@localhost:~/Branch_5_x$ svn merge -c 86077 https://svn.jboss.org/repos/jbossas/trunk/
U component-matrix/pom.xml
U server/src/main/org/jboss/deployment/security/AbstractSecurityDeployer.java
U server/src/main/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java
U server/src/main/org/jboss/web/deployers/WarSecurityDeployer.java
A server/src/main/org/jboss/web/deployers/SecurityActions.java
U server/src/etc/deployers/security-deployer-jboss-beans.xml
A testsuite/src/resources/web/xacml/requestAttrib/WEB-INF/jbossxacml-config.xml
A testsuite/src/resources/security/authorization/xacml-ejb/META-INF/jbossxacml-config.xml
U testsuite/imports/sections/security.xml
U testsuite/imports/sections/web.xml
U security/.classpath
A security/src/main/org/jboss/security/deployers
A security/src/main/org/jboss/security/deployers/XacmlConfigParsingDeployer.java
A security/src/main/org/jboss/security/deployers/JAXBElementParsingDeployer.java
A security/src/main/org/jboss/security/deployers/AclConfigParsingDeployer.java
U security/pom.xml
anil@localhost:~/Branch_5_x$
=============================

Tuesday, March 17, 2009

JAXB Debugging Unmarshalling

When you need to debug JAXB2 unmarshalling issues, try the following:

1) Set the system property "jaxb.debug" to "true"
2) Set the event handler on the unmarshaller which will print out the errors to System.out as follows:
um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());




Additional note
:

If you start seeing errors such as the sax parser not finding schema types, then look at the stack trace. If it shows com.sun.xerces (which is Sun JDK internal port of Xerces), then you will need to
either a) endorse the Xerces libraries or b) a system property
"-Djavax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema=org.apache.xerces.jaxp.validation.XMLSchemaFactory"

http://marc.info/?l=xerces-j-user&m=117066282420361&q=raw

============================
On 26.09.2006, at 15:48, Michael Glavassevich wrote:

> Hi Simon,
>
> You weren't actually using Xerces when you ran your test. The
> com.sun.org.apache.xerces.internal.* packages originate from Sun's
> Java 5.
> Regardless of whether there are schema locations in the document or
> not it
> doesn't seem to call the LSResourceResolver. This is probably one
> of many
> bugs which we've fixed (in the last three years) or one that never
> existed
> since the Validator implementation in Xerces is significantly
> different
> than the one included in Java 5.
>
> There's one Java 5 bug [1] in particular which prevents the
> SchemaFactory's factory finder from finding the implementation on the
> classpath. If you had xercesImpl.jar in your classpath this would
> explain
> why you got the JDK default instead. To select Xerces'
> SchemaFactory you
> can set a system property -Djavax.xml.validation.SchemaFactory:
> http://www.w3.org/2001/
> XMLSchema=org.apache.xerces.jaxp.validation.XMLSchemaFactory
> . Putting the xml-apis.jar which accompanies Xerces in your JDK's
> endorsed
> directory [2] works as well.
===============================