1

Tomcat 6 サーバーにデプロイする Spring 3.2.1 ベースの webapp (RestFull Services) を開発しています。Jpa、トランザクション、および他のカスタム依存関係プロジェクトの機能のため、loadTime ウィービングを有効にする必要があります。これを行うには、最初に app /META-INF で context.xml を構成し、以下を追加します。

<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>

次に、spring-instrument-3.2.1.RELEASE.jarspring-instrument-tomcat-3.2.1.RELEASE.jarを tomcat/lib フォルダーに配置します。

そして、ユーザーannotationBasedConfigurationにweb.xmlを構成しました

<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>local</param-value>
</context-param>


<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</context-param>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
com.xxx.yyy.spring.SpringConfiguration
com.xxx.yyy.configuration.spring.WebSpringConfiguration
</param-value>
</context-param>

<!--Spring -->

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Webapp は XML を使用しないコード構成を使用するため、次のような @Configuration 注釈クラスを作成しました。

@Configuration
@Profile("local")
@EnableLoadTimeWeaving
@EnableSpringConfigured
@EnableTransactionManagement(proxyTargetClass = true)
@Import(value = {DataSourceLocal.class,HibernateConfigurationLocal.class})
@ImportResource({"classpath:/database-context.xml"}) // context from imported jar library
@ComponentScan(basePackages = {"com.xxx.yyy","com.xxx.yyy.configuration"})
@EnableJpaRepositories(basePackages = {"com.xxx.yyy.repositories"})
public class SpringConfiguration
{ 
[...]
}

アプリケーションを起動しようとすると、エラーが表示されます

ERROR | ContextLoader - Context initialization failed
java.lang.IllegalStateException: No LoadTimeWeaver available

そのため、最初は LoadTimeWeaving が適切に構成されていないように見えましたが、考えられる回避策を 1 日試しても解決策が見つかりませんでした。

私が見ることができる唯一の奇妙なことは、ログの次の行です。

Overriding bean definition for bean 'loadTimeWeaver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.context.annotation.LoadTimeWeavingConfiguration; factoryMethodName=loadTimeWeaver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/context/annotation/LoadTimeWeavingConfiguration.class]] with [Generic bean: class [org.springframework.context.weaving.DefaultContextLoadTimeWeaver]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null;

同じ名前 (「LoadTimeWeaver」??) を持つ 2 つの異なる Bean が異なる定義でアプリ コンテキストで作成され、これら 2 つの Bean が何らかのレベルで競合しているように思えます。

ウィーバーが context:load-time-weaver (インポートされた jar からロードされたコンテキスト ファイルに存在する) を使用して作成し、新しいコンテキストで @EnableLoadTimeWeaving を使用して作成されたものが何らかの形で衝突している可能性はありますか? 最後の 1 つだけを使用して 2 つのうちの 1 つをオーバーライドする方法はありますか?

4

0 に答える 0