File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Set attribute value not serializable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Set attribute value not serializable" Watch "Set attribute value not serializable" New topic
Author

Set attribute value not serializable

Allan Rosa
Greenhorn

Joined: May 02, 2011
Posts: 6
Hello, java study on their own and came across an error that can not make out where it comes from
I am developing an application but it gave the following stack trace:


and the eclipse appears the following info:



is that there's something wrong with my Bean?



In this application I'm using primefaces. The referenced error may occur due to primefaces?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Welcome to the JavaRanch, Allan!

You would have done better to phrase your question in English for those of us who don't speak Portuguese. We're international, but we had to settle on a common language just to make things work.

You have a NullPointerException in line 87 of "getListaAteHoje". Unfortunately, I don't know which line of your sample code that is, since our code display editor's line numbers don't relate to stack traces.


Customer surveys are for companies who didn't pay proper attention to begin with.
Allan Rosa
Greenhorn

Joined: May 02, 2011
Posts: 6
Tim Holloway wrote:Welcome to the JavaRanch, Allan!

You would have done better to phrase your question in English for those of us who don't speak Portuguese. We're international, but we had to settle on a common language just to make things work.

You have a NullPointerException in line 87 of "getListaAteHoje". Unfortunately, I don't know which line of your sample code that is, since our code display editor's line numbers don't relate to stack traces.


Sorry I am not aware of this problem ... as we have developed codes of the entire application in Portuguese I think it will be difficult through the conversion now.
Thanks for your help!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

We can (usually) make our way through code in foreign languages, at least when it's using the Latin alphabet. I Just meant to say that it's better to ask the questions themselves in English.

I can definitely offer suggestions on your problem. I just need to know which line of your sample was "line 87".
Allan Rosa
Greenhorn

Joined: May 02, 2011
Posts: 6
Tim Holloway wrote:We can (usually) make our way through code in foreign languages, at least when it's using the Latin alphabet. I Just meant to say that it's better to ask the questions themselves in English.

I can definitely offer suggestions on your problem. I just need to know which line of your sample was "line 87".


Thank you for your commitment in helping me ... Line 87 corresponds to line 60 which is where the error occurs to me
see below the corresponding class:


and




Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Sorry, that didn't work either. There's no line 60 there.

You don't need to repeat the entire example. In fact, if you just give the line of code text that's line #87 in your source file, that's all I really need.
Allan Rosa
Greenhorn

Joined: May 02, 2011
Posts: 6
Tim Holloway wrote:Sorry, that didn't work either. There's no line 60 there.

You don't need to repeat the entire example. In fact, if you just give the line of code text that's line #87 in your source file, that's all I really need.


line #87 =
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

OK. contextoBean is not defined in the session at that point and is therefore null.

Question: Why are you using a service class to get contextoBean instead of simply injecting it as a managed property into lancamentoBean?
Allan Rosa
Greenhorn

Joined: May 02, 2011
Posts: 6
Tim Holloway wrote:OK. contextoBean is not defined in the session at that point and is therefore null.

Question: Why are you using a service class to get contextoBean instead of simply injecting it as a managed property into lancamentoBean?


I'm a beginner, I am following a book and the author makes it that way.
Can I send you the source of the program to look at the possible causes of this error?
Thanks again for your help and timely response.
The forums here in Brazil take too long to answer some questions
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Unfortunately, I don't have a lot of spare time right now, so I really can't look at your project. However, if you're going to access contextoBean, you have to first create it.

JSF will construct and initialize contextoBean automatically, but only when a View requires it. Session-scope beans are not constructed in advance. If non-JSF code (such as a servlet) requires contextoBean, that code will have to manually ensure that contextoBean is constructed and initialized properly. That is also true for things like your service class, since the bean is referenced in code before it has been referenced in a JSF View.

Where possible, injection of a managed property is preferable to using a service locator. The code required is simpler, the actual setting of the values is automatically done for you, and the lack of explicit binding means that you can test things in isolation more easily. Sometimes you can't use injection, such as cases where the injected object is in too narrow a scope or the object has been constructed by a foreign framework. In cases like that, a service location is useful. But if you just want to link 2 JSF beans, injection is usually the way to go.
Allan Rosa
Greenhorn

Joined: May 02, 2011
Posts: 6
Tim Holloway wrote:Unfortunately, I don't have a lot of spare time right now, so I really can't look at your project. However, if you're going to access contextoBean, you have to first create it.

JSF will construct and initialize contextoBean automatically, but only when a View requires it. Session-scope beans are not constructed in advance. If non-JSF code (such as a servlet) requires contextoBean, that code will have to manually ensure that contextoBean is constructed and initialized properly. That is also true for things like your service class, since the bean is referenced in code before it has been referenced in a JSF View.

Where possible, injection of a managed property is preferable to using a service locator. The code required is simpler, the actual setting of the values is automatically done for you, and the lack of explicit binding means that you can test things in isolation more easily. Sometimes you can't use injection, such as cases where the injected object is in too narrow a scope or the object has been constructed by a foreign framework. In cases like that, a service location is useful. But if you just want to link 2 JSF beans, injection is usually the way to go.


Thank you, I'll check the items mentioned
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Set attribute value not serializable