You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bogdan Calmac <bc...@gmail.com> on 2007/03/22 15:07:33 UTC

T5 - ASO cannot be in the same package as the page?

After creating my own ASO object, I kept getting the
ClassCastExeception below when accessing it, until I had the
inspiration to move the ASO in a different package than the page. Then
it worked fine. Is this just a bug or intentional design?

This is the exception (with 5.0.3). The ASO reader throws a ClassCastException:
Caused by: java.lang.ClassCastException:
org.byteberry.survey.pages.SurveySession
	at org.byteberry.survey.pages.SurveyDetail2._$read_surveySession(SurveyDetail2.java)
	at org.byteberry.survey.pages.SurveyDetail2.getQuestion0(SurveyDetail2.java:55)
	at $PropertyConduit_11179d07ce4.get($PropertyConduit_11179d07ce4.java)
	at org.apache.tapestry.internal.bindings.PropBinding.get(PropBinding.java:54)

For more details, the ASO is defined with:

  @ApplicationState
  private SurveySession surveySession;


and then accessed in:

  public SurveyQuestion getQuestion0() throws SQLException
  {
    return surveySession.questions.get(0);
  }


Thanks,

Bogdan Calmac.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5 - ASO cannot be in the same package as the page?

Posted by Peter Beshai <pe...@gmail.com>.
Not 100% sure, but it seems like Tapestry has designated
my.package.pagesfor Tapestry Pages (convention) and
my.package.components for Tapestry Components (convention again). So
Tapestry will treat the classes in those packages as pages/components
respectively. It is likely a better idea anyway to keep your data objects in
a separate package from your pages :-)

On 3/22/07, Bogdan Calmac <bc...@gmail.com> wrote:
>
> After creating my own ASO object, I kept getting the
> ClassCastExeception below when accessing it, until I had the
> inspiration to move the ASO in a different package than the page. Then
> it worked fine. Is this just a bug or intentional design?
>
> This is the exception (with 5.0.3). The ASO reader throws a
> ClassCastException:
> Caused by: java.lang.ClassCastException:
> org.byteberry.survey.pages.SurveySession
>         at org.byteberry.survey.pages.SurveyDetail2._$read_surveySession(
> SurveyDetail2.java)
>         at org.byteberry.survey.pages.SurveyDetail2.getQuestion0(
> SurveyDetail2.java:55)
>         at
> $PropertyConduit_11179d07ce4.get($PropertyConduit_11179d07ce4.java)
>         at org.apache.tapestry.internal.bindings.PropBinding.get(
> PropBinding.java:54)
>
> For more details, the ASO is defined with:
>
>   @ApplicationState
>   private SurveySession surveySession;
>
>
> and then accessed in:
>
>   public SurveyQuestion getQuestion0() throws SQLException
>   {
>     return surveySession.questions.get(0);
>   }
>
>
> Thanks,
>
> Bogdan Calmac.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Peter Beshai

Computer Science Student
University of Waterloo

Re: T5 - ASO cannot be in the same package as the page?

Posted by Stephan Schwab <sn...@caimito.net>.

Howard Lewis Ship wrote:
> 
> By putting the ASO class into the pages package, Tapestry created an
> enhanced version of the ASO class, as if it were a component. This
> enhanced class is in the class loader used for pages, components and
> mixins.  The reference to the ASO in the page is a reference to the
> enhanced version, not the normal version.  The ASO that's injected is
> from the normal class loader, not the enhanced class loader, thus a
> ClassCastException.
> 

I encountered the same problem by accident, but did suspect something
quickly as I had moved the class and the exception showed up on the next
refresh.

Still it would be nice for Tapestry to report more precisely what has
happened, if that's possible.

Stephan
--
http://www.stephan-schwab.com
-- 
View this message in context: http://www.nabble.com/T5---ASO-cannot-be-in-the-same-package-as-the-page--tf3447765.html#a9622369
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5 - ASO cannot be in the same package as the page?

Posted by Howard Lewis Ship <hl...@gmail.com>.
By putting the ASO class into the pages package, Tapestry created an
enhanced version of the ASO class, as if it were a component. This
enhanced class is in the class loader used for pages, components and
mixins.  The reference to the ASO in the page is a reference to the
enhanced version, not the normal version.  The ASO that's injected is
from the normal class loader, not the enhanced class loader, thus a
ClassCastException.

On 3/22/07, Bogdan Calmac <bc...@gmail.com> wrote:
> Hi Peter,
>
> I see your point. Any class in the pages package can be accessed
> through an URL and it doesn't make sense to store anything else than
> pages there.
>
> But on the other hand, the behaviour that I reported is totally
> obscure and not in line with the nice error reporting of tapestry. If
> somebody does put an ASO in the pages package because of ignorance (as
> I did) a ClassCastException from a generated method is not likely to
> guide to the source of the error. I see two ways to handle this
> nicely:
> 1. When the @ApplicationState annotation is processed report an error
> "An ASO cannot be part of the special tapestry packages". This way it
> would take 2 minutes to fix the problem instead of 2 hours.
> 2. In the documentation for the ASO mention that it is not a good
> practice to put the ASO in any of tapestry specific packages (pages,
> components, ...) but let the people do it if they really want to.
>
> This kind of small thing make quite a difference when starting to work
> with a framework like Tapestry where there's a lot going on behind the
> scene and as a newcomer you have no ideea that something apparently OK
> is not what it seems.
>
> Thanks,
>
> Bogdan.
>
>
> On 3/22/07, Anjana Gopinath <an...@truenorth1.com> wrote:
> > I beleive you are supposed to put only your page classes in the page
> > folder. Refer tapestry 5 tutorial, page 19.
> >
> >
> >
> >
> >
> > Anjana Gopinath
> >
> >
> >
> >
> >
> >
> > On Mar 22, 2007, at 10:07 AM, Bogdan Calmac wrote:
> >
> > > After creating my own ASO object, I kept getting the
> > > ClassCastExeception below when accessing it, until I had the
> > > inspiration to move the ASO in a different package than the page. Then
> > > it worked fine. Is this just a bug or intentional design?
> > >
> > > This is the exception (with 5.0.3). The ASO reader throws a
> > > ClassCastException:
> > > Caused by: java.lang.ClassCastException:
> > > org.byteberry.survey.pages.SurveySession
> > >       at org.byteberry.survey.pages.SurveyDetail2._$read_surveySession
> > > (SurveyDetail2.java)
> > >       at org.byteberry.survey.pages.SurveyDetail2.getQuestion0
> > > (SurveyDetail2.java:55)
> > >       at $PropertyConduit_11179d07ce4.get
> > > ($PropertyConduit_11179d07ce4.java)
> > >       at org.apache.tapestry.internal.bindings.PropBinding.get
> > > (PropBinding.java:54)
> > >
> > > For more details, the ASO is defined with:
> > >
> > >  @ApplicationState
> > >  private SurveySession surveySession;
> > >
> > >
> > > and then accessed in:
> > >
> > >  public SurveyQuestion getQuestion0() throws SQLException
> > >  {
> > >    return surveySession.questions.get(0);
> > >  }
> > >
> > >
> > > Thanks,
> > >
> > > Bogdan Calmac.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5 - ASO cannot be in the same package as the page?

Posted by Bogdan Calmac <bc...@gmail.com>.
Hi Peter,

I see your point. Any class in the pages package can be accessed
through an URL and it doesn't make sense to store anything else than
pages there.

But on the other hand, the behaviour that I reported is totally
obscure and not in line with the nice error reporting of tapestry. If
somebody does put an ASO in the pages package because of ignorance (as
I did) a ClassCastException from a generated method is not likely to
guide to the source of the error. I see two ways to handle this
nicely:
1. When the @ApplicationState annotation is processed report an error
"An ASO cannot be part of the special tapestry packages". This way it
would take 2 minutes to fix the problem instead of 2 hours.
2. In the documentation for the ASO mention that it is not a good
practice to put the ASO in any of tapestry specific packages (pages,
components, ...) but let the people do it if they really want to.

This kind of small thing make quite a difference when starting to work
with a framework like Tapestry where there's a lot going on behind the
scene and as a newcomer you have no ideea that something apparently OK
is not what it seems.

Thanks,

Bogdan.


On 3/22/07, Anjana Gopinath <an...@truenorth1.com> wrote:
> I beleive you are supposed to put only your page classes in the page
> folder. Refer tapestry 5 tutorial, page 19.
>
>
>
>
>
> Anjana Gopinath
>
>
>
>
>
>
> On Mar 22, 2007, at 10:07 AM, Bogdan Calmac wrote:
>
> > After creating my own ASO object, I kept getting the
> > ClassCastExeception below when accessing it, until I had the
> > inspiration to move the ASO in a different package than the page. Then
> > it worked fine. Is this just a bug or intentional design?
> >
> > This is the exception (with 5.0.3). The ASO reader throws a
> > ClassCastException:
> > Caused by: java.lang.ClassCastException:
> > org.byteberry.survey.pages.SurveySession
> >       at org.byteberry.survey.pages.SurveyDetail2._$read_surveySession
> > (SurveyDetail2.java)
> >       at org.byteberry.survey.pages.SurveyDetail2.getQuestion0
> > (SurveyDetail2.java:55)
> >       at $PropertyConduit_11179d07ce4.get
> > ($PropertyConduit_11179d07ce4.java)
> >       at org.apache.tapestry.internal.bindings.PropBinding.get
> > (PropBinding.java:54)
> >
> > For more details, the ASO is defined with:
> >
> >  @ApplicationState
> >  private SurveySession surveySession;
> >
> >
> > and then accessed in:
> >
> >  public SurveyQuestion getQuestion0() throws SQLException
> >  {
> >    return surveySession.questions.get(0);
> >  }
> >
> >
> > Thanks,
> >
> > Bogdan Calmac.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5 - ASO cannot be in the same package as the page?

Posted by Anjana Gopinath <an...@truenorth1.com>.
I beleive you are supposed to put only your page classes in the page  
folder. Refer tapestry 5 tutorial, page 19.





Anjana Gopinath






On Mar 22, 2007, at 10:07 AM, Bogdan Calmac wrote:

> After creating my own ASO object, I kept getting the
> ClassCastExeception below when accessing it, until I had the
> inspiration to move the ASO in a different package than the page. Then
> it worked fine. Is this just a bug or intentional design?
>
> This is the exception (with 5.0.3). The ASO reader throws a  
> ClassCastException:
> Caused by: java.lang.ClassCastException:
> org.byteberry.survey.pages.SurveySession
> 	at org.byteberry.survey.pages.SurveyDetail2._$read_surveySession 
> (SurveyDetail2.java)
> 	at org.byteberry.survey.pages.SurveyDetail2.getQuestion0 
> (SurveyDetail2.java:55)
> 	at $PropertyConduit_11179d07ce4.get 
> ($PropertyConduit_11179d07ce4.java)
> 	at org.apache.tapestry.internal.bindings.PropBinding.get 
> (PropBinding.java:54)
>
> For more details, the ASO is defined with:
>
>  @ApplicationState
>  private SurveySession surveySession;
>
>
> and then accessed in:
>
>  public SurveyQuestion getQuestion0() throws SQLException
>  {
>    return surveySession.questions.get(0);
>  }
>
>
> Thanks,
>
> Bogdan Calmac.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>