java.lang.IllegalArgumentException: warning no match for this type name: UserDaoImpl [Xlint:invalidAbsoluteTypeName]

10,160

Solution 1

I don't know why this old question popped up on my RSS feed today, but just for the record, the correct answer is that in annotation-style AspectJ pointcuts you need to use fully-qualified class names including package name, i.e. the pointcut should be

@Pointcut("execution(* dao.UserDaoImpl.mySave())")

That is what [Xlint:invalidAbsoluteTypeName] implies in the first place.

I wonder why nobody else noticed that back in 2011.


Update: There is one case in which you might not need to specify a fully qualified class name (FQCN): if the aspect happens to be in the exact same package as the class or annotation used in the pointcut. But that is fragile because if you ever refactor, moving around classes between packages, the aspect would still compile but its behaviour break. So you better use FQCN and let your IDE help you refactor class and package name changes in sync with aspects.

Solution 2

Are the spaces between annotation. and the class names in

<bean class="org.springframework.web.servlet.mvc.annotation. DefaultAnnotationHandlerMapping" />

<bean class="org.springframework.web.servlet.mvc.annotation. AnnotationMethodHandlerAdapter" />

only a copy paste error here or are they really in your xml? If so, then remove them and try again.

Solution 3

Your UserController has @Autowired property named UserDaoImpl. This is invalid, it should be userDaoImpl

Share:
10,160
Amit
Author by

Amit

"Be a good person, but never try to prove it." #SOreadytohelp I am a professional programmer and a Certified Scrum Master (CSM) currently working as Full Stack Java Developer. Technical Skills Java (Core and Advaced), Spring Security, MicroServices, AWS, C, C++, Android, JSP, JavaScript, jQuery, AngularJS, HTML,JSP, PL/SQL, Hibernate etc. Areas of Interest Any kind of programming, R &amp; D which pays enough money Java based Application Development i.e. Core Java, J2EE, J2ME, JNI, Web Development Software designing and Solution analysis for cloud plateforms. Have knowledge of AWS architecture but can work on Azure or Google cloud too if case 1 above is true :). Web Services and Microservices Development. Web application security and related frameworks and projects like prevention against OWASP's Top 10 vulnerabilities. Algorithm optimization, fine tuning, research &amp; development.

Updated on June 05, 2022

Comments

  • Amit
    Amit almost 2 years

    I am developing a Spring 3.0.2 based project. From last three days it is showing the below error.

    java.lang.IllegalArgumentException: warning no match for this type name: UserDaoImpl [Xlint:invalidAbsoluteTypeName]

    How do I solve this error?

    My applicationContext file is:

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xmlns:p="http://www.springframework.org/schema/p"
            xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
                http://www.springframework.org/schema/context
                http://www.springframework.org/schema/context/spring-context.xsd
                http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans.xsd
                http://www.springframework.org/schema/aop
                http://www.springframework.org/schema/aop/spring-aop.xsd">
    
            <aop:aspectj-autoproxy/>
            <context:component-scan base-package="web"/>
    <!--        <import resource="appicationContext.xml"/>        -->
    
        <bean id="viewResolver"
              class="org.springframework.web.servlet.view.InternalResourceViewResolver"
              p:prefix="jsp/" p:suffix=".jsp" />  
    
        <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
    
        <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
    
    
            <bean id="sessionFactory" class="hibernatefiles.HibernateUtil" factory-method="getSessionFactory"/>           
    
            <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
                    <property name="sessionFactory" ref="sessionFactory"/>
            </bean>
    
            <bean id="userDaoImpl"  class="dao.UserDaoImpl"/>
    
            <bean id = "profiler" class = "Profiler.AspectProfiler" />
    
         <bean name="/userRegistration.htm" class="web.UserController" depends-on="userDaoImpl">
                <property name="userDaoImpl" ref="userDaoImp"/>       
         </bean>       
    </beans>
    

    The stack trace is:

       org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController' defined in file [D:\JAVA Stuffs\projects\NewSpringDemo\build\web\WEB-INF\classes\web\UserController.class]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: **UserDaoImpl [Xlint:invalidAbsoluteTypeName]**
            org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
            org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
            org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
            org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
            org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
            org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
            org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
            org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
            org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
            org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
            org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
            org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
            org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
            javax.servlet.GenericServlet.init(GenericServlet.java:160)
            org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
            org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
            org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
            org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
            org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
            org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
            org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
            java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
            java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            java.lang.Thread.run(Thread.java:662)
        root cause
    
        java.lang.IllegalArgumentException: warning no match for this type name: UserDaoImpl [Xlint:invalidAbsoluteTypeName]
            org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:315)
            org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:204)
            org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:191)
            org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:172)
            org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200)
            org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)
            org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)
            org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
            org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
            org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
            org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
            org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
            org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
            org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1418)
            org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
            org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
            org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
            org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
            org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
            org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
            org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
            org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
            org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
            org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
            org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
            org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
            org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
            javax.servlet.GenericServlet.init(GenericServlet.java:160)
            org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
            org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
            org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
            org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
            org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
            org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
            org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
            java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
            java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            java.lang.Thread.run(Thread.java:662)
    ...
    

    The userDaoImpl is autowired in UserController class which is annotated with @Controller:

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package web;
    
    import dao.UserDaoImpl;
    import domain.UsersTable;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.ModelMap;
    import org.springframework.web.bind.annotation.ModelAttribute;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.SessionAttributes;
    import org.springframework.web.servlet.ModelAndView;
    
    /**
     *
     * @author amit
     */
    
    @Controller
    @RequestMapping("/userRegistration.htm")
    @SessionAttributes("user")
    public class UserController {
    
        @Autowired
        private UserDaoImpl userDaoImpl;
    
        public UserDaoImpl getUserDaoImpl() {
            return userDaoImpl;
        }
    
        public void setUserDaoImpl(UserDaoImpl userDaoImpl) {
            this.userDaoImpl = userDaoImpl;
        }   
    
        @RequestMapping(method = RequestMethod.GET)
        public String showForm(ModelMap model) {
            System.out.println("Get request found. . . . *****************************");
            UsersTable user = new UsersTable();
            model.addAttribute("user", user);
            return "registrationForm";
        }
    
        @RequestMapping(method = RequestMethod.POST)
        public ModelAndView OnSubmit(@ModelAttribute("user") UsersTable user) {
            System.out.println("User Object is : "+user);
            userDaoImpl.saveUser(user);
            return new ModelAndView("userConfirm", "user", user);
        }
    }
    

    Aspect Profiler:

    package Profiler;
    import org.aspectj.lang.ProceedingJoinPoint;
    import org.aspectj.lang.annotation.Around;
    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.Pointcut;
    
    @Aspect
    public class AspectProfiler {
       @Pointcut("execution(* UserDaoImpl.mySave())")
                public void insertionProfiler(){ }
    
        @Around("insertionProfiler()")
                public void aroundInsertionProfiler(ProceedingJoinPoint pjp) throws Throwable{
                System.out.println("Before Insertion....");
                pjp.proceed();
                System.out.println("After saving the data I am back.");
        }
    
    }