Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8426389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:31:25+00:00 2026-06-10T04:31:25+00:00

I tried to implement AOP but I get exception (java.lang.ClassCastException) java.lang.ClassCastException: $Proxy0 cannot be

  • 0

I tried to implement AOP but I get exception (java.lang.ClassCastException) java.lang.ClassCastException: $Proxy0 cannot be cast to myPackage.Person on (2) line. What could be the problem? The Person must be Thread, so it extends Thread class.

MAIN

1. ApplicationContext ctx = new ClassPathXmlApplicationContext("config/appContext.xml");
2. Person p = (Person)ctx.getBean("p1");
3. p.start(); 

PERSON

public class Person extends Thread{

    private String name;

    public Person(String name) {
        setPersonName(name);
    }

    public void setPersonName(String name) {
        this.name = name;
    }    
}

ASPECT

public class LogSettersCalls {

    public void logSetterCall(JoinPoint theJoinPoint)
    {
        String methodName = theJoinPoint.getSignature().getName();
        Object newValue = theJoinPoint.getArgs()[0];
        Object theObject = theJoinPoint.getTarget();
        System.out.println(theObject );
    }
}

CONFIG

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       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-lazy-init="true">

    <aop:config>
        <aop:pointcut expression="execution(void set*(*))" id="theSettersLogger" />
        <aop:aspect ref="logSettersCallsBean">
            <aop:before pointcut-ref="theSettersLogger" method="logSetterCall"/>
        </aop:aspect>
    </aop:config>
   <bean id="logSettersCallsBean" class="aop.LogSettersCalls" />


    <bean id="p1" class="myPackage.Person" >    
        <constructor-arg index="0" type="java.lang.String" value="igor"/>
    </bean>
</beans>

df

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:31:26+00:00Added an answer on June 10, 2026 at 4:31 am

    Leaving aside the fact that I’m not sure it’s intuitive or suitable to derive Person from Thread (can you not use composition or similar?), I suspect the issue is that the AOP is rewriting your class and it’s no longer a Person.

    I would separate the implementation (PersonImpl) from a suitable interface (Person) and the cast should then work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tried to implement Tagit to my website, but I can't get the array
I tried to implement __concat__ , but it didn't work >>> class lHolder(): ...
I have tried to implement css sticky footer on my page but it doesn't
I tried to implement IEnumerator< Status > but got errors about two different Properties
I tried to implement the - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section to get the text
i tried to implement this code that move UIImageView's objects, i get a compiler
I tried to implement rtmps with red5 but was having an error that the
I've tried to implement this CSS3 slideshow on my site ( http://www.designmadeingermany.de/slideshow/ ) But
I tried to implement a send-receive example via a socket but It didn't work
I tried to implement the Strassen algorithm for matrix multiplication with C++, but the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.