Java Code Examples for org.springframework.core.NestedIOException

The following examples show how to use org.springframework.core.NestedIOException. These examples are extracted from open source projects. 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 Project: spring-analysis-note   Source File: ConfigurationClassParser.java    License: MIT License 6 votes vote down vote up
/**
 * Factory method to obtain a {@link SourceClass} from a class name.
 */
SourceClass asSourceClass(@Nullable String className) throws IOException {
	if (className == null || className.startsWith("java.lang.annotation.")) {
		return this.objectSourceClass;
	}
	if (className.startsWith("java")) {
		// Never use ASM for core java types
		try {
			return new SourceClass(ClassUtils.forName(className,
					this.resourceLoader.getClassLoader()));
		}
		catch (ClassNotFoundException ex) {
			throw new NestedIOException(
					"Failed to load class [" + className + "]", ex);
		}
	}
	return new SourceClass(
			this.metadataReaderFactory.getMetadataReader(className));
}
 
Example 2
Source Project: spring-analysis-note   Source File: ConfigurationClassParser.java    License: MIT License 6 votes vote down vote up
private SourceClass getRelated(String className) throws IOException {
	if (this.source instanceof Class) {
		try {
			Class<?> clazz = ClassUtils.forName(className, ((Class<?>) this.source).getClassLoader());
			return asSourceClass(clazz);
		}
		catch (ClassNotFoundException ex) {
			// Ignore -> fall back to ASM next, except for core java types.
			if (className.startsWith("java")) {
				throw new NestedIOException("Failed to load class [" + className + "]", ex);
			}
			return new SourceClass(metadataReaderFactory.getMetadataReader(className));
		}
	}
	return asSourceClass(className);
}
 
Example 3
Source Project: java-technology-stack   Source File: ConfigurationClassParser.java    License: MIT License 6 votes vote down vote up
/**
 * Factory method to obtain a {@link SourceClass} from a class name.
 */
SourceClass asSourceClass(@Nullable String className) throws IOException {
	if (className == null) {
		return new SourceClass(Object.class);
	}
	if (className.startsWith("java")) {
		// Never use ASM for core java types
		try {
			return new SourceClass(ClassUtils.forName(className, this.resourceLoader.getClassLoader()));
		}
		catch (ClassNotFoundException ex) {
			throw new NestedIOException("Failed to load class [" + className + "]", ex);
		}
	}
	return new SourceClass(this.metadataReaderFactory.getMetadataReader(className));
}
 
Example 4
Source Project: java-technology-stack   Source File: ConfigurationClassParser.java    License: MIT License 6 votes vote down vote up
private SourceClass getRelated(String className) throws IOException {
	if (this.source instanceof Class) {
		try {
			Class<?> clazz = ClassUtils.forName(className, ((Class<?>) this.source).getClassLoader());
			return asSourceClass(clazz);
		}
		catch (ClassNotFoundException ex) {
			// Ignore -> fall back to ASM next, except for core java types.
			if (className.startsWith("java")) {
				throw new NestedIOException("Failed to load class [" + className + "]", ex);
			}
			return new SourceClass(metadataReaderFactory.getMetadataReader(className));
		}
	}
	return asSourceClass(className);
}
 
Example 5
private SourceClass getRelated(String className) throws IOException {
	if (this.source instanceof Class) {
		try {
			Class<?> clazz = ((Class<?>) this.source).getClassLoader().loadClass(className);
			return asSourceClass(clazz);
		}
		catch (ClassNotFoundException ex) {
			// Ignore -> fall back to ASM next, except for core java types.
			if (className.startsWith("java")) {
				throw new NestedIOException("Failed to load class [" + className + "]", ex);
			}
			return new SourceClass(metadataReaderFactory.getMetadataReader(className));
		}
	}
	return asSourceClass(className);
}
 
Example 6
private SourceClass getRelated(String className) throws IOException {
	if (this.source instanceof Class<?>) {
		try {
			Class<?> clazz = resourceLoader.getClassLoader().loadClass(className);
			return asSourceClass(clazz);
		}
		catch (ClassNotFoundException ex) {
			// Ignore -> fall back to ASM next, except for core java types.
			if (className.startsWith("java")) {
				throw new NestedIOException("Failed to load class [" + className + "]", ex);
			}
			return new SourceClass(metadataReaderFactory.getMetadataReader(className));
		}
	}
	return asSourceClass(className);
}
 
Example 7
Source Project: Shop-for-JavaWeb   Source File: SqlSessionFactoryBean.java    License: MIT License 6 votes vote down vote up
/**
 * TODO 刷新
 * 
 * @param inputStream
 * @param resource
 * @param configuration
 * @throws NestedIOException
 */
public static void refresh(java.io.InputStream inputStream,
		String resource, Configuration configuration)
		throws NestedIOException {

	try {
		XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(
				inputStream, configuration, resource,
				configuration.getSqlFragments());
		xmlMapperBuilder.parse1();
	} catch (Exception e) {
		throw new NestedIOException("Failed to parse mapping resource: '"
				+ resource + "'", e);
	} finally {
		ErrorContext.instance().reset();
	}

}
 
Example 8
Source Project: spring-analysis-note   Source File: DefaultDeserializer.java    License: MIT License 5 votes vote down vote up
/**
 * Read from the supplied {@code InputStream} and deserialize the contents
 * into an object.
 * @see ObjectInputStream#readObject()
 */
@Override
@SuppressWarnings("resource")
public Object deserialize(InputStream inputStream) throws IOException {
	ObjectInputStream objectInputStream = new ConfigurableObjectInputStream(inputStream, this.classLoader);
	try {
		return objectInputStream.readObject();
	}
	catch (ClassNotFoundException ex) {
		throw new NestedIOException("Failed to deserialize object type", ex);
	}
}
 
Example 9
Source Project: spring-analysis-note   Source File: SimpleMetadataReader.java    License: MIT License 5 votes vote down vote up
private static ClassReader getClassReader(Resource resource) throws IOException {
	try (InputStream is = new BufferedInputStream(resource.getInputStream())) {
		try {
			return new ClassReader(is);
		}
		catch (IllegalArgumentException ex) {
			throw new NestedIOException("ASM ClassReader failed to parse class file - " +
					"probably due to a new Java class file version that isn't supported yet: " + resource, ex);
		}
	}
}
 
Example 10
Source Project: spring-analysis-note   Source File: AbstractResource.java    License: MIT License 5 votes vote down vote up
/**
 * This implementation builds a URI based on the URL returned
 * by {@link #getURL()}.
 */
@Override
public URI getURI() throws IOException {
	URL url = getURL();
	try {
		return ResourceUtils.toURI(url);
	}
	catch (URISyntaxException ex) {
		throw new NestedIOException("Invalid URI [" + url + "]", ex);
	}
}
 
Example 11
Source Project: spring-analysis-note   Source File: VfsResource.java    License: MIT License 5 votes vote down vote up
@Override
public URL getURL() throws IOException {
	try {
		return VfsUtils.getURL(this.resource);
	}
	catch (Exception ex) {
		throw new NestedIOException("Failed to obtain URL for file " + this.resource, ex);
	}
}
 
Example 12
Source Project: spring-analysis-note   Source File: VfsResource.java    License: MIT License 5 votes vote down vote up
@Override
public URI getURI() throws IOException {
	try {
		return VfsUtils.getURI(this.resource);
	}
	catch (Exception ex) {
		throw new NestedIOException("Failed to obtain URI for " + this.resource, ex);
	}
}
 
Example 13
Source Project: java-technology-stack   Source File: DefaultDeserializer.java    License: MIT License 5 votes vote down vote up
/**
 * Read from the supplied {@code InputStream} and deserialize the contents
 * into an object.
 * @see ObjectInputStream#readObject()
 */
@Override
@SuppressWarnings("resource")
public Object deserialize(InputStream inputStream) throws IOException {
	ObjectInputStream objectInputStream = new ConfigurableObjectInputStream(inputStream, this.classLoader);
	try {
		return objectInputStream.readObject();
	}
	catch (ClassNotFoundException ex) {
		throw new NestedIOException("Failed to deserialize object type", ex);
	}
}
 
Example 14
Source Project: java-technology-stack   Source File: AbstractResource.java    License: MIT License 5 votes vote down vote up
/**
 * This implementation builds a URI based on the URL returned
 * by {@link #getURL()}.
 */
@Override
public URI getURI() throws IOException {
	URL url = getURL();
	try {
		return ResourceUtils.toURI(url);
	}
	catch (URISyntaxException ex) {
		throw new NestedIOException("Invalid URI [" + url + "]", ex);
	}
}
 
Example 15
Source Project: java-technology-stack   Source File: VfsResource.java    License: MIT License 5 votes vote down vote up
@Override
public URL getURL() throws IOException {
	try {
		return VfsUtils.getURL(this.resource);
	}
	catch (Exception ex) {
		throw new NestedIOException("Failed to obtain URL for file " + this.resource, ex);
	}
}
 
Example 16
Source Project: java-technology-stack   Source File: VfsResource.java    License: MIT License 5 votes vote down vote up
@Override
public URI getURI() throws IOException {
	try {
		return VfsUtils.getURI(this.resource);
	}
	catch (Exception ex) {
		throw new NestedIOException("Failed to obtain URI for " + this.resource, ex);
	}
}
 
Example 17
Source Project: radar   Source File: BeanUtils.java    License: Apache License 2.0 5 votes vote down vote up
private static Object deserialize(InputStream inputStream) throws IOException {
	ObjectInputStream objectInputStream = new ConfigurableObjectInputStream(inputStream, BeanUtils.class.getClassLoader());
	try {
		return objectInputStream.readObject();
	}
	catch (ClassNotFoundException ex) {
		logger.error("Failed to deserialize object type", ex);
		throw new NestedIOException("Failed to deserialize object type", ex);
	}
}
 
Example 18
/**
 * Factory method to obtain a {@link SourceClass} from a class name.
 */
SourceClass asSourceClass(String className) throws IOException {
	if (className.startsWith("java")) {
		// Never use ASM for core java types
		try {
			return new SourceClass(this.resourceLoader.getClassLoader().loadClass(className));
		}
		catch (ClassNotFoundException ex) {
			throw new NestedIOException("Failed to load class [" + className + "]", ex);
		}
	}
	return new SourceClass(this.metadataReaderFactory.getMetadataReader(className));
}
 
Example 19
Source Project: lams   Source File: DefaultDeserializer.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read from the supplied {@code InputStream} and deserialize the contents
 * into an object.
 * @see ObjectInputStream#readObject()
 */
@Override
@SuppressWarnings("resource")
public Object deserialize(InputStream inputStream) throws IOException {
	ObjectInputStream objectInputStream = new ConfigurableObjectInputStream(inputStream, this.classLoader);
	try {
		return objectInputStream.readObject();
	}
	catch (ClassNotFoundException ex) {
		throw new NestedIOException("Failed to deserialize object type", ex);
	}
}
 
Example 20
Source Project: lams   Source File: AbstractResource.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * This implementation builds a URI based on the URL returned
 * by {@link #getURL()}.
 */
@Override
public URI getURI() throws IOException {
	URL url = getURL();
	try {
		return ResourceUtils.toURI(url);
	}
	catch (URISyntaxException ex) {
		throw new NestedIOException("Invalid URI [" + url + "]", ex);
	}
}
 
Example 21
Source Project: lams   Source File: VfsResource.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public URL getURL() throws IOException {
	try {
		return VfsUtils.getURL(this.resource);
	}
	catch (Exception ex) {
		throw new NestedIOException("Failed to obtain URL for file " + this.resource, ex);
	}
}
 
Example 22
Source Project: lams   Source File: VfsResource.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public URI getURI() throws IOException {
	try {
		return VfsUtils.getURI(this.resource);
	}
	catch (Exception ex) {
		throw new NestedIOException("Failed to obtain URI for " + this.resource, ex);
	}
}
 
Example 23
/**
 * Factory method to obtain a {@link SourceClass} from a class name.
 */
public SourceClass asSourceClass(String className) throws IOException {
	if (className.startsWith("java")) {
		// Never use ASM for core java types
		try {
			return new SourceClass(this.resourceLoader.getClassLoader().loadClass(className));
		}
		catch (ClassNotFoundException ex) {
			throw new NestedIOException("Failed to load class [" + className + "]", ex);
		}
	}
	return new SourceClass(this.metadataReaderFactory.getMetadataReader(className));
}
 
Example 24
Source Project: spring4-understanding   Source File: DefaultDeserializer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Read from the supplied {@code InputStream} and deserialize the contents
 * into an object.
 * @see ObjectInputStream#readObject()
 */
@Override
@SuppressWarnings("resource")
public Object deserialize(InputStream inputStream) throws IOException {
	ObjectInputStream objectInputStream = new ConfigurableObjectInputStream(inputStream, this.classLoader);
	try {
		return objectInputStream.readObject();
	}
	catch (ClassNotFoundException ex) {
		throw new NestedIOException("Failed to deserialize object type", ex);
	}
}
 
Example 25
Source Project: spring4-understanding   Source File: AbstractResource.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This implementation builds a URI based on the URL returned
 * by {@link #getURL()}.
 */
@Override
public URI getURI() throws IOException {
	URL url = getURL();
	try {
		return ResourceUtils.toURI(url);
	}
	catch (URISyntaxException ex) {
		throw new NestedIOException("Invalid URI [" + url + "]", ex);
	}
}
 
Example 26
Source Project: spring4-understanding   Source File: VfsResource.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public URL getURL() throws IOException {
	try {
		return VfsUtils.getURL(this.resource);
	}
	catch (Exception ex) {
		throw new NestedIOException("Failed to obtain URL for file " + this.resource, ex);
	}
}
 
Example 27
Source Project: spring4-understanding   Source File: VfsResource.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public URI getURI() throws IOException {
	try {
		return VfsUtils.getURI(this.resource);
	}
	catch (Exception ex) {
		throw new NestedIOException("Failed to obtain URI for " + this.resource, ex);
	}
}
 
Example 28
Source Project: Shop-for-JavaWeb   Source File: MapperLoader.java    License: MIT License 5 votes vote down vote up
public void reloadXML() throws Exception {
	SqlSessionFactory factory = context.getBean(SqlSessionFactory.class);
	Configuration configuration = factory.getConfiguration();
	// 移除加载项
	removeConfig(configuration);
	// 重新扫描加载
	for (String basePackage : basePackages) {
		Resource[] resources = getResource(basePackage, XML_RESOURCE_PATTERN);
		if (resources != null) {
			for (int i = 0; i < resources.length; i++) {
				if (resources[i] == null) {
					continue;
				}
				try {
					XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(resources[i].getInputStream(),
							configuration, resources[i].toString(), configuration.getSqlFragments());
					xmlMapperBuilder.parse();
				} catch (Exception e) {
					throw new NestedIOException("Failed to parse mapping resource: '" + resources[i] + "'", e);
				} finally {
					ErrorContext.instance().reset();
				}
			}
		}
	}

}
 
Example 29
Source Project: mongodb-orm   Source File: MongoFactoryBean.java    License: Apache License 2.0 5 votes vote down vote up
public void init() throws Exception {
  MqlMapConfigParser configParser = new MqlMapConfigParser();
  for (Resource configLocation : configLocations) {
    InputStream is = configLocation.getInputStream();
    try {
      configParser.parse(is);
      logger.info("Mql configuration parse resource file. File name is " + configLocation.getFilename());
    } catch (RuntimeException ex) {
      throw new NestedIOException("Failed to parse config configuration. File name is " + configLocation.getFilename(), ex.getCause());
    }
  }
  configParser.validateMapping();
  this.configParser = configParser;
  logger.info("Mongodb orm framework has ready.");
}
 
Example 30
Source Project: mongodb-orm   Source File: NodeletParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Begins parsing from the provided Reader.
 */
public void parse(Reader reader) throws NestedIOException {
  try {
    Document doc = createDocument(reader);
    parse(doc.getLastChild());
  } catch (Exception e) {
    throw new NestedIOException("Error parsing XML.  Cause: " + e, e);
  }
}