OSGi バンドルの実行中に「/hibernate.cfg.xml が見つかりません」という問題に直面する。Apache felix バンドル プラグインを介して OSGi バンドルを作成しました。バンドルでは、休止状態を介してデータベースに接続しています。OSGi コンテナーでバンドルを実行すると、エラーがスローされます。バンドルのルート フォルダーにある POM.xml ファイルのリソース タグを使用して、休止状態に関連するすべての xml ファイル (hibernate.cfg.xml など) を追加しました。
エラーは
SessionFactory の作成に失敗しました:org.hibernate.HibernateException: /hibernate.cfg.xml が見つかりません
これは小さな問題かもしれませんが、私はそれを理解できませんでした。問題を解決するのを手伝ってください
これは私のPOM.xmlファイルです
……………………………………………… ...................................
<build>
<sourceDirectory>D:\WSNew\HCB-VCDPlugin100\src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.5</version>
<extensions>true</extensions>
<configuration>
<excludeDependencies>*;scope=provided|runtime</excludeDependencies>
<instructions>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Directory>OSGI-INF/lib</Embed-Directory>
<Embed-Transitive>true</Embed-Transitive>
<!-- Export-Package>${project.exports}</Export-Package> -->
<!--<_exportcontents>${project.exports}</_exportcontents> -->
<Import-Package>org.osgi.framework, ,org.apache.log4j,org.hibernate,org.hibernate.cfg,org.hibernate.transform,org.quartz,org.quartz.impl,javax.xml.transform,org.w3c.dom,org.xml.sax,javax.xml.parsers,!*</Import-Package>
<Bundle-Activator>com.abclcorp.hcb.vddservice.impl.Activator</Bundle-Activator>
<!-- <Private-Package>org.foo.myproject.*</Private-Package> -->
<_exportcontents>*</_exportcontents>
</instructions>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>resources/configuration</directory>
<includes>
<include>CronScheduler.xml</include>
</includes>
</resource>
<resource>
<directory>resources/log4j</directory>
<includes>
<include>log4j.properties</include>
</includes>
</resource>
<resource>
<directory>resources/logs</directory>
<includes>
<include>CronScheduler.log</include>
</includes>
</resource>
<resource>
<directory>src</directory>
<includes>
<include>*.xml</include>
</includes>
</resource>
</resources>
</build>