私はSpringブート1.3.2から1.4.0にアップグレードし、今ではアプリケーションの起動に失敗しました - 私のBeanPostProcessor
は、3dパーティのオープンソースLazy Chopperを呼び出します。 getTransaction()
しようとしたときのターンで、ここで失敗します。Springブート1.4.0にアップグレードした後、AbstractPlatformTransactionManagerのNullPointerException
public abstract class AbstractPlatformTransactionManager implements PlatformTransactionManager, Serializable {
protected transient Log logger = LogFactory.getLog(getClass());
// ...
@Override
public final TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException {
Object transaction = doGetTransaction();
// Cache debug flag to avoid repeated checks.
boolean debugEnabled = logger.isDebugEnabled(); // logger is null here
私はすぐそこにブレークポイントを配置すると、私はlogger
を見ることができますが、実際にnull
ですが、それは私がすぐそこに自分自身をLogFactory.getLog(getClass())
を起動した場合、私はやることを言及する価値がある場合適切なロガーを入手してください。
私のBeanの前に初期化されている右ロガーにそのメソッドを呼び出す何とかかのように思え..
ここで私が得たフルスタックトレースです:?
Caused by: java.lang.NullPointerException: null
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:340) ~[spring-tx-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:426) ~[spring-tx-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:275) ~[spring-tx-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at com.tikal.lazychopper.DefaultLazyInitializationChopperAdvice.chop(DefaultLazyInitializationChopperAdvice.java:76) ~[lazy-chopper-1.2.8.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at com.sapiens.bdms.core.service.impl.sign.hash.MD5StringCalculator$$EnhancerBySpringCGLIB$$b5747fb.getSignTypes(<generated>) ~[classes/:na]
at com.sapiens.bdms.core.service.impl.sign.EntitySignCalculatorManagerImpl.postProcessAfterInitialization(EntitySignCalculatorManagerImpl.java:105) ~[classes/:na]
at com.sapiens.bdms.core.service.impl.sign.EntitySignCalculatorManagerImpl$$FastClassBySpringCGLIB$$80ef4d8e.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at com.sapiens.bdms.core.service.impl.sign.EntitySignCalculatorManagerImpl$$EnhancerBySpringCGLIB$$91a9897b.postProcessAfterInitialization(<generated>) ~[classes/:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
私はデフォルトlogback
を使用していますが、自動設定、調整なし。
更新#1: その方法の周りにポイントカットが定義されています。
<aop:pointcut id="transactionManagerPointcut"
expression="(execution(* org.springframework.transaction.PlatformTransactionManager.getTransaction(..)))"/>
更新#2: だから、その点を取り除くようだ...それでもなぜ、どのようにこれを克服するために把握しようとトリックをしました。ここで
は、アスペクトの定義です:それこのインスタンスでロガーを破る理由として
@Component("sessionFilterConfigurator")
public class SessionFilterConfigurator {
@Resource
private Collection<FilterConfiguration> filterConfigurations;
@Resource
private SessionFactory sessionFactory;
@Resource
private FiltersDisconnector filtersDisconnector;
public void setupFilter() throws Throwable {
Session session = sessionFactory.getCurrentSession();
if (AutoEnableConfig.isFiltersEnabled()) {
for (FilterConfiguration filterConfiguration : filterConfigurations) {
Filter filter = session.enableFilter(filterConfiguration.getFilterName());
for (Map.Entry<String, Object> entry : filterConfiguration.getFilterParameters().entrySet()) {
filter.setParameter(entry.getKey(), entry.getValue());
}
}
AutoEnableConfig.disableFilterEnabling();
((EventSource) session).getActionQueue().registerProcess(filtersDisconnector);
}
}
}
まだ明確ではない、と理由だけ1.4にアップグレードした後:
<aop:pointcut id="transactionManagerPointcut"
expression="(execution(* org.springframework.transaction.PlatformTransactionManager.getTransaction(..)))"/>
<aop:pointcut id="allServices"
expression="(execution(* com.decision..tx..*.*(..))) or (execution(* com.sapiens.bdms..tx..*.*(..))) && [email protected](com.sapiens.bdms.core.persistence.annotation.NotTransactional)"/>
<aop:aspect ref="sessionFilterConfigurator">
<aop:before method="setupFilter"
pointcut-ref="allServices"/>
<aop:after-returning method="setupFilter"
pointcut-ref="transactionManagerPointcut"/>
</aop:aspect>
そしてここでは、アスペクト方法です.0 ...
NPEが奇妙です。 'logger'は、構築時に初期化され、オブジェクトが直列化から復元されない限り、再度割り当てられません。フィールドは保護されていますが、サブクラスは 'null 'に設定する可能性があります。 Springフレームワークではそのコードはありませんので、その拡張子にする必要があります。私はそれがなぜそれを行うのか、なぜそれがアップデートで壊れるのかという理由で困惑しています。その特定のクラスは全く変更されていません。問題を再現するサンプルを共有できますか? –
@StéphaneNicoll迅速な対応に感謝します。同意する。私の考えは誰も 'null'でそれを上書きするのではなく、おそらく' LogFactory'が実際に 'null'を返す何らかの特異な理由のためです。ロガー実装のミスマッチとは何か?それは公正な評価のように聞こえる?私は多分ここに依存木を掲示することを考えた。それが助けになると思いますか? – ronif
@StéphaneNicollにも言及する価値がありますが、そのサービスのために定義されたポイントカットがあります。上記の編集を参照してください。 – ronif