Page with @Persist and default value fails to instantiate

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Page with @Persist and default value fails to instantiate

Deepak
I'm just beginning with Tapestry and referring to "Tapestry 5, Building Web
Applications" by Alexander Kolesnikov. But I'm using version 5.3.7.

I have a page with a property annotated with @Persist and a default value
of an enum.

<t:radiogroup t:value="gender">
<input type="radio" t:type="radio"
t:value="literal:M" /> Male
<input type="radio" t:type="radio"
t:value="literal:F"/> Female
</t:radiogroup>

@Property
@Persist
private String gender = "F";

When the page is brought up, it throws the following exception:

http://localhost:8080/t5inaction/register

An unexpected application exception has occurred.

Exception assembling root component of page Register: Unable to instantiate
instance of transformed class tapestry5.inaction.pages.Register:
java.lang.reflect.InvocationTargetException

why is this happening and what's wrong in my implementation ?

Thanks,
Deepak
Reply | Threaded
Open this post in threaded view
|

Re: Page with @Persist and default value fails to instantiate

Chris Poulsen
I think that

private String gender = "F";

is suspect, you should probably not initialize it to "F", instead you can
use onActivate or setupRender to default it, if it is null.

--
Chris

On Thu, Oct 23, 2014 at 2:45 PM, Deepak <[hidden email]> wrote:

> I'm just beginning with Tapestry and referring to "Tapestry 5, Building Web
> Applications" by Alexander Kolesnikov. But I'm using version 5.3.7.
>
> I have a page with a property annotated with @Persist and a default value
> of an enum.
>
> <t:radiogroup t:value="gender">
> <input type="radio" t:type="radio"
> t:value="literal:M" /> Male
> <input type="radio" t:type="radio"
> t:value="literal:F"/> Female
> </t:radiogroup>
>
> @Property
> @Persist
> private String gender = "F";
>
> When the page is brought up, it throws the following exception:
>
> http://localhost:8080/t5inaction/register
>
> An unexpected application exception has occurred.
>
> Exception assembling root component of page Register: Unable to instantiate
> instance of transformed class tapestry5.inaction.pages.Register:
> java.lang.reflect.InvocationTargetException
>
> why is this happening and what's wrong in my implementation ?
>
> Thanks,
> Deepak
>
Reply | Threaded
Open this post in threaded view
|

Re: Page with @Persist and default value fails to instantiate

George Christman
<t:radiogroup t:value="gender">
<input type="radio" t:type="radio"
t:value="literal:M" /> Male
<input type="radio" t:type="radio"
t:value="literal:F"/> Female
</t:radiogroup>

@Property
@Persist
private String gender;

void onActivate()  {
    gender = "F";
}

or

void onSetupRender()  {
    gender = "F";
}

On Thu, Oct 23, 2014 at 9:24 AM, Chris Poulsen <[hidden email]>
wrote:

> I think that
>
> private String gender = "F";
>
> is suspect, you should probably not initialize it to "F", instead you can
> use onActivate or setupRender to default it, if it is null.
>
> --
> Chris
>
> On Thu, Oct 23, 2014 at 2:45 PM, Deepak <[hidden email]> wrote:
>
> > I'm just beginning with Tapestry and referring to "Tapestry 5, Building
> Web
> > Applications" by Alexander Kolesnikov. But I'm using version 5.3.7.
> >
> > I have a page with a property annotated with @Persist and a default value
> > of an enum.
> >
> > <t:radiogroup t:value="gender">
> > <input type="radio" t:type="radio"
> > t:value="literal:M" /> Male
> > <input type="radio" t:type="radio"
> > t:value="literal:F"/> Female
> > </t:radiogroup>
> >
> > @Property
> > @Persist
> > private String gender = "F";
> >
> > When the page is brought up, it throws the following exception:
> >
> > http://localhost:8080/t5inaction/register
> >
> > An unexpected application exception has occurred.
> >
> > Exception assembling root component of page Register: Unable to
> instantiate
> > instance of transformed class tapestry5.inaction.pages.Register:
> > java.lang.reflect.InvocationTargetException
> >
> > why is this happening and what's wrong in my implementation ?
> >
> > Thanks,
> > Deepak
> >
>



--
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York
Reply | Threaded
Open this post in threaded view
|

Re: Page with @Persist and default value fails to instantiate

Thiago H de Paula Figueiredo
In reply to this post by Deepak
On Thu, 23 Oct 2014 10:45:00 -0200, Deepak <[hidden email]> wrote:

> @Property
> @Persist
> private String gender = "F";

As Chris and George already said, never, never ever initialize a page,  
component or field in its initialization. Their suggestion of using  
setupRender() or onActivate() to initialize it is spot on.

> Exception assembling root component of page Register: Unable to  
> instantiate
> instance of transformed class tapestry5.inaction.pages.Register:
> java.lang.reflect.InvocationTargetException

Well, it shouldn't cause an exception, so I'm curious. It's probably  
something else. On the other hand, when posting an exception, post the  
full stack trace, as the information needed is there.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Page with @Persist and default value fails to instantiate

Deepak
In reply to this post by Chris Poulsen
Great, that worked !!! As a general rule of thumb, does this mean that i
should initialize variables in these methods rather than during declaration
?

On Thu, Oct 23, 2014 at 6:54 PM, Chris Poulsen <[hidden email]>
wrote:

> I think that
>
> private String gender = "F";
>
> is suspect, you should probably not initialize it to "F", instead you can
> use onActivate or setupRender to default it, if it is null.
>
> --
> Chris
>
> On Thu, Oct 23, 2014 at 2:45 PM, Deepak <[hidden email]> wrote:
>
> > I'm just beginning with Tapestry and referring to "Tapestry 5, Building
> Web
> > Applications" by Alexander Kolesnikov. But I'm using version 5.3.7.
> >
> > I have a page with a property annotated with @Persist and a default value
> > of an enum.
> >
> > <t:radiogroup t:value="gender">
> > <input type="radio" t:type="radio"
> > t:value="literal:M" /> Male
> > <input type="radio" t:type="radio"
> > t:value="literal:F"/> Female
> > </t:radiogroup>
> >
> > @Property
> > @Persist
> > private String gender = "F";
> >
> > When the page is brought up, it throws the following exception:
> >
> > http://localhost:8080/t5inaction/register
> >
> > An unexpected application exception has occurred.
> >
> > Exception assembling root component of page Register: Unable to
> instantiate
> > instance of transformed class tapestry5.inaction.pages.Register:
> > java.lang.reflect.InvocationTargetException
> >
> > why is this happening and what's wrong in my implementation ?
> >
> > Thanks,
> > Deepak
> >
>



--
Deepak
--------------------------------------------
Lend your voices only to sounds of freedom.
No longer lend your strength to that which you wish to be free from.
Fill your lives with love and bravery and you shall lead... a life
uncommon.
Reply | Threaded
Open this post in threaded view
|

Re: Page with @Persist and default value fails to instantiate

Deepak
Please ignore my 2nd question. I did not notice the rest of the
conversation in my inbox..sorry, my apologies.

On Thu, Oct 23, 2014 at 10:06 PM, Deepak <[hidden email]> wrote:

> Great, that worked !!! As a general rule of thumb, does this mean that i
> should initialize variables in these methods rather than during declaration
> ?
>
> On Thu, Oct 23, 2014 at 6:54 PM, Chris Poulsen <[hidden email]>
> wrote:
>
>> I think that
>>
>> private String gender = "F";
>>
>> is suspect, you should probably not initialize it to "F", instead you can
>> use onActivate or setupRender to default it, if it is null.
>>
>> --
>> Chris
>>
>> On Thu, Oct 23, 2014 at 2:45 PM, Deepak <[hidden email]> wrote:
>>
>> > I'm just beginning with Tapestry and referring to "Tapestry 5, Building
>> Web
>> > Applications" by Alexander Kolesnikov. But I'm using version 5.3.7.
>> >
>> > I have a page with a property annotated with @Persist and a default
>> value
>> > of an enum.
>> >
>> > <t:radiogroup t:value="gender">
>> > <input type="radio" t:type="radio"
>> > t:value="literal:M" /> Male
>> > <input type="radio" t:type="radio"
>> > t:value="literal:F"/> Female
>> > </t:radiogroup>
>> >
>> > @Property
>> > @Persist
>> > private String gender = "F";
>> >
>> > When the page is brought up, it throws the following exception:
>> >
>> > http://localhost:8080/t5inaction/register
>> >
>> > An unexpected application exception has occurred.
>> >
>> > Exception assembling root component of page Register: Unable to
>> instantiate
>> > instance of transformed class tapestry5.inaction.pages.Register:
>> > java.lang.reflect.InvocationTargetException
>> >
>> > why is this happening and what's wrong in my implementation ?
>> >
>> > Thanks,
>> > Deepak
>> >
>>
>
>
>
> --
> Deepak
> --------------------------------------------
> Lend your voices only to sounds of freedom.
> No longer lend your strength to that which you wish to be free from.
> Fill your lives with love and bravery and you shall lead... a life
> uncommon.
>



--
Deepak
--------------------------------------------
Lend your voices only to sounds of freedom.
No longer lend your strength to that which you wish to be free from.
Fill your lives with love and bravery and you shall lead... a life
uncommon.
Reply | Threaded
Open this post in threaded view
|

Re: Page with @Persist and default value fails to instantiate

Deepak
In reply to this post by Thiago H de Paula Figueiredo
I'm noticing that the exception raised by my tapestry application do not
appear as a stack track and not at all colored and highlighted as shown in
various posts and blogs. The exception is just displayed in a single
sentence paragraph. Am i missing any jar for the decoration ? The jars I've
used is listed below.

antlr-runtime-3.3.jar
commons-codec-1.5.jar
javassist.jar
javax.inject-1.jar
log4j-1.2.16.jar
plastic-5.3.7.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
tapestry-core-5.3.7.jar
tapestry-func-5.3.7.jar
tapestry-ioc-5.3.7.jar
tapestry-json-5.3.7.jar
tapestry5-annotations-5.3.7.jar

Thanks,
Deepak

On Thu, Oct 23, 2014 at 9:46 PM, Thiago H de Paula Figueiredo <
[hidden email]> wrote:

> On Thu, 23 Oct 2014 10:45:00 -0200, Deepak <[hidden email]> wrote:
>
>  @Property
>> @Persist
>> private String gender = "F";
>>
>
> As Chris and George already said, never, never ever initialize a page,
> component or field in its initialization. Their suggestion of using
> setupRender() or onActivate() to initialize it is spot on.
>
>  Exception assembling root component of page Register: Unable to
>> instantiate
>> instance of transformed class tapestry5.inaction.pages.Register:
>> java.lang.reflect.InvocationTargetException
>>
>
> Well, it shouldn't cause an exception, so I'm curious. It's probably
> something else. On the other hand, when posting an exception, post the full
> stack trace, as the information needed is there.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Deepak
--------------------------------------------
Lend your voices only to sounds of freedom.
No longer lend your strength to that which you wish to be free from.
Fill your lives with love and bravery and you shall lead... a life
uncommon.
Reply | Threaded
Open this post in threaded view
|

Re: Page with @Persist and default value fails to instantiate

Thiago H de Paula Figueiredo
On Thu, 23 Oct 2014 14:56:40 -0200, Deepak <[hidden email]> wrote:

> I'm noticing that the exception raised by my tapestry application do not
> appear as a stack track and not at all colored and highlighted as shown  
> in various posts and blogs. The exception is just displayed in a single
> sentence paragraph. Am i missing any jar for the decoration ?

No. Are you running with production mode on? Have you set up logging?

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Page with @Persist and default value fails to instantiate

Deepak
Hi, Thiago.

No, I've not created log4j.properties file but I've set the app to run in development mode under web.xml as

<context-param> 
   <param-name>tapestry.execution-mode</param-name> 
   <param-value>development</param-value> 
</context-param>

I've attached the screen shot of how exception is displayed in the app.

Thanks.

On Thu, Oct 23, 2014 at 10:50 PM, Thiago H de Paula Figueiredo <[hidden email]> wrote:
On Thu, 23 Oct 2014 14:56:40 -0200, Deepak <[hidden email]> wrote:

I'm noticing that the exception raised by my tapestry application do not
appear as a stack track and not at all colored and highlighted as shown in various posts and blogs. The exception is just displayed in a single
sentence paragraph. Am i missing any jar for the decoration ?

No. Are you running with production mode on? Have you set up logging?

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]





---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Page with @Persist and default value fails to instantiate

Thiago H de Paula Figueiredo
On Thu, 23 Oct 2014 17:01:42 -0200, Deepak <[hidden email]> wrote:

Hi, Thiago.

Hi!

No, I've not created log4j.properties file but I've set the app to run in development mode under web.xml as

<context-param> 
   <param-name>tapestry.execution-mode</param-name> 
   <param-value>development</param-value> 
</context-param>

This just tells DevelopmentModule to be loaded alongside AppModule, not setting the production mode. You need to set the tapestry.production-mode symbol to false.

I've attached the screen shot of how exception is displayed in the app.

I'm sorry, but the screenshot wasn't actually attached. In addition, please post the stack trace as text.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
Reply | Threaded
Open this post in threaded view
|

Re: Page with @Persist and default value fails to instantiate

Deepak
Thanks a lot for the pointer. With the setting of tapestry.production-mode
the stack trace is now displayed in its full glory :)

On Fri, Oct 24, 2014 at 1:02 AM, Thiago H de Paula Figueiredo <
[hidden email]> wrote:

>  On Thu, 23 Oct 2014 17:01:42 -0200, Deepak <[hidden email]> wrote:
>
> Hi, Thiago.
>
>
> Hi!
>
> No, I've not created log4j.properties file but I've set the app to run in
> development mode under web.xml as
>
> <context-param>
>     <param-name>tapestry.execution-mode</param-name>
>     <param-value>development</param-value>
> </context-param>
>
>
> This just tells DevelopmentModule to be loaded alongside AppModule, not
> setting the production mode. You need to set the tapestry.production-mode
> symbol to false.
>
> I've attached the screen shot of how exception is displayed in the app.
>
>
> I'm sorry, but the screenshot wasn't actually attached. In addition,
> please post the stack trace as text.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
Reply | Threaded
Open this post in threaded view
|

Re: Page with @Persist and default value fails to instantiate

JumpStart
This might help you further.

        http://jumpstart.doublenegative.com.au/jumpstart7/examples/infrastructure/exceptionreport

Cheers,

Geoff

On 24 Oct 2014, at 2:30 pm, Deepak <[hidden email]> wrote:

> Thanks a lot for the pointer. With the setting of tapestry.production-mode
> the stack trace is now displayed in its full glory :)
>
> On Fri, Oct 24, 2014 at 1:02 AM, Thiago H de Paula Figueiredo <
> [hidden email]> wrote:
>
>> On Thu, 23 Oct 2014 17:01:42 -0200, Deepak <[hidden email]> wrote:
>>
>> Hi, Thiago.
>>
>>
>> Hi!
>>
>> No, I've not created log4j.properties file but I've set the app to run in
>> development mode under web.xml as
>>
>> <context-param>
>>    <param-name>tapestry.execution-mode</param-name>
>>    <param-value>development</param-value>
>> </context-param>
>>
>>
>> This just tells DevelopmentModule to be loaded alongside AppModule, not
>> setting the production mode. You need to set the tapestry.production-mode
>> symbol to false.
>>
>> I've attached the screen shot of how exception is displayed in the app.
>>
>>
>> I'm sorry, but the screenshot wasn't actually attached. In addition,
>> please post the stack trace as text.
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]