com.thoughtworks.xstream.mapper.CannotResolveClassException Java Examples

The following examples show how to use com.thoughtworks.xstream.mapper.CannotResolveClassException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XStreamMarshaller.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Convert the given XStream exception to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since XStream itself does not make this distinction in its exception hierarchy.
 * @param ex the XStream exception that occurred
 * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
 * or unmarshalling ({@code false})
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertXStreamException(Exception ex, boolean marshalling) {
	if (ex instanceof StreamException || ex instanceof CannotResolveClassException ||
			ex instanceof ConversionException) {
		if (marshalling) {
			return new MarshallingFailureException("XStream marshalling exception",  ex);
		}
		else {
			return new UnmarshallingFailureException("XStream unmarshalling exception", ex);
		}
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown XStream exception", ex);
	}
}
 
Example #2
Source File: XStreamMarshaller.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Convert the given XStream exception to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since XStream itself does not make this distinction in its exception hierarchy.
 * @param ex the XStream exception that occurred
 * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
 * or unmarshalling ({@code false})
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertXStreamException(Exception ex, boolean marshalling) {
	if (ex instanceof StreamException || ex instanceof CannotResolveClassException ||
			ex instanceof ConversionException) {
		if (marshalling) {
			return new MarshallingFailureException("XStream marshalling exception",  ex);
		}
		else {
			return new UnmarshallingFailureException("XStream unmarshalling exception", ex);
		}
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown XStream exception", ex);
	}
}
 
Example #3
Source File: XStreamMarshaller.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
    * Convert the given XStream exception to an appropriate exception from the
    * {@code org.springframework.oxm} hierarchy.
    * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
    * unmarshalling, since XStream itself does not make this distinction in its exception hierarchy.
    * @param ex XStream exception that occurred
    * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
    * or unmarshalling ({@code false})
    * @return the corresponding {@code XmlMappingException}
    */
protected XmlMappingException convertXStreamException(Exception ex, boolean marshalling) {
	if (ex instanceof StreamException || ex instanceof CannotResolveClassException ||
			ex instanceof ConversionException) {
		if (marshalling) {
			return new MarshallingFailureException("XStream marshalling exception",  ex);
		}
		else {
			return new UnmarshallingFailureException("XStream unmarshalling exception", ex);
		}
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown XStream exception", ex);
	}
}
 
Example #4
Source File: JavaClassConverter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public Object fromString(String str) {
    try {
        return mapper.realClass(str);
    } catch (CannotResolveClassException e) {
        throw new ConversionException("Cannot load java class " + str, e.getCause());
    }
}