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 8846853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:05:58+00:00 2026-06-14T12:05:58+00:00

I stuck with this problem. Used components: Spring 1.2.8, Hibernate 3.2.0 cr1, tomcat, struts,

  • 0

I stuck with this problem.

Used components: Spring 1.2.8, Hibernate 3.2.0 cr1, tomcat, struts, java 6

I am trying to get bean from ProxyFactoryBean with scope = prototype. I am not successful. I have no clue what is wrong.

Here is context:

<beans>

    <bean id="ruleCheckTask" class="rulechecker.RuleCheckTask" singleton="false">

    <bean id="ruleCheckTaskPrototype" class="org.springframework.aop.target.PrototypeTargetSource">
       <property name="targetBeanName" value="ruleCheckTask" />
    </bean>

    <bean id="transactionInterceptorRuleCheckTask" class="org.springframework.transaction.interceptor .TransactionInterceptor">
       <property name="transactionManager"> 
           <ref bean="transactionManager" />
       </property>
       <property name="transactionAttributeSource">
          <value>
              rulechecker.IRuleCheckTask.run=PROPAGATION_REQUIRE S_NEW
          </value>
       </property>
   </bean>

  <bean id="ruleCheckTaskService" class="org.springframework.aop.framework.ProxyFact oryBean">
         <property name="target" ref="ruleCheckTaskPrototype" />
         <property name="proxyInterfaces">
             <value>
                  rulechecker.IRuleCheckTask
             </value>
        </property>
        <property name="interceptorNames">
              <list>
                   <value>transactionInterceptorRuleCheckTask</value>
              </list>
        </property>
   </bean>
</beans>

In code when I do following:

……………….

……………….

IRuleCheckTask checkTask = (IRuleCheckTask) applicationContext.getBean(“ruleCheckTaskService”) ;
checkTask.setTestCase(oneTestCase);

I got following exception when trying call setTestCase on checkTask bean:

java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:287)
at org.springframework.aop.framework.ReflectiveMethod  Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:181)
at org.springframework.aop.framework.ReflectiveMethod    Invocation.proceed(ReflectiveMethodInvocation.java :148)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:96)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :170)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy21.setTestCase(Unknown Source)

It was working if in ProxyFactoryBean I used ruleCheckTask instead ruleCheckTaskPrototype. Problem is that in that case I always obtain singleton of ruleCheckTask. And I need always new instance.
One small thing RuleCheckTask implements Runnable interface.

Could anybody give me a hint?

Thank you

  • 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-14T12:05:59+00:00Added an answer on June 14, 2026 at 12:05 pm

    try with:

    <bean id="ruleCheckTaskService" class="org.springframework.aop.framework.ProxyFact oryBean">
             <property name="targetName" value="ruleCheckTask" />
             <property name="singleton" value="false" />  <!-- this do the trick -->
             <property name="proxyInterfaces">
                 <value>
                      rulechecker.IRuleCheckTask
                 </value>
            </property>
            <property name="interceptorNames">
                  <list>
                       <value>transactionInterceptorRuleCheckTask</value>
                  </list>
            </property>
       </bean>
    

    You could also set targetSource (no target) to ruleCheckTaskPrototype instead. The diference is that on the first one, you have an independient instance of the proxy configuration, on the second one, the PrototypeTargetSource gets a new instance on each request.

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

Sidebar

Related Questions

Hi i got stuck with this problem, i can't find out how to get
i am stuck with this small problem in my code. I am trying to
I am trying to get a better pattern / technique for this problem: I
So I'm stuck on this problem where I've been asked to write an function
I am currently stuck at this problem right now where I don't seem to
I got stuck in this problem for an hour. I am thinking this is
I'm currently stuck on this problem. I've hooked into the method_missing function in a
I got stuck with this problem. I wrap two tables inside of a h:form.
I am stuck with this problem for 3 days with no avail to solve
Hi I've been stuck on this problem for a while and would appreciate your

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.