Друзей,ошибки с Spring Security 3.0.2 х Spring 3.0.1 - Proxies не создаются
я потерял несколько дней поиска в Интернете для ответа по поводу моей проблемы, и ничего не нашел, что может на самом деле решить его. Я пробовал несколько разных конфигураций, но все равно, безрезультатно.
Вот моя проблема:
У меня есть приложение, которое работает отлично, пока я не решил добавить Spring Security. После того, как я представил этот компонент, я получаю эти сообщения при запуске 6.0.24 кота:
INFO: Bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
Mar 10, 2010 3:46:47 PM org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
INFO: Bean 'org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource#0' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
Mar 10, 2010 3:46:47 PM org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
INFO: Bean 'org.springframework.security.methodSecurityMetadataSourceAdvisor' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
Mar 10, 2010 3:46:48 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
который я не получал. В результате теперь все классы, вместо получения прокси для бизнес-классов, получают POJO, которые не совершают транзакции. Я использовал аннотацию @PersistenceContext и получал EntityManager, но после того, как появилась Spring Security, я продолжал получать NPE (EntityManager больше не вводился). Так что я попытался простирающийся JpaDaoSupport и добраться до EntityManager по-другому, например:
getJpaTemplate()
.execute(new JpaCallback() {
public Object doInJpa(final EntityManager em)
throws PersistenceException {
// Here, I get an EntityManager...
}
});
Это работает, потому что теперь я не получаю NPE больше. Но все же это не прокси.
Если я прокомментирую файл app-security.xml и не загружаю его компоненты, приложение работает нормально. Если я это сделаю, прокси не создаются, и приложение не совершает никаких транзакций.
Мое приложение-security.xml файл:
[?xml version="1.0" encoding="UTF-8"?]
[beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"
]
[bean id="interfaceDecisionManagerBean" class="com.mot.br.jag.security.InterfaceDecisionManager" /]
[security:global-method-security
access-decision-manager-ref="interfaceDecisionManagerBean"
/]
[security:http auto-config="false" access-decision-manager-ref="interfaceDecisionManagerBean"]
[security:form-login login-page="/login.html"
login-processing-url="/loginProcess"
default-target-url="/index.jsp"
authentication-failure-url="/login.html?login_error=1" /]
[security:anonymous /]
[security:logout logout-url="/logout" logout-success-url="/logoutSuccess.html" /]
[security:port-mappings]
[security:port-mapping http="8080" https="8443"/]
[/security:port-mappings]
[/security:http]
[security:ldap-server
id="motoLDAP"
url="[private... ]"
/]
[security:authentication-manager]
[security:ldap-authentication-provider
server-ref="motoLDAP"
user-search-filter="(uid={0})"
user-search-base="ou=intranet"
/]
[/security:authentication-manager]
[bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource"]
[constructor-arg value="[... private ...]"/]
[/bean]
[bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch"]
[constructor-arg index="0" value="ou=intranet"/]
[constructor-arg index="1" value="(uid={0})"/]
[constructor-arg index="2" ref="contextSource" /]
[/bean]
[bean id="ldapAuthentication" class="com.mot.br.jag.security.authentication.LDAPAuthentication"]
[constructor-arg index="0"]
[bean id="ldapProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider"]
[constructor-arg]
[bean class="org.springframework.security.ldap.authentication.BindAuthenticator"]
[constructor-arg ref="contextSource" /]
[property name="userSearch" ref="userSearch" /]
[/bean]
[/constructor-arg]
[/bean]
[/constructor-arg]
[constructor-arg index="1" ref="userSearch" /]
[/bean]
[/beans]
Мое приложение-persistence.xml является:
[?xml version="1.0" encoding="UTF-8"?]
[beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.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-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd"]
[bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /]
[bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /]
[bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator" /]
[!-- ENTITY MANAGERS --]
[bean id="interfaceEMF"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"]
[property name="persistenceUnitName" value="interfaceDS" /]
[/bean]
[!-- TRANSACTION MANAGERS --]
[bean id="interfaceTM" class="org.springframework.orm.jpa.JpaTransactionManager"]
[property name="entityManagerFactory" ref="interfaceEMF" /]
[/bean]
[!-- TX ADVICES --]
[tx:advice id="txAdvice" transaction-manager="interfaceTM"]
[tx:attributes]
[tx:method name="*" propagation="REQUIRED" rollback-for="Throwable" /]
[/tx:attributes]
[/tx:advice]
[!-- AOP CONFIG --]
[aop:aspectj-autoproxy /]
[aop:config]
[aop:pointcut id="businessMethods" expression="execution(* com.mot.br.jag.business.Business+.*(..))" /]
[aop:advisor advice-ref="txAdvice" pointcut-ref="businessMethods" /]
[/aop:config]
[/beans]
Я бегу из идей ... Я читал, что это ошибка, которая возникает из-за порядка, в котором бобы предварительно обработаны, но я также читал, что эта ошибка уже исправлена. Извините, если я не выражаю себя ясно, английский не мой первый язык. Я был бы рад ответить на любые вопросы, если бы он руководил мной в правильном направлении. :)
Большое спасибо заранее, Родриго
Вы хотите сказать, что он работал с весной безопасности 2.x ?? –
Вы не ясно заявили, в чем проблема. Вы говорите, что получаете NPE - можете ли вы опубликовать трассировку стека этого NPE? Вы также говорите: «Если я закомментирую файл app-security.xml и не загружаю его компоненты, приложение отлично работает», вам нужно быть немного более конкретным здесь - это _really_ true, если вы удалите весь файл или просто объявление ''? Где у вас есть аннотации, которые будут подхвачены обработчиками аннотаций? Вы смешиваете @Transactional и @Secured аннотации на тех же бобах? Больше информации пожалуйста! –