|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
|
|
|
Re: Fwd: XStream.fromXML in a JSP page throwing CannotResolveClassExceptionHi Mohamed,
Mohamed Mansour wrote: > Hello, > > Before I start, I know JSP gets compiled into a Servlet and I can use > normal POJO's but the requirements is only using JSP. Somehow, I cannot > use fromXML in a JSP file, any reasons why? Any assistance is helpful and > appreciated! Since the missing class is also generated by the jsp compiler, it might be very well, that it is not part of the default class loader. > The working code snippet is below, it can be saved as test.jsp and you can > see the exception live: > > <%@ page import="com.thoughtworks.xstream.XStream"%> > <%@ page import="com.thoughtworks.xstream.io.xml.DomDriver"%> > <%@ page import="com.thoughtworks.xstream.annotations.XStreamAlias"%> > <%@ page > import="com.thoughtworks.xstream.annotations.XStreamAsAttribute"%> > > <%! > @XStreamAlias("InstanceParameter") > public static class InstanceParameter { > @XStreamAlias("ID") @XStreamAsAttribute > public String id; > @XStreamAlias("Value") @XStreamAsAttribute > public String value; > } > %> > <% > InstanceParameter testA = new InstanceParameter(); > testA.id = "Hello"; > testA.value = "World"; > > // This works. Returns 'toXML: <InstanceParameter ID="Hello" > Value="World"/>' > XStream stream = new XStream(new DomDriver()); try here to insert: xstream.setClassloader(getClass().getClassloader()); > stream.processAnnotations(InstanceParameter.class); > String xml = stream.toXML(testA); > System.out.println("toXML: " + xml); > > // This does not work. > InstanceParameter param = (InstanceParameter)stream.fromXML(xml); > System.out.println("fromXML: " + param.id); > > out.close(); > %> > > > The exception I am getting is the following: > > com.thoughtworks.xstream.mapper.CannotResolveClassException: > org.apache.jsp.rulesTranslator_jsp$InstanceParameter : > org.apache.jsp.rulesTranslator_js > $InstanceParameter > at > > at [snip] > > Any help is appreciated. I am really puzzling, it works fine in plain pogo > Java, but within a JSP page the fromXML part doesn't work at all. - Jörg --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Re: Fwd: XStream.fromXML in a JSP page throwing CannotResolveClassExceptionThanks Jörg, works perfectly!
- Mohamed On Sun, Nov 8, 2009 at 7:32 AM, Jörg Schaible <joerg.schaible@...> wrote:
|
| Free embeddable forum powered by Nabble | Forum Help |