我有一个使用aspectj进行日志记录的应用程序。最初,aspectj模块在我的原始应用程序中使用。后来我将aspectj模块作为一个单独的项目移动,并在我的主项目中添加了模块依赖项。现在当我运行我的主应用程序时,我得到一个运行时异常,如下所示 -
Mon Jan 09 2017 10:40:50 AM [main] WARN o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'xxxController': Unsatisfied dependency expressed through field 'xxxxManager': Error creating bean with name 'xxxManagerImpl': Unsatisfied dependency expressed through field 'xxxx': Error creating bean with name 'xxxInspectorImpl': Injection of autowired dependencies failed; nested exception is java.lang.VerifyError: Expecting a stackmap frame at branch target 51
Exception Details:
Location:
com/afl/axidot/service/impl/xxxx.getxxx(Ljava/util/List;)D @15: ifnull
Reason:
Expected stackmap frame at this location.
Bytecode:
0x0000000: 2b3a 04b2 0275 2a2a 1904 b801 e54e 2ac6
0x0000010: 0024 2ab6 00d6 1302 34b6 01f9 9900 17b8
0x0000020: 0232 2d2a b600 d613 0234 b601 f1c0 0234
0x0000030: b602 3e2a c600 4c2a b600 d613 0234 b601
0x0000040: f999 003f b802 3206 bd00 033a 1519 1503
0x0000050: 2a53 1915 0419 0453 1915 052d 53bb 027c
0x0000060: 5919 15b7 027d 1302 27b6 022d 2ab6 00d6
0x0000070: 1302 34b6 01f1 c002 34b6 0238 b802 58af
0x0000080: 2a19 042d b802 7faf
; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxInspectorImpl': Injection of autowired dependencies failed; nested exception is java.lang.VerifyError: Expecting a stackmap frame at branch target 51
Exception Details:
Location:
com/afl/axidot/service/impl/xxxx.getxxxx(Ljava/util/List;)D @15: ifnull
Reason:
Expected stackmap frame at this location.
Bytecode:
0x0000000: 2b3a 04b2 0275 2a2a 1904 b801 e54e 2ac6
0x0000010: 0024 2ab6 00d6 1302 34b6 01f9 9900 17b8
0x0000020: 0232 2d2a b600 d613 0234 b601 f1c0 0234
0x0000030: b602 3e2a c600 4c2a b600 d613 0234 b601
0x0000040: f999 003f b802 3206 bd00 033a 1519 1503
0x0000050: 2a53 1915 0419 0453 1915 052d 53bb 027c
0x0000060: 5919 15b7 027d 1302 27b6 022d 2ab6 00d6
0x0000070: 1302 34b6 01f1 c002 34b6 0238 b802 58af
0x0000080: 2a19 042d b802 7faf
Mon Jan 09 2017 10:40:50 AM [main] INFO o.a.catalina.core.StandardService - Stopping service Tomcat
Mon Jan 09 2017 10:40:50 AM [main] WARN o.s.boot.SpringApplication - Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor' defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]: Factory method 'transactionAdvisor' threw exception; nested exception is java.lang.NullPointerException)
Mon Jan 09 2017 10:40:50 AM [main] ERROR o.s.boot.SpringApplication - Application startup failed
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
at com.afl.axidot.application.xxxxApplication.main(xxxxApplication.java:29)
当我在我的主应用程序上进行maven安装时,它将毫无问题地运行。但是如果我在主应用程序中进行了任何更改,则会发生上述异常。我必须再做一个maven安装,没有问题。这是aspectj项目的pom.xml。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx.aspectj</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>logger</artifactId>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<aspectj.version>1.8.9</aspectj.version>
<java.source.version>1.8</java.source.version>
<java.target.version>1.8</java.target.version>
<aop.compliance.level>1.8</aop.compliance.level>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>${java.source.version}</source>
<target>${java.target.version}</target>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.9</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<source>${java.source.version}</source>
<target>${java.target.version}</target>
<complianceLevel>${aop.compliance.level}</complianceLevel>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
下面是我的主应用程序的pom.xml(不包括其他依赖项)
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd“&GT; 4.0.0
<groupId>com.xxx.axidot</groupId>
<artifactId>xxxx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.source.version>1.8</java.source.version>
<java.target.version>1.8</java.target.version>
<aop.compliance.level>1.8</aop.compliance.level>
<sonar.host.url>http://172.16.2.31:9000/</sonar.host.url>
<aspectj.version>1.8.9</aspectj.version>
<drools.version>6.4.0.Final</drools.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.SR4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.xxx.aspectj</groupId>
<artifactId>logger</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- AOP -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<dependency>
<groupId>com.afl.aspectj</groupId>
<artifactId>logger</artifactId>
</dependency>
</dependencies>
<build>
<finalName>xxx-xxx</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>${java.source.version}</source>
<target>${java.target.version}</target>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.9</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<source>${java.source.version}</source>
<target>${java.target.version}</target>
<complianceLevel>${aop.compliance.level}</complianceLevel>
<encoding>${project.build.sourceEncoding}</encoding>
<aspectLibraries>
<aspectLibrary>
<groupId>com.xxx.aspectj</groupId>
<artifactId>logger</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
当我将aspectj文件移动到我的主应用程序时,它工作正常。我使用-noverify运行并且工作,但它有时会崩溃jvm。这可能是什么问题?