Re: [Wicket-user] java.io.NotSerializableException on my session object
* Igor Vaynberg: this is not a requiremenet of wicket per se but that of the servlet containers. anything you keep in http session must be serializable. since wicket keeps most of its entities in session they must be serializable. I understand this for a session because it can be made persistent across restarts, but what about Application's metadata: Application.setMetaData(MetaDataKey key, java.io.Serializable object) Why do we need Serializable here? BTW I use Application.setMetaData() to pass Spring beans to the Page. Are MetaData suitable for that kind of purpose? And about the Wicket-Spring extension, is there a documentation available? -- Jean-Baptiste Quenot aka John Banana Qwerty http://caraldi.com/jbq/ - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] java.io.NotSerializableException on my session object
On 7/19/06, Jean-Baptiste Quenot [EMAIL PROTECTED] wrote: * Igor Vaynberg: this is not a requiremenet of wicket per se but that of the servlet containers. anything you keep in http session must be serializable. since wicket keeps most of its entities in session they must be serializable. I understand this for a session because it can be made persistent across restarts, but what about Application's metadata: Application.setMetaData(MetaDataKey key, java.io.Serializable object) Why do we need Serializable here? I agree you don't need it for application. However, Application's meta data reuses the metadata classes that are used for pages and session, where meta data typically should be serializable. BTW I use Application.setMetaData() to pass Spring beans to the Page. Are MetaData suitable for that kind of purpose? Theoretically, you can use the meta data for any thing your want. *However*, you typically would not need to use this facility for concrete applications. If you know what application you're in, you can directly use the concrete application class for instance. That would be less work, more strongly typed, and easier to find out what the application class supports. The meta data facility is specifically meant for reusable components/ constructs, that need to utilize some page/session/application scoped message bus, without knowing anything about any concrete application they function in. We use the application scope once in Wicket (in class WebPage), where we log a warning when the page has no body element. We set a meta data bit to ensure we only issue that warning once a page. And about the Wicket-Spring extension, is there a documentation available? It has JavaDocs and an example project, and there is a WIKI page: http://www.wicket-wiki.org.uk/wiki/index.php/Spring. Eelco - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] java.io.NotSerializableException on my session object
* Eelco Hillenius: On 7/19/06, Jean-Baptiste Quenot [EMAIL PROTECTED] wrote: Why do we need Serializable here? I agree you don't need it for application. However, Application's meta data reuses the metadata classes that are used for pages and session, where meta data typically should be serializable. OK I understand the concern. BTW I use Application.setMetaData() to pass Spring beans to the Page. Are MetaData suitable for that kind of purpose? Theoretically, you can use the meta data for any thing your want. *However*, you typically would not need to use this facility for concrete applications. If you know what application you're in, you can directly use the concrete application class for instance. That would be less work, more strongly typed, and easier to find out what the application class supports. You're perfectly right, but the Application can be either MyWebApplication or WicketTester, so the Page doesn't know the exact type of the Application. And about the Wicket-Spring extension, is there a documentation available? It has JavaDocs and an example project, and there is a WIKI page: http://www.wicket-wiki.org.uk/wiki/index.php/Spring. Thanks, that was exactly what I was looking for. And you see in the examples that the following construct is used: ((MyApplication)getApplication()).getContactDao() However there is also a discussion about Injector, maybe it's a better approach than MetaData, and no cast is necessary in this case apparently. Thanks for your answers. -- Jean-Baptiste Quenot aka John Banana Qwerty http://caraldi.com/jbq/ - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] java.io.NotSerializableException on my session object
this is not a requiremenet of wicket per se but that of the servlet containers. anything you keep in http session must be serializable. since wicket keeps most of its entities in session they must be serializable.when you set level to debug you tripped this: HttpSessionStore:47public void setAttribute(Request request, String name, Object value){// Do some extra profiling/ debugging. This can be a great help// just for testing whether your webbapp will behave when using // session replicationif (log.isDebugEnabled())the code inside the if block will try to serialize whatever you are trying to put into session immediately so there are no surprises during replication. there is no alternative as far as i know, simply a requirement that must be followed when dealing with java webapps and storing things in session.-IgorOn 7/18/06, Steve Moitozo [EMAIL PROTECTED] wrote: I just changed the log4j log level for wicket to DEBUG and now myapplication craps out with the following error:Internal error cloning object. Make sure all dependent objects implementSerializable. Class: mystuff.wicketapp.MyWebSessionAm I to assume that the entire hierarchy of class properties containedwithin MyWebSession must implement Serializable? If so can you offer anyalternatives?Why does my app still work when the log level is set higher? I guess the real question is does it really work? I haven't tested clustering andstate replication. I would assume that the above error would cause statereplication to fail. True?-S2--Steve Moitozo II -Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share youropinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Wicket-user mailing listWicket-user@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] java.io.NotSerializableException on my session object
Thanks for the quick response. Do you know if there's a way to tell Java which parts of an object are vital during serialization and which can be ignored. I'm thinking about how Detachable Models work. Am I correct in assuming that if I do not correct this my app will continue to work in a single JVM environment but it will probably not work in a clustered environment? -S2 -- Steve Moitozo II Manager of Web Technology Bates College 207-786-6266 Get the Bates College CA Certificate at: http://www.bates.edu/ils/offices/web/crypto/ Igor Vaynberg wrote: this is not a requiremenet of wicket per se but that of the servlet containers. anything you keep in http session must be serializable. since wicket keeps most of its entities in session they must be serializable. when you set level to debug you tripped this: HttpSessionStore:47 public void setAttribute(Request request, String name, Object value) { // Do some extra profiling/ debugging. This can be a great help // just for testing whether your webbapp will behave when using // session replication if (log.isDebugEnabled()) the code inside the if block will try to serialize whatever you are trying to put into session immediately so there are no surprises during replication. there is no alternative as far as i know, simply a requirement that must be followed when dealing with java webapps and storing things in session. -Igor On 7/18/06, Steve Moitozo [EMAIL PROTECTED] wrote: I just changed the log4j log level for wicket to DEBUG and now my application craps out with the following error: Internal error cloning object. Make sure all dependent objects implement Serializable. Class: mystuff.wicketapp.MyWebSession Am I to assume that the entire hierarchy of class properties contained within MyWebSession must implement Serializable? If so can you offer any alternatives? Why does my app still work when the log level is set higher? I guess the real question is does it really work? I haven't tested clustering and state replication. I would assume that the above error would cause state replication to fail. True? -S2 -- Steve Moitozo II - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user smime.p7s Description: S/MIME Cryptographic Signature - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] java.io.NotSerializableException on my session object
There is a DEBUG level logger in wicket.protocol.http.HttpSessionStore that tries to serialize any attribute that is set. The development version - soon 1.2.1 - has a fix so that it doesn't depend on the log level, but instead on an application setting: if (Application.get().getDebugSettings().getSerializeSessionAttributes()) { String valueTypeName = (value != null ? value.getClass().getName() : null); try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); new ObjectOutputStream(out).writeObject(value); log.debug(Stored attribute + name + { + valueTypeName + } with size: + Bytes.bytes(out.size())); } catch (Exception e) { throw new WicketRuntimeException( Internal error cloning object. Make sure all dependent objects implement Serializable. Class: + valueTypeName, e); } } The reason we deliver that functionality is to help you ensure you application can function properly in a cluster, using session replication. There are many strategies however, including a different approach than normal serializing, but serializing is the default, and is something you should use when you use a backing httpsession (Wicket's default) anyway. Anything that may end up in the session store, components (and their state), models, etc, should be serializable. If you want to pursue a different strategy, implement an ISessionStore that does this. Hope this helps, Eelco On 7/18/06, Steve Moitozo [EMAIL PROTECTED] wrote: I just changed the log4j log level for wicket to DEBUG and now my application craps out with the following error: Internal error cloning object. Make sure all dependent objects implement Serializable. Class: mystuff.wicketapp.MyWebSession Am I to assume that the entire hierarchy of class properties contained within MyWebSession must implement Serializable? If so can you offer any alternatives? Why does my app still work when the log level is set higher? I guess the real question is does it really work? I haven't tested clustering and state replication. I would assume that the above error would cause state replication to fail. True? -S2 -- Steve Moitozo II - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] java.io.NotSerializableException on my session object
On 7/18/06, Steve Moitozo [EMAIL PROTECTED] wrote: Thanks for the quick response. Do you know if there's a way to tell Java which parts of an object are vital during serialization and which can be ignored. yep, the transient keyword. Transient fields will not be serialized (and thus null after serialization). Useful for lazy init fields. Am I correct in assuming that if I do not correct this my app will continue to work in a single JVM environment but it will probably not work in a clustered environment? Correct, if you use the default serialization mechanism. Fix is easy usually. Just let those classes implement Serializable. Eelco - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] java.io.NotSerializableException on my session object
Thanks for the quick response. Do you know if there's a way to tell Java which parts of an object are vital during serialization and which can be ignored. I'm thinking about how Detachable Models work.not really sure what you mean or why you would have to do that. what is the usecase for having something that is not serializable in session? Am I correct in assuming that if I do not correct this my app willcontinue to work in a single JVM environment but it will probably not work in a clustered environment?yep. the debug feature serializes immediately so you get the error now instead of whenever the servlet container tries to replicate your session for you - at which point you will get a very similar error. -Igor-S2--Steve Moitozo IIManager of Web Technology Bates College207-786-6266Get the Bates College CA Certificate at:http://www.bates.edu/ils/offices/web/crypto/Igor Vaynberg wrote: this is not a requiremenet of wicket per se but that of the servlet containers. anything you keep in http session must be serializable. since wicket keeps most of its entities in session they must be serializable. when you set level to debug you tripped this: HttpSessionStore:47 public void setAttribute(Request request, String name, Object value) { // Do some extra profiling/ debugging. This can be a great help // just for testing whether your webbapp will behave when using // session replication if (log.isDebugEnabled()) the code inside the if block will try to serialize whatever you are trying to put into session immediately so there are no surprises during replication. there is no alternative as far as i know, simply a requirement that must be followed when dealing with java webapps and storing things in session. -Igor On 7/18/06, Steve Moitozo [EMAIL PROTECTED] wrote: I just changed the log4j log level for wicket to DEBUG and now my application craps out with the following error: Internal error cloning object. Make sure all dependent objects implement Serializable. Class: mystuff.wicketapp.MyWebSession Am I to assume that the entire hierarchy of class properties contained within MyWebSession must implement Serializable? If so can you offer any alternatives? Why does my app still work when the log level is set higher? I guess the real question is does it really work? I haven't tested clustering and state replication. I would assume that the above error would cause state replication to fail. True? -S2 -- Steve Moitozo II - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user-Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net 's Techsay panel and you'll get the chance to share youropinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___Wicket-user mailing list Wicket-user@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] java.io.NotSerializableException on my session object
i would be careful about using transient since you will have to implement null checks anytime you access that field.-IgorOn 7/18/06, Eelco Hillenius [EMAIL PROTECTED] wrote: On 7/18/06, Steve Moitozo [EMAIL PROTECTED] wrote: Thanks for the quick response. Do you know if there's a way to tell Javawhich parts of an object are vital during serialization and which can be ignored.yep, the transient keyword. Transient fields will not be serialized(and thus null after serialization). Useful for lazy init fields. Am I correct in assuming that if I do not correct this my app will continue to work in a single JVM environment but it will probably not work in a clustered environment?Correct, if you use the default serialization mechanism. Fix is easyusually. Just let those classes implement Serializable. Eelco-Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cashhttp://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___Wicket-user mailing listWicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] java.io.NotSerializableException on my session object
not really sure what you mean or why you would have to do that. what is the usecase for having something that is not serializable in session? As I trace this issue through my code it's becoming apparent that since pages are added to the session any properties that is in a page that isn't serializable causes the error. So it's not that I want to store non-serializable things in the session necessarily. Many of my pages use third-party libraries that are not serializable and these seem to cause the issue. I'll admit I'm a new comer so I may be missing something or violating a Wicket principle as I build out my app. the debug feature serializes immediately so you get the error now instead of whenever the servlet container tries to replicate your session for you - at which point you will get a very similar error. Thank you for this! -S2 -- Steve Moitozo II - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] java.io.NotSerializableException on my session object
well, now that you are aware of this going should get better.in case you are storing beans from other framework that are not serializable i really dont see an easy way. the creators of those projects should make sure their objects are serializable. the only thing i see that you can do is to create a serializable bean yourself that has the necessary logic to translate to and from the other bean. or subclass it, override writeReplace/readReplace and do the same thing. in case you are talking about stateless objects from other frameworks you have a lot more options:use a pure getteruse a null-check-getter in conjunection with a transient field if lookups are expensive and you want to cache them for a while use a wicket-spring type of proxy that is serializable and knows how to look up the dependency - kinda like a middleman between your dependency and serialization-Igor On 7/18/06, Steve Moitozo [EMAIL PROTECTED] wrote: not really sure what you mean or why you would have to do that. what is the usecase for having something that is not serializable in session?As I trace this issue through my code it's becoming apparent that since pages are added to the session any properties that is in a page thatisn't serializable causes the error. So it's not that I want to storenon-serializable things in the session necessarily. Many of my pages use third-party libraries that are not serializable and these seem to causethe issue.I'll admit I'm a new comer so I may be missing something or violating aWicket principle as I build out my app. the debug feature serializes immediately so you get the error now instead of whenever the servlet container tries to replicate your session for you - at which point you will get a very similar error.Thank you for this!-S2--Steve Moitozo II -Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share youropinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Wicket-user mailing listWicket-user@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user