AspectJ SpringアプリケーションでProceedingJoinPointを引数として使用したときや、hello.controllersなどのすべてのコントローラからキャプチャしようとしたとき* I/O例外が発生しました。ただし、これは、クラスを直接参照し、ProceedingJointPointではなくJointPointのみを使用する場合は発生しません。AspectJがある場所でSpring IOExceptionが発生しました
[2017年9月6日10:01:17311]アーティファクトdaniel2:戦争が爆発:にjava.io.IOException:com.sun.enterprise.admin.remote.RemoteFailureException:エラーは、展開中に発生した:例外を搭載しながら、アプリケーション:java.lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:org.springframework.beans.factory.BeanCreationException:ServletContextリソースで定義された 'messageSource'という名前のBeanを作成中にエラーが発生しました[/ WEB-INF /dispatcher-servlet.xml]:Beanのインスタンス化が失敗する前のBeanPostProcessor。ネストされた例外はorg.springframework.beans.factory.BeanCreationExceptionです: 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration'という名前のBeanを作成中にエラーが発生しました:Beanのインスタンス化が失敗する前にBeanPostProcessorが失敗しました。 org.springframework.beans.factory.BeanCreationException:名前が 'org.springframework.transaction.config.internalTransactionAdvisor'のBeanを作成中にエラーが発生しました:Bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0'への参照を解決できませんbeanプロパティ 'transactionAttributeSource';ネストされた例外はorg.springframework.beans.factory.BeanCreationExceptionです:名前 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0'を持つBeanの作成中にエラーが発生しました:Beanのインスタンス化前のBeanPostProcessorが失敗しました。ネストされた例外はjava.lang.IllegalArgumentExceptionです。ProceedingJoinPointは、周囲のアドバイスでのみサポートされています。詳細については、server.logを参照してください。
私のAspectJのは、私は時間のために、この問題で苦労しているし、任意の洞察力をいただければ幸いです
package hello.controllers;
import hello.api.APIResponse;
import hello.api.UploadAPIResponse;
import hello.aspect.AntiJavascript;
import hello.models.Upload;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;
@Controller
public class MessageAPIController extends APIController {
@RequestMapping(value="/message", method = RequestMethod.GET)
public String showMessage(String message, ModelMap model) throws Exception {
model.addAttribute("message", message);
return new String("message");
}
}
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"
xmlns:tx="http://www.springframework.org/schema/tx">
<aop:aspectj-autoproxy />
<bean id="xssAspect" class="hello.aspect.XSSAspect" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="hello" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="268435456"/>
</bean>
<bean id="freeMarkerConfigurationFactory" init-method="createConfiguration"
class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">
<property name="templateLoaderPath" value="classpath:/freemarker"/>
<property name="preferFileSystemAccess" value="false"/>
</bean>
<bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/*******" />
<property name="username" value="root" />
<property name="password" value="*********" />
</bean>
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.gmail.com"/>
<property name="port" value="25"/>
<property name="username" value="**********"/>
<property name="password" value="********"/>
<property name="javaMailProperties">
<props>
<prop key="mail.transport.protocol">smtp</prop>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
<prop key="mail.debug">true</prop>
</props>
</property>
</bean>
<bean id="TaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="5" />
<property name="maxPoolSize" value="10" />
<property name="queueCapacity" value="25" />
<property name="daemon" value="true" />
</bean>
<bean id="persistenceExceptionTranslationPostProcessor"
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
<bean name="VehicleDao" class="hello.dao.VehicleDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean name="ModelDao" class="hello.dao.ModelDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean name="ManufactureDao" class="hello.dao.ManufactureDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean name="UserDao" class="hello.dao.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean name="CurrencyDao" class="hello.dao.CurrencyDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean name="ProposalDao" class="hello.dao.ProposalDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean name="AcceptedProposalDao" class="hello.dao.AcceptedProposalDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean name="ManufactureModelDao" class="hello.dao.ManufactureModelDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean name="UploadDao" class="hello.dao.UploadDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean name="VehicleService" class="hello.services.VehicleServiceImpl">
<property name="vehicleDao" ref="VehicleDao" />
<property name="manufactureModelDao" ref="ManufactureModelDao" />
</bean>
<bean name="UserService" class="hello.services.UserServiceImpl">
<property name="userDao" ref="UserDao" />
</bean>
<bean name="CurrencyService" class="hello.services.CurrencyServiceImpl">
</bean>
<bean name="ManufactureService" class="hello.services.ManufactureServiceImpl">
</bean>
<bean name="ProposalService" class="hello.services.ProposalServiceImpl">
<property name="proposalDao" ref="ProposalDao"></property>
<property name="acceptedProposalDao" ref="AcceptedProposalDao"></property>
</bean>
<bean name="ModelService" class="hello.services.ModelServiceImpl">
</bean>
<bean name="EmailService" class="hello.services.EmailServiceImpl">
<property name="taskExecutor" ref="TaskExecutor" />
</bean>
<bean name="UploadService" class="hello.services.StandardUploadService">
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages" />
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
</mvc:interceptor>
</mvc:interceptors>
<context:component-scan base-package="hello" />
<tx:annotation-driven transaction-manager="transactionManager"/>
<mvc:annotation-driven />
<context:annotation-config />
</beans>
MessageAPIController
@Aspect
public class XSSAspect {
@Around(value = "execution(* hello.controllers.*(..))")
public void before(final ProceedingJoinPoint joinPoint) throws Throwable {
Object[] arguments = joinPoint.getArgs();
for (int i = 0; i < arguments.length; i++) {
if (arguments[i] instanceof String) {
String s = (String) arguments[i];
s = "testing";
arguments[i] = s;
}
}
joinPoint.proceed(arguments);
}
}
ディスパッチャサーブレットを提出します。 ありがとうございます。
コントローラーを直接参照する際に最初の問題を解決していただきありがとうございます。私はマップできない2番目の問題:@Around(value = "execution(* hello.controllers。*(..))") –
このように変更することができます:@Around( "実行(* hello.controllers.MessageAPIController .. *。*(..))") – cameron
ありがとうございます。それは問題を解決しませんでした。私はまた、すべてのコントローラがMessageAPIControllerだけでなく影響を受けたいと思っています。 –