[ https://issues.apache.org/jira/browse/CXF-4424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420623#comment-13420623 ]
David J. M. Karlsen edited comment on CXF-4424 at 7/23/12 1:12 PM: ------------------------------------------------------------------- In my top pom I declare in the properties section: {noformat} <properties> ... <jaxws.api.version>2.2</jaxws.api.version> <jaxb.api.version>2.2</jaxb.api.version> <jaxb.impl.version>2.2</jaxb.impl.version> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> </properties> {noformat} as well as manage surefire/compiler plugin to use endorsed: {noformat} <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArguments> <endorseddirs>${endorsed.dir}</endorseddirs> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <forkMode>once</forkMode> <argLine>-Djava.endorsed.dirs=${endorsed.dir}</argLine> </configuration> </plugin> {noformat} Thirdly in the topmost pom I configure the dependency plugin to copy the jaxws-api and jaxb-api to target/endorsed for all modules: {noformat} <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>copy</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>${jaxb.api.version}</version> </artifactItem> <artifactItem> <groupId>javax.xml.ws</groupId> <artifactId>jaxws-api</artifactId> <version>${jaxws.api.version}</version> </artifactItem> </artifactItems> <outputDirectory>${endorsed.dir}</outputDirectory> </configuration> </execution> </executions> </plugin> {noformat} in the child projects which generates code, I unpack a dependency containing wsdls and fork with the endorsed libs: {noformat} <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>unpack-cpl-server-schemas</id> <phase>generate-sources</phase> <goals> <goal>unpack</goal> </goals> </execution> </executions> <configuration> <includes>**/*.wsdl</includes> <artifactItems> <artifactItem> <groupId>com.edb.fs.cashpool.srv</groupId> <artifactId>cp-server-schemas</artifactId> <version>${cp.srv.version}</version> </artifactItem> </artifactItems> </configuration> </plugin> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>${cxf.version}</version> <configuration> <fork>once</fork> <additionalJvmArgs>-Djava.endorsed.dirs=${endorsed.dir}</additionalJvmArgs> <defaultOptions> <catalog>${basedir}/src/main/resources/wsdl/catalog.xml</catalog> <bindingFiles> <bindingFile>${basedir}/src/main/resources/wsdl/jaxbbindings.xml</bindingFile> </bindingFiles> <extraargs> <extraarg>-fe</extraarg> <extraarg>jaxws21</extraarg> <extraarg>-xjc-Xts</extraarg> <extraarg>-xjc-Xfluent-api</extraarg> <extraarg>-xjc-mark-generated</extraarg> <extraarg>-verbose</extraarg> </extraargs> <validateWsdl>true</validateWsdl> </defaultOptions> <wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot> </configuration> <executions> <execution> <id>generate-sources-embedded</id> <phase>generate-sources</phase> <configuration> <wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> <execution> <id>generate-sources-cp-srv</id> <phase>generate-sources</phase> <configuration> <wsdlRoot>${project.build.directory}/dependency/wsdl</wsdlRoot> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.apache.cxf.xjcplugins</groupId> <artifactId>cxf-xjc-ts</artifactId> <version>${cxf.ts.plugin.version}</version> </dependency> <dependency> <groupId>net.java.dev.jaxb2-commons</groupId> <artifactId>jaxb-fluent-api</artifactId> <version>2.1.8</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>${jaxb.impl.version}</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-xjc</artifactId> <version>${jaxb.impl.version}</version> </dependency> </dependencies> </plugin> </plugins> </build> {noformat} To verify that actually JAXB 2.2 was used (since I invoke codegen with <extraarg>-xjc-mark-generated</extraarg>), you should see {noformat} @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-07-23T12:51:44+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-146") {noformat} in the generated sources. And for good measure some additional WebSphere info (v8 fixpack 3): WAS is jax-ws 2.2 and jaxb2.2. To avoid too big impact I leave my classloader to parent_first, but I add a shared library (set to use "isolated classloader") where I chuck in xmlschema-core-2.0.2. This will override xmlschema core which would otherwise be attempted loaded from $WAS_HOME/plugins/org.apache.axis2.jar and be old (1.4.x) - but have minimal impact on classloading to avoid a lot of potential problems. Thanks for all help! was (Author: davidkarl...@gmail.com): In my top pom I declare in the properties section: {noformat} <properties> ... <jaxws.api.version>2.2</jaxws.api.version> <jaxb.api.version>2.2</jaxb.api.version> <jaxb.impl.version>2.2</jaxb.impl.version> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> </properties> {noformat} as well as manage surefire/compiler plugin to use endorsed: {noformat} <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArguments> <endorseddirs>${endorsed.dir}</endorseddirs> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <forkMode>once</forkMode> <argLine>-Djava.endorsed.dirs=${endorsed.dir}</argLine> </configuration> </plugin> {noformat} Thirdly in the topmost pom I configure the dependency plugin to copy the jaxws-api and jaxb-api to target/endorsed for all modules: {noformat} <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>copy</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>${jaxb.api.version}</version> </artifactItem> <artifactItem> <groupId>javax.xml.ws</groupId> <artifactId>jaxws-api</artifactId> <version>${jaxws.api.version}</version> </artifactItem> </artifactItems> <outputDirectory>${endorsed.dir}</outputDirectory> </configuration> </execution> </executions> </plugin> {noformat} in the child projects which generates code, I unpack a dependency containing wsdls and fork with the endorsed libs: {noformat} <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>unpack-cpl-server-schemas</id> <phase>generate-sources</phase> <goals> <goal>unpack</goal> </goals> </execution> </executions> <configuration> <includes>**/*.wsdl</includes> <artifactItems> <artifactItem> <groupId>com.edb.fs.cashpool.srv</groupId> <artifactId>cp-server-schemas</artifactId> <version>${cp.srv.version}</version> </artifactItem> </artifactItems> </configuration> </plugin> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>${cxf.version}</version> <configuration> <fork>once</fork> <additionalJvmArgs>-Djava.endorsed.dirs=${endorsed.dir}</additionalJvmArgs> <defaultOptions> <catalog>${basedir}/src/main/resources/wsdl/catalog.xml</catalog> <bindingFiles> <bindingFile>${basedir}/src/main/resources/wsdl/jaxbbindings.xml</bindingFile> </bindingFiles> <extraargs> <extraarg>-fe</extraarg> <extraarg>jaxws21</extraarg> <extraarg>-xjc-Xts</extraarg> <extraarg>-xjc-Xfluent-api</extraarg> <extraarg>-xjc-mark-generated</extraarg> <extraarg>-verbose</extraarg> </extraargs> <validateWsdl>true</validateWsdl> </defaultOptions> <wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot> </configuration> <executions> <execution> <id>generate-sources-embedded</id> <phase>generate-sources</phase> <configuration> <wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> <execution> <id>generate-sources-cp-srv</id> <phase>generate-sources</phase> <configuration> <wsdlRoot>${project.build.directory}/dependency/wsdl</wsdlRoot> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.apache.cxf.xjcplugins</groupId> <artifactId>cxf-xjc-ts</artifactId> <version>${cxf.ts.plugin.version}</version> </dependency> <dependency> <groupId>net.java.dev.jaxb2-commons</groupId> <artifactId>jaxb-fluent-api</artifactId> <version>2.1.8</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>${jaxb.impl.version}</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-xjc</artifactId> <version>${jaxb.impl.version}</version> </dependency> </dependencies> </plugin> </plugins> </build> {noformat} And for good measure some additional WebSphere info (v8 fixpack 3): WAS is jax-ws 2.2 and jaxb2.2. To avoid too big impact I leave my classloader to parent_first, but I add a shared library (set to use "isolated classloader") where I chuck in xmlschema-core-2.0.2. This will override xmlschema core which would otherwise be attempted loaded from $WAS_HOME/plugins/org.apache.axis2.jar and be old (1.4.x) - but have minimal impact on classloading to avoid a lot of potential problems. Thanks for all help! > Option for codegen plugin to fork in order to support endorsed libs > ------------------------------------------------------------------- > > Key: CXF-4424 > URL: https://issues.apache.org/jira/browse/CXF-4424 > Project: CXF > Issue Type: Improvement > Components: Tooling > Affects Versions: 2.5.4 > Environment: java 6 > Reporter: David J. M. Karlsen > Labels: codegen, endorsed, fork > > In order to support endorsed libs it would be preferable to have the codegen > plugin fork (and support setting of java.endorsed.dirs). > I wish to do so because my build uses a vanilla JDK6 which is JAXB 2.1 and > JAX-WS 2.1, but the target env is JDK6, JEE6 on WAS8 with JAXB 2.2 and JAX-WS > 2.2 -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira