TLDが webapp とは異なるバンドルにある場合、Pax は TLD を見つけられません。
タグ ライブラリ
カスタム タグ ライブラリを機能させるには、バンドル内の「特別な」場所で TLD ファイルにアクセスできる必要があります。
- Bundle-ClassPath マニフェスト エントリによって参照される任意の jar 内のすべての tld ファイル
- バンドル jar 内の WEB-INF ディレクトリまたは WEB-INF のサブディレクトリ内のすべての tld ファイル
インポートしたパッケージは検索されないことに注意してください (このサポートは後で追加される可能性があります)。
複数の webapp バンドル間で OSGi-fied Struts バンドルを共有する Struts ベースのシステムでこの問題が発生しています。Web アプリケーションには、Struts taglib を必要とする JSP があります。
少しハックな (TLD をあちこちにコピーするため) 回避策は、TLD を Web アプリケーションのMETA-INF
ディレクトリに配置し、Web アプリケーション バンドルに必要な Struts パッケージをインポートさせることです (または、Struts を使用しない場合は、タグを処理するクラスは何でも)。これは次のように Maven で自動化できます。
<plugin>
<!--
Extract the TLD file from the Struts bundle you are using
and place it in src/main/resources/META-INF of your webapp's
project directory during generate-resources. This will make
the file end up in the appropriate place in the resulting WAR
-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>extract-tld</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts.version}</version>
<outputDirectory>src/main/resources</outputDirectory>
<includes>META-INF/struts-tags.tld</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--
Add the required Manifest headers using the maven-bundle-plugin
-->
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<!-- ... -->
<instructions>
<!-- ... -->
<Import-Package>[...],org.apache.struts2.views.jsp</Import-Package>
<!-- ... -->
</instructions>
</configuration>
</plugin>