Announcement Announcement Module
Collapse
No announcement yet.
BeanNameAutoProxyCreator not eligable for autoproxying Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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)

      Comment


      • #4
        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.

        Comment


        • #5
          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...

          Comment


          • #6
            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!).

            Comment


            • #7
              And the solution is?

              Comment


              • #8
                Have you READ my post

                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!).

                Comment


                • #9
                  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>

                  Comment


                  • #10
                    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.

                    Comment


                    • #11
                      So I suppose u r using org.springframework.web.jsf.DelegatingVariableReso lver ?
                      If yes, then the stacktrace should be longer .
                      If no, then start to use it by defining it in faces-config.xml :
                      Code:
                      <application>
                      	    <variable-resolver>
                      		org.springframework.web.jsf.DelegatingVariableResolver
                      	    </variable-resolver>
                      	</application>
                      Cheers

                      Comment


                      • #12
                        Thanks, i already use this variableresolver, but this is not my problem now. the problem is, that BeanNameAutoProxyCreator can not reach any other bean to create a auto proxy.
                        I have 2 projects, the first it work but the second it doesn't.

                        Comment


                        • #13
                          Can you post the full stacktrace? Or try to set the log level for Spring to INFO or DEBUG.

                          Comment

                          Working...
                          X