Results 1 to 7 of 7
  1. #1
    harry1985 is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default 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.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,789
    Rep Power
    7

    Default

    arrrrgggh!

    My eyes. Why do people insist on using colours to highlight text?

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    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.

  4. #4
    harry1985 is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default

    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.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    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.

  6. #6
    harry1985 is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default

    the xml returned in the first bit of code is same as the one posted above.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    And you confirmed this by printing it out?
    Because if so then they should both work.
    Java is not going to automagically work differently between the two Strings if xmlFromFile.equals(xmlFromString).

    If you haven't printed it out then you are making an assumption.

Similar Threads

  1. Replies: 0
    Last Post: 12-22-2008, 06:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •