Announcement Announcement Module
Collapse
No announcement yet.
Formal Unbound in Pointcut Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Formal Unbound in Pointcut

    I'm getting the above error when I add the AOP elements to my config files. I'm brand new to Spring, so it's likely something simple. Would appreciate it if anyone could point out what's wrong.

    The blankety-blank forum won't let me post the config files because it thinks the URI's are links to other sites. If someone knows how I can post the config files, let me know.
    ______________________

    The full error message is:

    Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dataSource': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAd visor#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdv isor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:405)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:220)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:423)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:729)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:381)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:139)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:93)
    at Test.main(Test.java:24)
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAd visor#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdv isor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.Construc torResolver.autowireConstructor(ConstructorResolve r.java:243)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.autowireConstructor(Abs tractAutowireCapableBeanFactory.java:923)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:833)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:440)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:220)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.aop.framework.autoproxy.BeanFa ctoryAdvisorRetrievalHelper.findAdvisorBeans(BeanF actoryAdvisorRetrievalHelper.java:87)
    at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.findCandidateAdvisors(Ab stractAdvisorAutoProxyCreator.java:98)
    at org.springframework.aop.aspectj.autoproxy.AspectJA wareAdvisorAutoProxyCreator.shouldSkip(AspectJAwar eAdvisorAutoProxyCreator.java:105)
    at org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.postProcessBeforeInstantiation( AbstractAutoProxyCreator.java:266)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyBeanPostProcessors BeforeInstantiation(AbstractAutowireCapableBeanFac tory.java:789)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.resolveBeforeInstantiat ion(AbstractAutowireCapableBeanFactory.java:760)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:399)
    ... 13 more
    Caused by: org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdv isor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:111)
    at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:87)
    at org.springframework.beans.factory.support.Construc torResolver.autowireConstructor(ConstructorResolve r.java:237)
    ... 31 more
    Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.aspectj.weaver.tools.PointcutParser.parsePoint cutExpression(PointcutParser.java:316)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.buildPointcutExpression(AspectJExpressionP ointcut.java:205)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.checkReadyToMatch(AspectJExpressionPointcu t.java:192)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.getMethodMatcher(AspectJExpressionPointcut .java:178)
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.buildSafePointcut(AbstractAspectJAdvice.java:1 89)
    at org.springframework.aop.aspectj.AspectJPointcutAdv isor.<init>(AspectJPointcutAdvisor.java:51)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:494)
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:96)
    ... 33 more

  • #2
    post your configuration, remove any @ (replace with {at} ) and remove links.

    When posting code/stacktraces use the [ code][/code ] tags that way it remains readable.

    We had to restrict posting urls/@ to prevent spam runs, so sorry for the minor inconvenience, however it should be ok after 5 posts.

    Comment


    • #3
      Config Files

      This is extremely frustrating. The forum software claims I have URL's in the post, but I've removed anything that looks like a URL, & it STILL complains. Even worse, it won't tell me WHAT part it objects to.

      Is there a way ATTACH the config files? It won't accept *.xml extensions.

      If I can't show the config files, this forum is pretty useless. Not a good introduction to Spring, so far.

      Any suggestions would be greatly appreciated.

      Comment


      • #4
        Dummy 1

        I'm going to try entering some dummy posts to get past the "5 posts" threshold & see if it will let me submit the config files after that.

        Comment


        • #5
          Dummy 2

          Trying to get to the 5-posts level

          Comment


          • #6
            Dummy 3

            Trying to get to the 5-post level.

            Comment


            • #7
              6th Attempt.

              I've made 5 posts now, so hopefully this will get through.
              Code:
              <?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:jee="http://www.springframework.org/schema/jee"
              	xsi:schemaLocation="
                 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                 http://www.springframework.org/schema/jee   http://www.springframework.org/schema/jee/spring-jee-2.5.xsd"
              >
                 <jee:jndi-lookup id="dataSource" 
                    jndi-name="com/uprr/app/tns/tns_PoolDS" 
                    resource-ref="true"
                    default-ref="developmentDataSource"
                 />
              
              	<bean id="developmentDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
              		<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
              		<property name="url" value="jdbc:oracle:thin:@dev091.oracle.uprr.com:1521:dev091" />
              		<property name="username" value="dtns999" />
              		<property name="password" value="tns_dev08" />
              	</bean>
                 
              </beans>
              ___________________
              
              <?xml version="1.0" encoding="UTF-8"?>
              <beans 
                 xmlns="http://www.springframework.org/schema/beans"
                 xmlns:aop="http://www.springframework.org/schema/aop"
              	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
                 "
                 default-autowire="byName"
              >
              	<bean id="maintenanceTransactionTypeDao" class="com.uprr.db.dao.spring.stats.MaintenanceTransactionTypeDAO" />
                 <bean id="maintenanceItemTypeDao"        class="com.uprr.db.dao.spring.stats.MaintenanceItemTypeDAO"        />
                 <bean id="maintenanceTransactionDao"     class="com.uprr.db.dao.spring.stats.MaintenanceTransactionDAO"     />
                 <bean id="throwAdvice"                   class="com.uprr.aop.ThrowAdvice"                                   />
               
                 <aop:config>
              
                    <aop:pointcut id="anyMethod" expression="execution(* *(..))" /> 
                    
                    <aop:aspect ref="throwAdvice">
                       <aop:after-throwing throwing="error" pointcut-ref="anyMethod" method="afterThrowing" />
                    </aop:aspect>
              
                 </aop:config>
                  
              </beans>
              __________________
              
              import java.util.Iterator;
              
              import org.apache.log4j.Logger;
              import org.apache.log4j.xml.DOMConfigurator;
              import org.springframework.context.support.ClassPathXmlApplicationContext;
              
              import com.uprr.db.dao.spring.stats.MaintenanceItemTypeDAO;
              import com.uprr.db.dao.spring.stats.MaintenanceTransactionTypeDAO;
              
              //----------------------------------------------------------------------------------------------
              public class Test
              {
              public static final Logger logger = Logger.getLogger("com.uprr.tns.test");
              
              //----------------------------------------------------------------------------------------------
              public static void main(final String[] args) throws Exception
              {
              	DOMConfigurator.configure("log4j-test.xml");
              	/**
              	 * In production:
              	 * getRootLogger().setLevel(Level.ERROR);
              	 */
              	final String configFiles[] = {"spring-test.xml", "spring-tns-api.xml"};
              	ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(configFiles);
              
              	testTransactionTypes(context);
              	testItemTypes(context);
              }
              //----------------------------------------------------------------------------------------------
              public static void testItemTypes(ClassPathXmlApplicationContext context) throws Exception
              {
              	MaintenanceItemTypeDAO dao = MaintenanceItemTypeDAO.getBean(context);
              	Iterator iterator = dao.getAllTypes().iterator();
              	while (iterator.hasNext()) {
              		logger.info(iterator.next());
              	}
              	final Integer systemNumber = new Integer(3);
              	logger.info("Item type # " + systemNumber + " = " + dao.getDescription(systemNumber));
              }
              //----------------------------------------------------------------------------------------------
              public static void testTransactionTypes(ClassPathXmlApplicationContext context) throws Exception
              {
              	MaintenanceTransactionTypeDAO dao = MaintenanceTransactionTypeDAO.getBean(context);
              	Iterator iterator = dao.getAllTypes().iterator();
              	while (iterator.hasNext()) {
              		logger.info(iterator.next());
              	}
              	final Integer systemNumber = new Integer(3);
              	logger.info("Transaction type # " + systemNumber + " = " + dao.getDescription(systemNumber));
              }
              //----------------------------------------------------------------------------------------------
              }

              Comment


              • #8
                Please use multiple code blocks instead of dumping everything into one large one. Next to that you didn't include you advice/aspect...

                Comment


                • #9
                  Code Blocks Divided Up

                  Hopefully this is more readable:

                  Code:
                  <?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:jee="http://www.springframework.org/schema/jee"
                  	xsi:schemaLocation="
                     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                     http://www.springframework.org/schema/jee   http://www.springframework.org/schema/jee/spring-jee-2.5.xsd"
                  >
                     <jee:jndi-lookup id="dataSource" 
                        jndi-name="com/uprr/app/tns/tns_PoolDS" 
                        resource-ref="true"
                        default-ref="developmentDataSource"
                     />
                  
                  	<bean id="developmentDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                  		<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
                  		<property name="url" value="jdbc:oracle:thin:@dev091.oracle.uprr.com:1521:dev091" />
                  		<property name="username" value="dtns999" />
                  		<property name="password" value="xxx" />
                  	</bean>
                     
                  </beans>
                  Code:
                  <?xml version="1.0" encoding="UTF-8"?>
                  <beans 
                     xmlns="http://www.springframework.org/schema/beans"
                     xmlns:aop="http://www.springframework.org/schema/aop"
                  	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
                     "
                     default-autowire="byName"
                  >
                  	<bean id="maintenanceTransactionTypeDao" class="com.uprr.db.dao.spring.stats.MaintenanceTransactionTypeDAO" />
                     <bean id="maintenanceItemTypeDao"        class="com.uprr.db.dao.spring.stats.MaintenanceItemTypeDAO"        />
                     <bean id="maintenanceTransactionDao"     class="com.uprr.db.dao.spring.stats.MaintenanceTransactionDAO"     />
                     <bean id="throwAdvice"                   class="com.uprr.aop.ThrowAdvice"                                   />
                   
                     <aop:config>
                  
                        <aop:pointcut id="anyMethod" expression="execution(* *(..))" /> 
                        
                        <aop:aspect ref="throwAdvice">
                           <aop:after-throwing throwing="error" pointcut-ref="anyMethod" method="afterThrowing" />
                        </aop:aspect>
                  
                     </aop:config>
                     
                      
                  </beans>
                  Code:
                  import java.util.Iterator;
                  
                  import org.apache.log4j.Logger;
                  import org.apache.log4j.xml.DOMConfigurator;
                  import org.springframework.context.support.ClassPathXmlApplicationContext;
                  
                  import com.uprr.db.dao.spring.stats.MaintenanceItemTypeDAO;
                  import com.uprr.db.dao.spring.stats.MaintenanceTransactionTypeDAO;
                  
                  //----------------------------------------------------------------------------------------------
                  public class Test
                  {
                  public static final Logger logger = Logger.getLogger("com.uprr.tns.test");
                  
                  //----------------------------------------------------------------------------------------------
                  public static void main(final String[] args) throws Exception
                  {
                  	DOMConfigurator.configure("log4j-test.xml");
                  	/**
                  	 * In production:
                  	 * getRootLogger().setLevel(Level.ERROR);
                  	 */
                  	final String configFiles[] = {"spring-test.xml", "spring-tns-api.xml"};
                  	ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(configFiles);
                  
                  	testTransactionTypes(context);
                  	testItemTypes(context);
                  }
                  //----------------------------------------------------------------------------------------------
                  public static void testItemTypes(ClassPathXmlApplicationContext context) throws Exception
                  {
                  	MaintenanceItemTypeDAO dao = MaintenanceItemTypeDAO.getBean(context);
                  	Iterator iterator = dao.getAllTypes().iterator();
                  	while (iterator.hasNext()) {
                  		logger.info(iterator.next());
                  	}
                  	final Integer systemNumber = new Integer(3);
                  	logger.info("Item type # " + systemNumber + " = " + dao.getDescription(systemNumber));
                  }
                  //----------------------------------------------------------------------------------------------
                  public static void testTransactionTypes(ClassPathXmlApplicationContext context) throws Exception
                  {
                  	MaintenanceTransactionTypeDAO dao = MaintenanceTransactionTypeDAO.getBean(context);
                  	Iterator iterator = dao.getAllTypes().iterator();
                  	while (iterator.hasNext()) {
                  		logger.info(iterator.next());
                  	}
                  	final Integer systemNumber = new Integer(3);
                  	logger.info("Transaction type # " + systemNumber + " = " + dao.getDescription(systemNumber));
                  }
                  //----------------------------------------------------------------------------------------------
                  }

                  Comment


                  • #10
                    Originally posted by mdeinum
                    Please use multiple code blocks instead of dumping everything into one large one. Next to that you didn't include you advice/aspect...
                    This still holds . Without your advice it is hard to tell, just one pointer you probably want to use the spring test classes for what you are doing.

                    Comment


                    • #11
                      The Advice

                      Yeah, your're right. Guess it's kind of hard without seeing the advice (hides red face):

                      Code:
                      package com.uprr.aop;
                      
                      import java.lang.reflect.Method;
                      
                      import org.apache.log4j.Logger;
                      import org.springframework.aop.ThrowsAdvice;
                      
                      import com.uprr.util.ApiLogger;
                      
                      //-----------------------------------------------------------------------
                      /**
                       * Invoked when an advised class throws a {@link Throwable}. The main purpose of this advice is
                       * to ensure that all errors are recorded in the log.
                       */
                      public class ThrowAdvice implements ThrowsAdvice {
                      
                      //-----------------------------------------------------------------------
                      /**
                       * Reacts to an exception being thrown. Currently, this method just logs the exception.
                       * @param method The throwing method.
                       * @param args Arguments to the throwing method.
                       * @param thrower The throwing object.
                       * @param error The item thrown.
                       * @throws RuntimeException if the API logger has not been configured.
                       */
                      public void afterThrowing(final Method method, final Object[] args, final Object thrower, 
                      	final Throwable error) {
                      	final Logger logger = Logger.getLogger(ApiLogger.NAME);
                      	if (logger == null) {
                      		String message = ApiLogger.NOT_FOUND;
                      		message += " Error that could not be recorded: " + error;
                      		throw new RuntimeException(message);
                      	}
                      	logger.error("An exception was thrown by " + thrower + '.' + method + '(' + args + ')');
                      	logger.error("Details: " + error);
                      }
                      //-----------------------------------------------------------------------
                      }

                      Comment


                      • #12
                        The problem is you are mixing different kinds of aop. You shouldn't define a method to execute neither the throws clause in your xml. It will automatically detect that it is a Afterthrows advice.

                        If you want to stick with your way. Remove the ThrowsAdvice interface and implement your method with a JoinPoint and an Exception.

                        Code:
                        public class ThrowAdvice {
                        
                        //-----------------------------------------------------------------------
                        /**
                         * Reacts to an exception being thrown. Currently, this method just logs the exception.
                         * @param method The throwing method.
                         * @param args Arguments to the throwing method.
                         * @param thrower The throwing object.
                         * @param error The item thrown.
                         * @throws RuntimeException if the API logger has not been configured.
                         */
                        public void afterThrowing(JoinPoint jp, final Exception error) {
                        	final Logger logger = Logger.getLogger(ApiLogger.NAME);
                        	if (logger == null) {
                        		String message = ApiLogger.NOT_FOUND;
                        		message += " Error that could not be recorded: " + error;
                        		throw new RuntimeException(message);
                        	}
                        	logger.error("An exception was thrown by " + jp.getSignature().getShortString());
                        	logger.error("Details: " + error);
                        }
                        //-----------------------------------------------------------------------
                        }
                        Also I'm not sure if you want to throw a new RuntimeException if your logger cannot be found.... At least include your root exception if you rethrow an exception.

                        Comment


                        • #13
                          XML Setup

                          Thanks for the quick analysis. Please be patient with me, as this is only my second day working with AOP & I've had no formal training.

                          What is meant by "mixing different kinds of aop"?

                          Comment


                          • #14
                            You are trying to mix AspectJ style AOP with the AOPAlliance style of AOP (that is where the ThrowsAdvice interface comes from).

                            Comment


                            • #15
                              How do Do XML?

                              Well, maybe I should just ask it this way: How do I set up the XML file so the throws advice is executed when anything is thrown?

                              I've tried numerous different ways of doing this in the XML config file, none of which works. I can't find a working example of this in either the Spring reference manual or in _Spring in Action_. Surely this must be a common task, but I can't seem to find it covered anywhere.

                              Comment

                              Working...
                              X