Spring Boot 1.4.0にアップグレードした後、AbstractPlatformTransactionManagerのNullPointerException

ロニフ

Spring Boot 1.3.2から1.4.0にアップグレードしましたが、アプリケーションを起動できません-BeanPostProcessorサードパーティのオープンソースLazy Chopperを呼び出します。これを実行しようとするとgetTransaction()、ここで失敗します。

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:それで、その側面を取り除くことがトリックをしたようです..それでも、これを克服する理由と方法を理解しようとしています。

アスペクトの定義は次のとおりです。

            <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..*.*(..))) &amp;&amp; !@annotation(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>

そして、これがアスペクトメソッドです:

    @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.0にアップグレードした後でのみなのかについてはまだ明確ではありません...

不幸

私もまったく同じ問題を抱えていました。私の欠点は、ポイントカットの定義が間違っていたために、TransactionManagerにアスペクトを適用することになったということでした(標準のものを拡張しました)。したがって、ヌルロガーはCGLIBで生成された拡張クラスの1つでした。本物の豆はそのロガーをうまくインスタンス化しました。

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Spring Boot 1.4.0にアップグレードした後、AbstractPlatformTransactionManagerのNullPointerException

分類Dev

Spring Boot 1.4.0にアップグレードした後、AbstractPlatformTransactionManagerのNullPointerException

分類Dev

Spring Bootを2.1.9から2.2にアップグレードした後のInaccessibleObjectException

分類Dev

Spring Boot 2.1.9から2.2.1(Spring Integration)にアップグレードした後のClassCastException

分類Dev

Spring Boot-2.2.5から2.3.0へのアップグレード後に検証が停止しました

分類Dev

Spring3.2.3からSpring4にアップグレードした後のエラー

分類Dev

SB 2.2.7からSB 2.3.0にアップグレードした後、Spring Bootアプリが起動しない

分類Dev

hibernate 5 にアップグレードした後の Spring 4 の hibernate 依存関係の問題

分類Dev

Spring Boot1.3.3にアップグレードした後に@Asyncが機能しない

分類Dev

Spring boot 1.4にアップグレードした後、サービスが開始されない

分類Dev

Spring boot 1.4にアップグレードした後、サービスが開始されない

分類Dev

Spring Bootのアップグレード後、@ Repositoryアノテーション付きインターフェースのAutowireに失敗しました

分類Dev

Spring Boot 1.4.3+のLoadTimeWeavingが、1.4.2からのアップグレード後に機能しない

分類Dev

Spring boot 2.xにアップグレードした後、マッピングのリクエストが機能しない

分類Dev

Spring Security3からSpringSecurity 4にアップグレードした後に例外が発生しますか?

分類Dev

Spring3からSpring4にアップグレードした後、HibernateTemplateに互換性のないタイプのエラーがあります

分類Dev

Spring Security .permitAll()は、Spring Boot 2.0.2へのアップグレード後に有効ではなくなりました

分類Dev

spring-boot-starter-parentを2.1.1から2.3.3にアップグレードした後のSQLステートメントの構文エラー

分類Dev

Gradle、Spring Boot、spring-boot-starter-data-jpaアップグレード

分類Dev

Spring Boot 1.5.21から2.3.4にアップグレードした後の、単体テストでのSQL構文エラー

分類Dev

Spring boot 1.2から1.5.2にアップグレードした後、Tomcat 8.5の起動中にFileNotFoundExceptionが発生する

分類Dev

Spring Bootバージョンを1.3.5から1.4.2にアップグレードした後、DB2ZOSダイアレクトが機能しない

分類Dev

Spring Boot / Spring Dataimport.sqlはSpring-Boot-1.0.0.RC1を実行しません

分類Dev

Spring Boot 2.2.7からSpring Boot 2.3.0へのアップグレードエラー

分類Dev

Spring Boot 2にアップグレードした後、キャッシュメトリックをプロメテウスに公開する方法は?

分類Dev

Spring Boot1.3から1.4RC1にアップグレードするときに、org.hibernate.internal.SessionFactoryImpl。<init>によってスローされるAbstractMethodError

分類Dev

Spring Boot1.3から1.4RC1にアップグレードするときに、org.hibernate.internal.SessionFactoryImpl。<init>によってスローされるAbstractMethodError

分類Dev

Spring Boot1.3から1.4RC1にアップグレードするときに、org.hibernate.internal.SessionFactoryImpl。<init>によってスローされるAbstractMethodError

分類Dev

Spring Boot 2.2へのアップグレード後にSpringboot WebFluxテストが失敗する

Related 関連記事

  1. 1

    Spring Boot 1.4.0にアップグレードした後、AbstractPlatformTransactionManagerのNullPointerException

  2. 2

    Spring Boot 1.4.0にアップグレードした後、AbstractPlatformTransactionManagerのNullPointerException

  3. 3

    Spring Bootを2.1.9から2.2にアップグレードした後のInaccessibleObjectException

  4. 4

    Spring Boot 2.1.9から2.2.1(Spring Integration)にアップグレードした後のClassCastException

  5. 5

    Spring Boot-2.2.5から2.3.0へのアップグレード後に検証が停止しました

  6. 6

    Spring3.2.3からSpring4にアップグレードした後のエラー

  7. 7

    SB 2.2.7からSB 2.3.0にアップグレードした後、Spring Bootアプリが起動しない

  8. 8

    hibernate 5 にアップグレードした後の Spring 4 の hibernate 依存関係の問題

  9. 9

    Spring Boot1.3.3にアップグレードした後に@Asyncが機能しない

  10. 10

    Spring boot 1.4にアップグレードした後、サービスが開始されない

  11. 11

    Spring boot 1.4にアップグレードした後、サービスが開始されない

  12. 12

    Spring Bootのアップグレード後、@ Repositoryアノテーション付きインターフェースのAutowireに失敗しました

  13. 13

    Spring Boot 1.4.3+のLoadTimeWeavingが、1.4.2からのアップグレード後に機能しない

  14. 14

    Spring boot 2.xにアップグレードした後、マッピングのリクエストが機能しない

  15. 15

    Spring Security3からSpringSecurity 4にアップグレードした後に例外が発生しますか?

  16. 16

    Spring3からSpring4にアップグレードした後、HibernateTemplateに互換性のないタイプのエラーがあります

  17. 17

    Spring Security .permitAll()は、Spring Boot 2.0.2へのアップグレード後に有効ではなくなりました

  18. 18

    spring-boot-starter-parentを2.1.1から2.3.3にアップグレードした後のSQLステートメントの構文エラー

  19. 19

    Gradle、Spring Boot、spring-boot-starter-data-jpaアップグレード

  20. 20

    Spring Boot 1.5.21から2.3.4にアップグレードした後の、単体テストでのSQL構文エラー

  21. 21

    Spring boot 1.2から1.5.2にアップグレードした後、Tomcat 8.5の起動中にFileNotFoundExceptionが発生する

  22. 22

    Spring Bootバージョンを1.3.5から1.4.2にアップグレードした後、DB2ZOSダイアレクトが機能しない

  23. 23

    Spring Boot / Spring Dataimport.sqlはSpring-Boot-1.0.0.RC1を実行しません

  24. 24

    Spring Boot 2.2.7からSpring Boot 2.3.0へのアップグレードエラー

  25. 25

    Spring Boot 2にアップグレードした後、キャッシュメトリックをプロメテウスに公開する方法は?

  26. 26

    Spring Boot1.3から1.4RC1にアップグレードするときに、org.hibernate.internal.SessionFactoryImpl。<init>によってスローされるAbstractMethodError

  27. 27

    Spring Boot1.3から1.4RC1にアップグレードするときに、org.hibernate.internal.SessionFactoryImpl。<init>によってスローされるAbstractMethodError

  28. 28

    Spring Boot1.3から1.4RC1にアップグレードするときに、org.hibernate.internal.SessionFactoryImpl。<init>によってスローされるAbstractMethodError

  29. 29

    Spring Boot 2.2へのアップグレード後にSpringboot WebFluxテストが失敗する

ホットタグ

アーカイブ