Results 1 to 5 of 5

Thread: BridgeMethodResolver Unable to locate bridged method

  1. #1
    Join Date
    Aug 2005
    Location
    Sussex, UK
    Posts
    92

    Default RESOLVED - BridgeMethodResolver Unable to locate bridged method

    Hi
    When deploying a Bean (using Java Generics) on the server side, within an application context using <tx:annotation-driven transaction-manager="transactionManager"/> support, the BridgeMethodResolver is throwing an exception.
    This only occurs when the Bean attempts to override the methods within the generic super class, and where this super class implements a generic interface.
    Currently, I am unsure whether this is due to a misuse (or overuse) of generics, or whether it is a genuine bug within the BridgeMethodResolver.

    I have a test case hopefully explaining the issue as follows. Any help would be greatly appreciated.

    Abstract Domain Super
    Code:
    public abstract class DomainObjectSuper {
    
    }
    Domain Object
    Code:
    public class DomainObjectExtendsSuper extends DomainObjectSuper {
    
    }
    Generic Logic Interface
    Code:
    public interface IGenericInterface<D extends DomainObjectSuper> {
        <T> void doSomething(final D domainObject, final T value);
    }
    Base Logic Implementation
    Code:
    public abstract class AbstractImplementsInterface<D extends DomainObjectSuper> implements IGenericInterface<D> {
        public <T> void doSomething(D domainObject, T value) {
            // Base implementation of Functionality
        }
    
        public void anotherBaseMethod() {  
        }
    
    }
    True Logic Implementation
    Code:
    public class ExtendsAbstractImplementsInterface extends AbstractImplementsInterface<DomainObjectExtendsSuper> {
    
        @Override
        public <T> void doSomething(DomainObjectExtendsSuper domainObject, T value) {
            // Override the default implementation
            super.doSomething(domainObject, value);
        }
    }
    Test Case
    Code:
    public class GenericLogicTest extends TestCase {
        public void testSample() {
            Method[] methods = ExtendsAbstractImplementsInterface.class.getMethods();
            for (Method method : methods) {
                BridgeMethodResolver.findBridgedMethod(method);
            }
        }
    }
    Exception Thrown
    Code:
    java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public volatile void base.package.domain.ExtendsAbstractImplementsInterface.doSomething(base.package.domain.DomainObjectSuper,java.lang.Object)'
    	at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:91)
    Last edited by baronludwig; Apr 11th, 2007 at 06:45 AM. Reason: Issue resolved

  2. #2
    Join Date
    Aug 2005
    Location
    Sussex, UK
    Posts
    92

    Smile RESOLVED - BridgeMethodResolver Unable to locate bridged method

    For Info
    Posted a JIRA with test cases on this issue (http://opensource.atlassian.com/proj...owse/SPR-3357).
    Fix has been applied to 2.0.5. snapshot, if anyone encounters the same problem.

  3. #3
    Join Date
    Jan 2008
    Posts
    3

    Default Problem with Spring Proxying of Generic Methods

    Dear All,

    I'm encountering this old bug that's supposed to be fixed. I'm using Spring 2.5.3. Here's my class:

    @Configurable(preConstruction = true)
    @Entity
    @Immutable
    public class EvaluableItemEntityImpl extends ItemEntityImpl implements EvaluableItem
    {
    ...
    public <B extends ItemDataVisitor> void accept(B visitor)
    {
    visitor.visit(this);
    }
    }

    This causes the following runtime exception:
    Caused by: java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public void net.ruready.content.domain.evaluable.EvaluableItem EntityImpl.accept(net.ruready.api.common.visitor.V isitor)'

    If I switch to

    public void accept(ItemDataVisitor visitor) ,

    there's no exception. Is there a fix for this bug?

    Thanks so much,
    Oren

  4. #4
    Join Date
    Nov 2008
    Posts
    5

    Default Unable to locate bridged method for bridge method

    It seems the bug is still in Spring 2.5.5.
    We are also getting same exception with generics.

    Here are some details:


    I think we just run into another of those combinations with generics where
    matching is not done properly in BridgeMethodResolver. We are using spring 2.5.5.

    Stack trace for "Unable to locate bridged method for bridge method"

    Caused by: java.lang.IllegalStateException: Unable to locate bridged method for bridge method 'public volatile void com.bnpp.pb.tiger.dao.JournalSpaceDAO.cl
    ear(java.lang.Object)'
    at org.springframework.core.BridgeMethodResolver.find BridgedMethod(BridgeMethodResolver.java:89)
    at org.springframework.transaction.interceptor.Abstra ctFallbackTransactionAttributeSource.computeTransa ctionAttribute(AbstractFallbackTransactionAtt
    ributeSource.java:143)
    at org.springframework.transaction.interceptor.Abstra ctFallbackTransactionAttributeSource.getTransactio nAttribute(AbstractFallbackTransactionAttribu
    teSource.java:100)
    at org.springframework.transaction.interceptor.Transa ctionAttributeSourcePointcut.matches(TransactionAt tributeSourcePointcut.java:36)
    at org.springframework.aop.support.AopUtils.canApply( AopUtils.java:214)
    at org.springframework.aop.support.AopUtils.canApply( AopUtils.java:253)
    at org.springframework.aop.support.AopUtils.findAdvis orsThatCanApply(AopUtils.java:287)
    at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.findAdvisorsThatCanApply (AbstractAdvisorAutoProxyCreator.java:113)
    at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.findEligibleAdvisors(Abs tractAdvisorAutoProxyCreator.java:85)
    at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.getAdvicesAndAdvisorsFor Bean(AbstractAdvisorAutoProxyCreator.java:66)

    at org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.wrapIfNecessary(AbstractAutoPro xyCreator.java:360)
    at org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.postProcessAfterInitialization( AbstractAutoProxyCreator.java:324)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyBeanPostProcessors AfterInitialization(AbstractAutowireCapableBe
    anFactory.java:361)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1343)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:473)

    JournalSpaceDAO doesn't declare method clear. It just inherits it from parent generic class.

    public class JournalSpaceDAO extends GigaSpaceDAO {
    }

    public abstract class GigaSpaceDAO
    extends NonCachingGigaSpaceDAO implements GenericCachingDAO
    {
    @Override
    public void clear(
    Collection entities_)
    {
    }

    @Override
    public void clear(
    T entity_)
    {
    }

    }

    Thanks

    PS more info here http://blog.springsource.com/2007/01...ridge-too-far/

  5. #5
    Join Date
    Nov 2008
    Posts
    5

    Default Exclude rules for scanning

    Is there a way to specify some 'exclude' rules for a tag so it would
    skip scanning classes which cause the exception.

    @Transactional annotation is put usually on business layer methods
    and generic methods which create these issues are usually on DAO layer.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •