Announcement Announcement Module
Collapse
No announcement yet.
Specify a package instead of “classesToBeBound” for spring Jaxb2Marshaller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Specify a package instead of “classesToBeBound” for spring Jaxb2Marshaller

    I am trying to use Jaxb2Marshaller to marshal a set of java classes using spring. I know this can be done using the following code

    Code:
    <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="classesToBeBound">
            <list>
                <value>com.example.test1</value>
                <value>com.example.test2</value>
            </list>
        </property>
    </bean>
    What I would like to do is instead of specifying a list of classes, I would like to specify just the package name containing all the classes ( in the above case com.example).

    Does anyone know of a way to do this, or any other way which does not require me to list all the classes. any help would be appreciated !

    Thanks.

  • #2
    Read the doc org.springframework.oxm.jaxb.Jaxb2Marshaller. Is it?

    contextPath

    setContextPath

    Comment


    • #3
      Unfortunately the doc doesn't describe it in detail http://static.springsource.org/sprin...#oxm-jaxb2-xsd.

      It is contextPath, but for that to work you have to have jaxb.index file or ObjectFactory.class (generated by running xjc .. I think) in the package.

      Comment


      • #4
        Unfortunately you're right unless you're proven wrong by someone else.

        1. Caused by: javax.xml.bind.JAXBException: "test.ci" doesnt contain ObjectFactory.class or jaxb.index

        2. Taken from the sample:

        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <executions>
        <execution>
        <goals>
        <goal>xjc</goal> </goals>
        </execution>
        </executions>
        <configuration>
        <schemaDirectory>src/main/webapp/</schemaDirectory>
        <packageName>org.springframework.ws.samples.airlin e.schema</packageName> </configuration>
        </plugin>

        Comment

        Working...
        X