過去に一度これを行ったようですが、それを機能させるために何をしたかについての言及は見つかりません。
Web サーバー/jre が提供するものとは異なる JAXB 実装を指定したい Web アプリケーションがあります。Maven から適切なアーティファクトをダウンロードし、jar が war に適切にパッケージ化されていることを確認しましたが、Web アプリを起動すると、バンドルされた JRE 実装がまだ使用されていることがわかります。
構成できるプロパティー・ファイルについて漠然と覚えていますが、どのように構成する必要があるかについての参照が見つかりません。さらに、使用したい実装が同じもの (単に新しいバージョン) である場合、クラス名は JRE にパッケージ化されている場合と同じになります。WAR にバンドルされているものを使用することを指定するにはどうすればよいですか?
編集
私は現在、JBoss 7.0.2 で、Oracle JDK 1.6_0_27、JRE に付属する JAXB RI を実行しています (v2.1 だと思います)。JAXB RI 2.2.5 (MvnRepository にあります) にアップグレードしようとしています。
今朝、もう少し掘り下げてみたところ、ログに奇妙なエラー メッセージが記録されていることに気付きました。
09:43:18,325 WARN [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry jaxb-api.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar" does not point to a valid jar for a Class-Path reference.
09:43:18,325 WARN [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry activation.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar" does not point to a valid jar for a Class-Path reference.
09:43:18,326 WARN [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry jsr173_1.0_api.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar" does not point to a valid jar for a Class-Path reference.
09:43:18,326 WARN [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry jaxb1-impl.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar" does not point to a valid jar for a Class-Path reference.
とても奇妙だと思いました。その情報がどこにあるのかわかりませんでした。もう少し調査すると、MANIFEST.MF で次の行が見つかりました。
Class-Path: jaxb-api.jar activation.jar jsr173_1.0_api.jar jaxb1-impl.jar
だから今、私はこれまで以上に混乱しています。jaxb の実装は、API、アクティベーション、jsr、および jaxb1 実装の jar に依存しているように見えます。しかし、それらは jaxb pom にはリストされていません。オンラインで少し掘り下げたところ、Java6SE環境でJAXB 2.2を使用する方法について説明しているこのリンクが見つかりました。残念ながら、これもうまくいかないようです。上記の WARN メッセージが引き続き表示されます。
次のスニペットを使用して、実行中の JAXB 実装を一覧表示しています。おそらくこれは間違っていますか?
/**
* Print the JAXB Implementation information
*/
public static void outputJaxpImplementationInfo() {
logger.debug(getImplementationInfo("DocumentBuilderFactory", DocumentBuilderFactory.newInstance().getClass()));
logger.debug(getImplementationInfo("XPathFactory", XPathFactory.newInstance().getClass()));
logger.debug(getImplementationInfo("TransformerFactory", TransformerFactory.newInstance().getClass()));
logger.debug(getImplementationInfo("SAXParserFactory", SAXParserFactory.newInstance().getClass()));
}
/**
* Get the JAXB implementation information for a particular class
* @param componentName
* @param componentClass
* @return
*/
private static String getImplementationInfo(String componentName, Class componentClass) {
CodeSource source = componentClass.getProtectionDomain().getCodeSource();
return MessageFormat.format(
"{0} implementation: {1} loaded from: {2}",
componentName,
componentClass.getName(),
source == null ? "Java Runtime" : source.getLocation());
}
このスニペットは、次のログを生成します。
10:28:27,402 INFO [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,402 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil - DocumentBuilderFactory implementation: __redirected.__DocumentBuilderFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar
10:28:27,403 INFO [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,403 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil - XPathFactory implementation: __redirected.__XPathFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar
10:28:27,404 INFO [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,404 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil - TransformerFactory implementation: __redirected.__TransformerFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar
10:28:27,406 INFO [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,406 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil - SAXParserFactory implementation: __redirected.__SAXParserFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar