[
http://issues.apache.org/jira/browse/TAPESTRY-848?page=comments#action_12448138
]
Jan Normann Nielsen commented on TAPESTRY-848:
----------------------------------------------
It's problematic to give a test case because "the boss" let me show you too
much of our code. Instead, I've been digging into the problem and I have ended
up in the ComponentConstructorFactoryImpl.getComponentConstructor() method. The
important line is:
ComponentConstructor result = (ComponentConstructor)
_cachedConstructors.get(specification);
and when this one returns null, enhancement is performed. Two enhancements on
the same component class results in the error, that's the root of my problem.
Now how can the component class be enhanced twice? It's possible if
_cachedConstructors.get(specification) returns null at least twice for the same
component. Therefore, just before the line, I output the hashcode of the
specification parameter, and it shows the fact that multiple
IComponentSpecification instances for the same component exist, e.g. rendering
my page (which contains IFrames which result in multiple pages being rendered
simultaneously) gives the following output for the Insert component.
org.apache.tapestry.components.Insert 18891813
org.apache.tapestry.components.Insert 21977649
org.apache.tapestry.components.Insert 24229066
org.apache.tapestry.components.Insert 26810747
org.apache.tapestry.components.Insert 613258
org.apache.tapestry.components.Insert 8310913
As long as the component doesn't have annotations, there is no problem. But my
components are also loaded multiple times, e.g.
dk.mydomain.projects.tapestry.components.ExternalPageIframe 13472381
dk.mydomain.projects.tapestry.components.ExternalPageIframe 29460424
The dk.mydomain.projects.tapestry.components.ExternalPageIframe has annotations
and the method
_chain.performEnhancement(eo, specification);
therefore fails misably because the ExternalPageIframe class is enhanced twice.
The question that needs to be answered now is: Why are there multiple instances
of IComponentSpecification for the same components, even for the built-in
components? The example above shows that there are 6 IComponentSpecification
for the org.apache.tapestry.components.Insert component.
> Binding Exceptions more prominent with annotations
> --------------------------------------------------
>
> Key: TAPESTRY-848
> URL: http://issues.apache.org/jira/browse/TAPESTRY-848
> Project: Tapestry
> Issue Type: Bug
> Components: Annotations
> Affects Versions: 4.0
> Environment: Gentoo Linux, Jboss 4.0.2 JDK 5.0
> Reporter: Chris Chiappone
> Assigned To: Jesse Kuhnert
> Fix For: 4.1.1
>
> Attachments: patch.txt
>
>
> As posted in the tapestry forums:
> At first I thought I could work around these issues but they seem to
> be popping up more and more throughout my application. Its really
> becoming an issue for me.
> Ever since I have moved from .page and .jwc files to annotations I get
> these exceptions more often.
> I don't believe I am doing anything wrong with these annotations. As
> you can see by the following one I have just declared a DelegateBean
> in my class. Using
> @Bean(SimpleValidationDeleage)
> public abstract SimpleValidationDelegate getDelegate();
> That same Delegate is used on mulitple pages and in components. From
> what I understand this should be acceptable.
> This issue also has sprung up on my declaring the same Persistent
> property on different pages or components using the @Persist
> annotation.
> I've also recieved a similar exception doing the following in which both the
> page and component contain:
> @InjectState("visit")
> public abstract void getVisitObj();
> I was able to work around the issue by changing the component to be
> @InjectState("visit")
> public abstract void getVisitObjComp();
> I didn't run into these problems before I used annotations. I'd also
> hate to have to go back to .page and .jwc files since there are so
> many files that I've changed.
> Here is an one of the exceptions:
> Exception invoking listener method searchLinkListener of component
> SearchResults/border.search: Error: An error occured processing
> annotation @org.apache.tapestry.annotations.Bean(value=class
> view.util.SimpleValidationDelegate, lifecycle=REQUEST, initializer=)
> of public abstract view.util.SimpleValidationDelegate
> view.components.BasicSearch.getDelegate(): Bean delegate has already
> been declared (at Annotation
> @org.apache.tapestry.annotations.Bean(value=class
> view.util.SimpleValidationDelegate, lifecycle=REQUEST, initializer=)
> of public abstract view.util.SimpleValidationDelegate
> view.components.BasicSearch.getDelegate()).
> binding: [EMAIL PROTECTED]
> parameter listener, component=SearchResults/border.search,
> methodName=searchLinkListener,
> location=context:/WEB-INF/BasicSearch.html, line 16]
> component: [EMAIL PROTECTED]/border.search]
> location: context:/WEB-INF/BasicSearch.html, line 16
> 11 <br>
> 12 <input jwcid="companyField"
> 13 autocomplete="off" size="20" id="txt1" /> <br>
> 14 <input jwcid="@Submit" name="Submit" label="message:submit" /></form>
> 15
> 16 <a jwcid="@DirectLink" listener="listener:searchLinkListener">
> 17 » <span key="advanced">Advanced</span>
> 18 </a>
> 19 </div>
> 20 </td>
> 21 </tr>
> org.apache.hivemind.ApplicationRuntimeException
> Error: An error occured processing annotation
> @org.apache.tapestry.annotations.Bean(value=class
> util.SimpleValidationDelegate, lifecycle=REQUEST, initializer=) of
> public abstract view.util.SimpleValidationDelegate
> view.components.BasicSearch.getDelegate(): Bean delegate has already
> been declared (at Annotation
> @org.apache.tapestry.annotations.Bean(value=class
> view.util.SimpleValidationDelegate, lifecycle=REQUEST, initializer=)
> of public abstract view.util.SimpleValidationDelegate
> view.components.BasicSearch.getDelegate()).
> location: Annotation @org.apache.tapestry.annotations.Bean(value=class
> view.util.SimpleValidationDelegate, lifecycle=REQUEST, initializer=)
> of public abstract view.util.SimpleValidationDelegate
> view.components.BasicSearch.getDelegate()
> org.apache.hivemind.ApplicationRuntimeException
> Bean delegate has already been declared (at Annotation
> @org.apache.tapestry.annotations.Bean(value=class
> view.util.SimpleValidationDelegate, lifecycle=REQUEST, initializer=)
> of public abstract view.util.SimpleValidationDelegate
> view.components.BasicSearch.getDelegate()).
> location: Annotation @org.apache.tapestry.annotations.Bean(value=class
> view.util.SimpleValidationDelegate, lifecycle=REQUEST, initializer=)
> of public abstract view.util.SimpleValidationDelegate
> view.components.BasicSearch.getDelegate()
> Stack Trace:
> org.apache.tapestry.spec.ComponentSpecification.addBeanSpecification(ComponentSpecification.java:410)
> org.apache.tapestry.annotations.BeanAnnotationWorker.performEnhancement(BeanAnnotationWorker.java:64)
> org.apache.tapestry.annotations.AnnotationEnhancementWorker.performMethodEnhancement(AnnotationEnhancementWorker.java:142)
> org.apache.tapestry.annotations.AnnotationEnhancementWorker.performMethodEnhancement(AnnotationEnhancementWorker.java:110)
> org.apache.tapestry.annotations.AnnotationEnhancementWorker.performEnhancement(AnnotationEnhancementWorker.java:70)
> $EnhancementWorker_1090cd8cc4b.performEnhancement($EnhancementWorker_1090cd8cc4b.java)
> $EnhancementWorker_1090cd8cc4d.performEnhancement($EnhancementWorker_1090cd8cc4d.java)
> $EnhancementWorker_1090cd8cc2d.performEnhancement($EnhancementWorker_1090cd8cc2d.java)
> org.apache.tapestry.services.impl.ComponentConstructorFactoryImpl.getComponentConstructor(ComponentConstructorFactoryImpl.java:97)
> $ComponentConstructorFactory_1090cd8cc1a.getComponentConstructor($ComponentConstructorFactory_1090cd8cc1a.java)
> org.apache.tapestry.pageload.PageLoader.instantiateComponent(PageLoader.java:531)
> org.apache.tapestry.pageload.PageLoader.createImplicitComponent(PageLoader.java:481)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]