Results 1 to 4 of 4

Thread: Specify a package instead of “classesToBeBound” for spring Jaxb2Marshaller

Hybrid View

  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Default 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. #2
    Join Date
    Aug 2011
    Posts
    11

    Default

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

    contextPath

    setContextPath

  3. #3
    Join Date
    Jan 2012
    Posts
    2

    Default

    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.

  4. #4
    Join Date
    Aug 2011
    Posts
    11

    Default

    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>

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •