Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: BeanNameAutoProxyCreator not eligable for autoproxying

  1. #1
    Join Date
    Jul 2007
    Location
    France
    Posts
    8

    Default BeanNameAutoProxyCreator not eligable for autoproxying

    In order to create interceptors for each service bean to manage my exceptions, i created a advisor from the class BeanNameAutoProxyCreator.

    <bean id="RuntimeAdvice" class="mypackage.InterceptExceptionAdvice"></bean>

    <bean class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="beanNames">
    <value>rmyService</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>RuntimeAdvice</value>
    </list>
    </property>
    </bean>

    But this can't instanciate the bean service and i have the following error:
    not eligable for autoproxying.
    do you have any idea, how can i resolve this problem?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Please don't crosspost! This is a duplicate of this.

    For as far as I know that isn't an error but simply a INFO/WARN message indicating that a bean isn't going to be autoproxied. However which and how is hard to determine without the real stacktrace. However I still expect that your application runs fine with the message.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jul 2007
    Location
    France
    Posts
    8

    Default

    No, the application stopped, and the stacktrace :
    11:45:00,244 ERROR ApplicationImpl:createAndMaybeStoreManagedBeans:26 3 - Managedbean rmyServiceBean could not be created Can't instantiate class: 'mypackage.rmyService.@ad483'.
    javax.faces.FacesException: Can't instantiate class: 'mypackage.rmyService.@ad483'.
    at com.sun.faces.config.ManagedBeanFactory.getConvert edValueConsideringPrimitives(ManagedBeanFactory.ja va:869)
    at com.sun.faces.config.ManagedBeanFactory.setPropert iesIntoBean(ManagedBeanFactory.java:555)
    at com.sun.faces.config.ManagedBeanFactory.newInstanc e(ManagedBeanFactory.java:233)
    at com.sun.faces.application.ApplicationAssociate.cre ateAndMaybeStoreManagedBeans(ApplicationAssociate. java:256)

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    please use [ code][ /code] tags when posting code, makes your post more readable.

    Your application stops because it cannot create an instance (do you have a no-arg constructor!) which is not because of the error you posted earlier.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Jul 2007
    Location
    France
    Posts
    8

    Default

    i don't have any arg in the constructor of my business beans.
    The problem is, that i use the same interceptor in oder project, it work very good. I can intercept all the exceptions what i thrown before.
    The Spring documentation is not helpfull for that case.
    I don't know what can i do...

  6. #6
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    As I stated before it isn't due to your interceptor! It has to do with your bean. The exception you get is quite clear in regards to that

    Code:
    javax.faces.FacesException: Can't instantiate class: 'mypackage.rmyService.@ad483'.
    at com.sun.faces.config.ManagedBeanFactory.getConvert edValueConsideringPrimitives(ManagedBeanFactory.ja va:869)
    at com.sun.faces.config.ManagedBeanFactory.setPropert iesIntoBean(ManagedBeanFactory.java:555)
    at com.sun.faces.config.ManagedBeanFactory.newInstanc e(ManagedBeanFactory.java:233)
    at com.sun.faces.application.ApplicationAssociate.cre ateAndMaybeStoreManagedBeans(ApplicationAssociate. java:256)
    Post some relevant configuration, stacktrace(s) and code. Keep in mind that when you do so that you use [ code][/code] tags (without the spaces!).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  7. #7
    Join Date
    Jul 2007
    Location
    France
    Posts
    8

    Default

    And the solution is?

  8. #8
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Have you READ my post

    Quote Originally Posted by mdeinum
    Post some relevant configuration, stacktrace(s) and code. Keep in mind that when you do so that you use [ code][/code] tags (without the spaces!).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  9. #9
    Join Date
    Jul 2007
    Location
    France
    Posts
    8

    Default

    faces config.xml
    Code:
    <managed-bean>
    		<description>Bean de gestion des Référentiels</description>
    		<managed-bean-name>myBean</managed-bean-name>
    		<managed-bean-class>
    			mypackage.myBean
    		</managed-bean-class>
    		<managed-bean-scope>request</managed-bean-scope>
    		<managed-property>
    			<property-name>service</property-name>
    			<value>#{myServiceProxy}</value>
    		</managed-property>
    		<managed-property>
    			<property-name>myId</property-name>
    			<value>#{param.myID}</value>
    		</managed-property>
    	</managed-bean>
    InterceptedExceptionAdvice.java
    Code:
    public class InterceptExceptionAdvice implements ThrowsAdvice {
    
    	ResourceBundle bundle = ResourceBundle
    			.getBundle("mypackage.Exception");
    
    	String text = null;
    
    	public void afterThrowing(HibernateException he) throws TechnicalException {
    		text = bundle.getString(he.getMessage().toString());
    		FacesContext.getCurrentInstance().addMessage(
    				"TechnicalException",
    				new FacesMessage(FacesMessage.SEVERITY_ERROR,					"TechnicalException", text));
    		throw new TechnicalException(he);
    	}
    Applicationcontext.xml
    Code:
    	<bean id="RuntimeAdvice" class="mypackage.InterceptExceptionAdvice"></bean>
    	
    	<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
    	<property name="beanNames">
    			<value>myServiceProxy</value>
    	</property>
    	<property name="interceptorNames">
     		<list>
       			<value>RuntimeAdvice</value>
     		</list>
    	</property>
    	</bean>

  10. #10
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Those aren't the classes I'm interested in . The problem is in another class.

    On a side note you might have a potential problem in your InterceptExceptionAdvice, you are keeping state, which due to the fact that the bean is a singleton isn't a good idea.

    Code:
    public class InterceptExceptionAdvice implements ThrowsAdvice {
    
    	private final ResourceBundle bundle = ResourceBundle.getBundle("mypackage.Exception");
    
    	public void afterThrowing(HibernateException he) throws TechnicalException {
    		final String text = bundle.getString(he.getMessage().toString());
    		FacesContext.getCurrentInstance().addMessage("TechnicalException", new FacesMessage(FacesMessage.SEVERITY_ERROR, "TechnicalException", text));
    		throw new TechnicalException(he);
    	}
    would be better.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •