Results 1 to 7 of 7
- 07-27-2011, 08:07 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
CannotResolveClassException while deserializing
In the below function, the line marked bold is giving com.thoughtworks.xstream.alias.CannotResolveClassE xception. the variable xml contains the correct bean in string format but conversion fails here.
public List<DocumentPermissionBean> getDocumentPermissionsFromCache(Document document) {
String docPermissionBeantring = (String) DocBuilderCacheFactory.getCache(
DocBuilderCacheType.PERMISSION_ID).get(document.ge tId());
if (docPermissionBeantring == null) {
return null;
}
List<Long> docPermissionBeanList = (List<Long>) xstream.fromXML(docPermissionBeantring);
for (Long docPermissionBean : docPermissionBeanList) {
String xml = (String) DocBuilderCacheFactory.getCache(
DocBuilderCacheType.PERMISSION_BEANS).get(docPermi ssionBean);
if (xml == null) {
return null;
}
cachedDocPermissionBean = (DocumentPermissionBean) xstream.fromXML(xml);
cachedDocPermissionBeans.add(cachedDocPermissionBe an);
}
return cachedDocPermissionBeans;
}
The value of variable "xml" when I debug the code and the error stack (not complete) is documented below. The conversion is failing at the line marked bold.
Variable xml Value:
<com.abc.xyz.docbuilder.database.beans.DocumentPer missionBean>
<permissionId>3</permissionId>
<documentBean>
<documentId>1</documentId>
<documentName>ewr</documentName>
<documentAuthor>admin</documentAuthor>
<documentDescription>wer</documentDescription>
<lastModifier>admin</lastModifier>
<creationDate class="sql-timestamp">2011-07-20 11:57:29.056</creationDate>
<currentVersion>1</currentVersion>
<currentVersionDate class="sql-timestamp">2011-07-20 11:57:29.056</currentVersionDate>
<contentBeans class="net.sf.hibernate.collection.Set">
<set>
<com.abc.xyz.docbuilder.database.beans.DocumentCon tentBean>
<id>2</id>
<documentBean reference="../../../.."/>
<pageId>32785</pageId>
<pageOrder>1</pageOrder>
</com.abc.xyz.docbuilder.database.beans.DocumentCont entBean>
<com.abc.xyz.docbuilder.database.beans.DocumentCon tentBean>
<id>1</id>
<documentBean reference="../../../.."/>
<pageId>32780</pageId>
<pageOrder>2</pageOrder>
</com.abc.xyz.docbuilder.database.beans.DocumentCont entBean>
</set>
<initialized>true</initialized>
<collectionSnapshot class="net.sf.hibernate.impl.SessionImpl-CollectionEntry">
<dirty>false</dirty>
<initialized>true</initialized>
<loadedKey class="long">1</loadedKey>
<snapshot class="map">
<entry>
<com.abc.xyz.docbuilder.database.beans.DocumentCon tentBean reference="../../../../set/com.abc.xyz.docbuilder.database.beans.DocumentCont entBean"/>
<com.abc.xyz.docbuilder.database.beans.DocumentCon tentBean reference="../../../../set/com.abc.xyz.docbuilder.database.beans.DocumentCont entBean"/>
</entry>
<entry>
<com.abc.xyz.docbuilder.database.beans.DocumentCon tentBean reference="../../../../set/com.abc.xyz.docbuilder.database.beans.DocumentCont entBean[2]"/>
<com.abc.xyz.docbuilder.database.beans.DocumentCon tentBean reference="../../../../set/com.abc.xyz.docbuilder.database.beans.DocumentCont entBean[2]"/>
</entry>
</snapshot>
<role>com.abc.xyz.docbuilder.database.beans.Docume ntBean.contentBeans</role>
</collectionSnapshot>
</contentBeans>
</documentBean>
<entityName>admin</entityName>
<entityType>USER</entityType>
<permissionName>UPDATE</permissionName>
<permissionValue>true</permissionValue>
</com.abc.xyz.docbuilder.database.beans.DocumentPerm issionBean>
Error Stack:
[INFO] [talledLocalContainer] ---- Debugging information ----
[INFO] [talledLocalContainer] message : net.sf.hibernate.impl.SessionImpl$CollectionEntry : net.sf.hibernate.impl.SessionImpl$CollectionEn
try
[INFO] [talledLocalContainer] line number : 28
[INFO] [talledLocalContainer] path : /com.abc.xyz.docbuilder.database.beans.DocumentPerm issionBean/documentBean/contentBeans/colle
ctionSnapshot
[INFO] [talledLocalContainer] cause-message : net.sf.hibernate.impl.SessionImpl$CollectionEntry : net.sf.hibernate.impl.SessionImpl$CollectionEn
try
[INFO] [talledLocalContainer] class : com.abc.xyz.docbuilder.database.beans.DocumentPerm issionBean
[INFO] [talledLocalContainer] cause-exception : com.thoughtworks.xstream.alias.CannotResolveClassE xception
[INFO] [talledLocalContainer] required-type : net.sf.hibernate.collection.Set
[INFO] [talledLocalContainer] -------------------------------
[INFO] [talledLocalContainer] atlassian.core.seraph.original.url: /plugins/docbuilder/permissioninfo.action
[INFO] [talledLocalContainer] javax.servlet.error.status_code: 500
[INFO] [talledLocalContainer] javax.servlet.error.servlet_name: action
[INFO] [talledLocalContainer] __sitemesh__using_stream: false
[INFO] [talledLocalContainer] com.atlassian.gzipfilter.GzipFilter_already_filter ed: true
[INFO] [talledLocalContainer] loginfilter.already.filtered: true
[INFO] [talledLocalContainer] com.atlassian.confluence.web.ConfluenceJohnsonFilt er_already_filtered: true
[INFO] [talledLocalContainer] Confluence-Request-Time: 1311260585587
[INFO] [talledLocalContainer] javax.servlet.error.message:
[INFO] [talledLocalContainer] com.atlassian.core.filters.HeaderSanitisingFilter_ already_filtered: true
[INFO] [talledLocalContainer] webwork.valueStack: com.opensymphony.xwork.util.OgnlValueStack@1365dd2
[INFO] [talledLocalContainer] sessioninview.FILTERED: true
[INFO] [talledLocalContainer] __sitemesh__filterapplied: true
[INFO] [talledLocalContainer] javax.servlet.error.exception: com.thoughtworks.xstream.converters.ConversionExce ption: net.sf.hibernate.impl.SessionImp
l$CollectionEntry : net.sf.hibernate.impl.SessionImpl$CollectionEntry
[INFO] [talledLocalContainer] ---- Debugging information ----
[INFO] [talledLocalContainer] message : net.sf.hibernate.impl.SessionImpl$CollectionEntry : net.sf.hibernate.impl.SessionImpl$CollectionEn
try
[INFO] [talledLocalContainer] line number : 28
[INFO] [talledLocalContainer] path : /com.abc.xyz.docbuilder.database.beans.DocumentPerm issionBean/documentBean/contentBeans/colle
ctionSnapshot
[INFO] [talledLocalContainer] cause-message : net.sf.hibernate.impl.SessionImpl$CollectionEntry : net.sf.hibernate.impl.SessionImpl$CollectionEn
try
[INFO] [talledLocalContainer] class : com.abc.xyz.docbuilder.database.beans.DocumentPerm issionBean
[INFO] [talledLocalContainer] cause-exception : com.thoughtworks.xstream.alias.CannotResolveClassE xception
[INFO] [talledLocalContainer] required-type : net.sf.hibernate.collection.Set
[INFO] [talledLocalContainer] -------------------------------
[INFO] [talledLocalContainer] javax.servlet.error.request_uri: /confluence/plugins/docbuilder/permissioninfo.action
[INFO] [talledLocalContainer] --------------------------
[INFO] [talledLocalContainer] Parameters
[INFO] [talledLocalContainer] --------------------------
[INFO] [talledLocalContainer] documentId : 1
[INFO] [talledLocalContainer] caused by: com.thoughtworks.xstream.converters.ConversionExce ption: net.sf.hibernate.impl.SessionImpl$CollectionEntry :
net.sf.hibernate.impl.SessionImpl$CollectionEntry
[INFO] [talledLocalContainer] ---- Debugging information ----
[INFO] [talledLocalContainer] message : net.sf.hibernate.impl.SessionImpl$CollectionEntry : net.sf.hibernate.impl.SessionImpl$CollectionEntry
[INFO] [talledLocalContainer] line number : 28
[INFO] [talledLocalContainer] path : /com.abc.xyz.docbuilder.database.beans.DocumentPerm issionBean/documentBean/contentBeans/colle
ctionSnapshot
[INFO] [talledLocalContainer] cause-message : net.sf.hibernate.impl.SessionImpl$CollectionEntry : net.sf.hibernate.impl.SessionImpl$CollectionEn
try
[INFO] [talledLocalContainer] class : com.abc.xyz.docbuilder.database.beans.DocumentPerm issionBean
[INFO] [talledLocalContainer] cause-exception : com.thoughtworks.xstream.alias.CannotResolveClassE xception
[INFO] [talledLocalContainer] required-type : net.sf.hibernate.collection.Set
[INFO] [talledLocalContainer] -------------------------------
[INFO] [talledLocalContainer] at com.thoughtworks.xstream.core.TreeUnmarshaller.con vertAnother(TreeUnmarshaller.java:45)
[INFO] [talledLocalContainer] caused by: com.thoughtworks.xstream.alias.CannotResolveClassE xception: net.sf.hibernate.impl.SessionImpl$CollectionEntry
: net.sf.hibernate.impl.SessionImpl$CollectionEntry
[INFO] [talledLocalContainer] at com.thoughtworks.xstream.mapper.DefaultMapper.real Class(DefaultMapper.java:35)
[INFO] [talledLocalContainer]
Can anyone suggest what might be the reason for the error here?
Thanks!Last edited by harry1985; 07-27-2011 at 10:29 AM.
- 07-27-2011, 08:15 AM #2
arrrrgggh!
My eyes. Why do people insist on using colours to highlight text?
- 07-27-2011, 09:55 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Yes, yellow is particularly bad as well...
Anyway:
cause-message : net.sf.hibernate.impl.SessionImpl$CollectionEntry : net.sf.hibernate.impl.SessionImpl$CollectionEntry
...
required-type : net.sf.hibernate.collection.Set
There seems to be a mismatch between your classes.
- 07-27-2011, 10:40 AM #4
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
thanks for the reply! But, if i pass the same string to a simple class given below and try to convert it to bean it works fine.
Java Code:package com.abc.xyz.docbuilder.actions; import com.abc.xyz.docbuilder.database.beans.DocumentPermissionBean; import com.thoughtworks.xstream.XStream; public class example{ public static void main(String[] args){ XStream xstream = new XStream(); String xml = "<com.abc.xyz.docbuilder.database.beans.DocumentPermissionBean> <permissionId>16</permissionId><documentBean><documentId>1</documentId> <documentName>ewr</documentName><documentAuthor>admin</documentAuthor> <documentDescription>wer</documentDescription><lastModifier>admin</lastModifier><creationDate class='sql-timestamp'>2011-07-20 11:57:29.056</creationDate> <currentVersion>1</currentVersion><currentVersionDate class='sql-timestamp'>2011-07-20 11:57:29.056</currentVersionDate> <contentBeans class='net.sf.hibernate.collection.Set'><set> <com.abc.xyz.docbuilder.database.beans.DocumentContentBean><id>1</id> <documentBean reference='../../../..'/><pageId>32780</pageId><pageOrder>2</pageOrder> </com.abc.xyz.docbuilder.database.beans.DocumentContentBean> <com.abc.xyz.docbuilder.database.beans.DocumentContentBean><id>2</id> <documentBean reference='../../../..'/><pageId>32785</pageId><pageOrder>1</pageOrder> </com.abc.xyz.docbuilder.database.beans.DocumentContentBean></set><initialized>true</initialized> <collectionSnapshot class='net.sf.hibernate.impl.SessionImpl-CollectionEntry'><dirty>false</dirty> <initialized>true</initialized><loadedKey class='long'>1</loadedKey><snapshot class='map'> <entry><com.abc.xyz.docbuilder.database.beans.DocumentContentBean reference='../../../../set/com.abc.xyz.docbuilder.database.beans.DocumentContentBean'/><com.abc.xyz.docbuilder.database.beans.DocumentContentBean reference='../../../../set/com.abc.xyz.docbuilder.database.beans.DocumentContentBean'/></entry><entry><com.abc.xyz.docbuilder.database.beans.DocumentContentBean reference='../../../../set/com.abc.xyz.docbuilder.database.beans.DocumentContentBean[2]'/><com.abc.xyz.docbuilder.database.beans.DocumentContentBean reference='../../../../set/com.abc.xyz.docbuilder.database.beans.DocumentContentBean[2]'/></entry></snapshot> <role>com.abc.xyz.docbuilder.database.beans.DocumentBean.contentBeans</role></collectionSnapshot> </contentBeans></documentBean><entityName>admin</entityName><entityType>USER</entityType> <permissionName>UPDATE</permissionName><permissionValue>true</permissionValue> </com.abc.xyz.docbuilder.database.beans.DocumentPermissionBean>"; DocumentPermissionBean cachedDocPermissionBean = (DocumentPermissionBean) xstream.fromXML(xml); System.out.println(cachedDocPermissionBean); } }Last edited by harry1985; 07-27-2011 at 12:04 PM.
- 07-27-2011, 10:59 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
You'll have to use code tags, because I can't see anything in that lot.
Also the forum mucks up long strings without them.
Print out the xml returned in the first bit of code to ensure it is the same.
- 07-27-2011, 12:42 PM #6
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
the xml returned in the first bit of code is same as the one posted above.
- 07-27-2011, 12:45 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Similar Threads
-
InputStream, Iterator, readObject issues while deserializing multiple objects
By xcallmejudasx in forum New To JavaReplies: 0Last Post: 12-22-2008, 06:16 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks