users@jersey.java.net

Re: [Jersey] Jersey Spring CGLIB2 is not available

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 16 Nov 2009 13:14:06 +0100

Hi,

I think what is happening is that AOP is being implicitly utilized.

Notice the following in the cause:

Caused by: org.springframework.aop.framework.AopConfigException: Cannot
proxy target class because CGLIB2 is not available. Add CGLIB to the
class
path or specify proxy interfaces. at
org
.springframework
.aop
.framework
.DefaultAopProxyFactory.createAopProxy(DefaultAopProxyFactory.java:67)
at
org
.springframework
.aop
.framework.ProxyCreatorSupport.createAopProxy(ProxyCreatorSupport.java:
106)
at
org
.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:
110)


I suspect it is the following in your Spring config:

  <global-method-security secured-annotations="enabled" access-
decision-manager-ref="businessAccessDecisionManager" />

and you may or may not be using @Secured on methods of your resource
class. I dunno if the above declaration means that all components are
proxied for AOP or not.

Paul.

On Nov 16, 2009, at 12:58 PM, Nabil Benothman wrote:

> Hi Paul,
> I would like to thank you for your answer. In my project i do not
> use AOP. I had this error in an earlier project having the same
> configuration with a small difference (applicationContext.xml, web-
> xml, pom.xml, etc.) but when i added CGLIB dependency the error
> disappeared and i can acces my resources without any problem. You
> find bellow my configuration files content.
>
> Thanks in advance.
>
> web.xml
> -----------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
> ">
> <display-name>WebEng-web</display-name>
> <description/>
>
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>/WEB-INF/applicationContext-security.xml</param-
> value>
> </context-param>
> <context-param>
> <param-name>log4jConfigLocation</param-name>
> <param-value>/WEB-INF/log4j.properties</param-value>
> </context-param>
> <filter>
> <filter-name>springSecurityFilterChain</filter-name>
> <filter-class>org.springframework.web.filter.DelegatingFilterProxy
> </filter-class>
> </filter>
>
> <filter-mapping>
> <filter-name>springSecurityFilterChain</filter-name>
> <url-pattern>/*</url-pattern>
> <dispatcher>REQUEST</dispatcher>
> <dispatcher>FORWARD</dispatcher>
> <dispatcher>INCLUDE</dispatcher>
> </filter-mapping>
>
> <listener>
> <listener-class>org.springframework.web.context.ContextLoaderListener
> </listener-class>
> </listener>
> <listener>
> <listener-
> class
> >org.springframework.security.ui.session.HttpSessionEventPublisher</
> listener-class>
> </listener>
>
> <listener>
> <listener-class>org.springframework.web.context.request.RequestContextListener
> </listener-class>
> </listener>
>
> <welcome-file-list>
> <welcome-file>index.jsp</welcome-file>
> </welcome-file-list>
>
> <context-param>
> <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
> <param-value>.xhtml</param-value>
> </context-param>
> <context-param>
> <param-name>facelets.DEVELOPMENT</param-name>
> <param-value>false</param-value>
> </context-param>
> <context-param>
> <param-name>facelets.SKIP_COMMENTS</param-name>
> <param-value>true</param-value>
> </context-param>
> <servlet>
> <servlet-name>Faces Servlet</servlet-name>
> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
> <load-on-startup>1</load-on-startup>
> </servlet>
>
> <servlet>
> <servlet-name>Jersey Spring</servlet-name>
> <servlet-
> class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</
> servlet-class>
> </servlet>
> <servlet-mapping>
> <servlet-name>Jersey Spring</servlet-name>
> <url-pattern>/resources/*</url-pattern>
> </servlet-mapping>
>
> <persistence-context-ref>
> <persistence-context-ref-name>WebEngPU</persistence-context-
> ref-name>
> <persistence-unit-name>WebEngPU</persistence-unit-name>
> </persistence-context-ref>
>
> <resource-ref>
> <res-ref-name>UserTransaction</res-ref-name>
> <res-type>javax.transaction.UserTransaction</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
> <servlet-mapping>
> <servlet-name>Faces Servlet</servlet-name>
> <url-pattern>*.jsf</url-pattern>
> </servlet-mapping>
>
> <context-param>
> <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
> <param-value>server</param-value>
> </context-param>
>
> <context-param>
> <param-name>org.richfaces.SKIN</param-name>
> <param-value>blueSky</param-value>
> </context-param>
>
> <context-param>
> <param-name>org.richfaces.CONTROL_SKINNING</param-name>
> <param-value>enable</param-value>
> </context-param>
>
> <filter>
> <display-name>RichFaces Filter</display-name>
> <filter-name>richfaces</filter-name>
> <filter-class>org.ajax4jsf.Filter</filter-class>
> <init-param>
> <param-name>maxRequestSize</param-name>
> <param-value>5242880</param-value>
> </init-param>
> <init-param>
> <param-name>createTempFiles</param-name>
> <param-value>false</param-value>
> </init-param>
> </filter>
>
> <filter-mapping>
> <filter-name>richfaces</filter-name>
> <servlet-name>Faces Servlet</servlet-name>
> <dispatcher>REQUEST</dispatcher>
> <dispatcher>FORWARD</dispatcher>
> <dispatcher>INCLUDE</dispatcher>
> </filter-mapping>
>
> <listener>
> <listener-class>com.sun.faces.config.ConfigureListener</
> listener-class>
> </listener>
> </web-app>
>
>
>
> applicationContext.xml
> -----------------------------
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans:beans xmlns="http://www.springframework.org/schema/security"
> xmlns:beans="http://www.springframework.org/schema/beans"
> xmlns:aop="http://www.springframework.org/schema/aop"
> xmlns:util="http://www.springframework.org/schema/util"
> xmlns:context="http://www.springframework.org/schema/context"
> 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-2.5.xsd
> http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
> http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
> http://www.springframework.org/schema/
> context http://www.springframework.org/schema/context/spring-context-2.5.xsd
> http://www.springframework.org/schema/
> security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd
> ">
>
> <context:component-scan base-package="com.webeng.services"/>
> <global-method-security secured-annotations="enabled" access-
> decision-manager-ref="businessAccessDecisionManager" />
>
> <http auto-config="true" access-decision-manager-
> ref="accessDecisionManager" access-denied-page="/403.jsf">
> <intercept-url pattern="/resources/**"
> access="ROLE_USER,ROLE_ADMIN" />
> <intercept-url pattern="/secure/**"
> access="ROLE_USER,ROLE_ADMIN" />
> <form-login login-page="/login.jsf" default-target-url="/
> index.jsp" authentication-failure-url="/login.jsf?error=1" />
> <logout logout-success-url="/login.jsf" />
> </http>
>
> <authentication-manager alias="authenticationManager" />
>
> <beans:bean id="authVoter"
> class="org.springframework.security.vote.AuthenticatedVoter" />
> <beans:bean id="roleVoter"
> class="org.springframework.security.vote.RoleVoter"/>
> <beans:bean id="authenticationController"
> class="com.webeng.security.AuthenticationController" scope="session">
> <beans:property name="authenticationManager">
> <beans:ref bean="authenticationManager"/>
> </beans:property>
> </beans:bean>
>
> <beans:bean id="accessDecisionManager"
> class="org.springframework.security.vote.AffirmativeBased">
> <beans:property name="allowIfAllAbstainDecisions"
> value="false" />
> <beans:property name="decisionVoters">
> <beans:list>
> <beans:ref local="authVoter"/>
> <beans:ref local="roleVoter"/>
> </beans:list>
> </beans:property>
> </beans:bean>
> <beans:bean id="businessAccessDecisionManager"
> class="org.springframework.security.vote.UnanimousBased">
> <beans:property name="allowIfAllAbstainDecisions"
> value="true" />
> <beans:property name="decisionVoters">
> <beans:list>
> <beans:ref local="authVoter"/>
> <beans:ref local="roleVoter"/>
> </beans:list>
> </beans:property>
> </beans:bean>
> <authentication-provider>
> <password-encoder hash="sha" ref="passwordEncoder">
> <salt-source user-property="username" />
> </password-encoder>
> <jdbc-user-service data-source-ref="dataSource"
> users-by-username-query="SELECT
> username,password,enabled FROM ACCOUNTS WHERE username = ?"
> authorities-by-username-query="SELECT
> username,authority FROM AUTHORITIES WHERE username = ?"/>
> </authentication-provider>
>
> <beans:bean id="passwordEncoder"
> class
> ="org.springframework.security.providers.encoding.ShaPasswordEncoder">
> <beans:constructor-arg value="512"/>
> </beans:bean>
>
> <beans:bean id="transactionManager"
> class
> ="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> <beans:property name="dataSource" ref="dataSource" />
> </beans:bean>
> <beans:bean id="dataSource"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
> <beans:property name="driverClassName"
> value="com.mysql.jdbc.Driver"/>
> <beans:property name="url" value="jdbc:mysql://localhost:
> 3306/mydb"/>
> <beans:property name="username" value="rootmaster"/>
> <beans:property name="password" value="*********"/>
> </beans:bean>
> </beans:beans>
>
>
>
>
> View this message in context: Re: [Jersey] Jersey Spring CGLIB2 is
> not available
> Sent from the Jersey mailing list archive at Nabble.com.