org.springframework.core.NestedIOException Java Examples

The following examples show how to use org.springframework.core.NestedIOException. 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: ConfigurationClassParser.java    From spring-analysis-note with 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 #2
Source File: ConfigurationClassParser.java    From spring-analysis-note with 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 #3
Source File: ConfigurationClassParser.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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 #4
Source File: SqlSessionFactoryBean.java    From Shop-for-JavaWeb with 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 #5
Source File: ConfigurationClassParser.java    From java-technology-stack with 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 #6
Source File: ConfigurationClassParser.java    From java-technology-stack with 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 #7
Source File: ConfigurationClassParser.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
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 #8
Source File: VfsResource.java    From lams with 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 #9
Source File: NodeletParser.java    From mongodb-orm with Apache License 2.0 5 votes vote down vote up
public void parse(InputStream inputStream) throws NestedIOException {
  try {
    Document doc = createDocument(inputStream);
    parse(doc.getLastChild());
  } catch (Exception e) {
    throw new NestedIOException("Error parsing XML.  Cause: " + e, e);
  }
}
 
Example #10
Source File: VfsResource.java    From lams with 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 #11
Source File: ConfigurationClassParser.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #12
Source File: DefaultDeserializer.java    From spring4-understanding with 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 #13
Source File: AbstractResource.java    From spring4-understanding with 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 #14
Source File: VfsResource.java    From spring4-understanding with 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 #15
Source File: VfsResource.java    From spring4-understanding with 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 #16
Source File: MapperLoader.java    From Shop-for-JavaWeb with 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 #17
Source File: MongoFactoryBean.java    From mongodb-orm with 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 #18
Source File: NodeletParser.java    From mongodb-orm with 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);
  }
}
 
Example #19
Source File: AbstractResource.java    From lams with 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 #20
Source File: DefaultDeserializer.java    From lams with 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 #21
Source File: ConfigurationClassParser.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #22
Source File: BeanUtils.java    From radar with 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 #23
Source File: VfsResource.java    From java-technology-stack with 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 #24
Source File: VfsResource.java    From java-technology-stack with 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 #25
Source File: AbstractResource.java    From java-technology-stack with 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 #26
Source File: DefaultDeserializer.java    From java-technology-stack with 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 #27
Source File: VfsResource.java    From spring-analysis-note with 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 #28
Source File: VfsResource.java    From spring-analysis-note with 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 #29
Source File: AbstractResource.java    From spring-analysis-note with 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 #30
Source File: SimpleMetadataReader.java    From spring-analysis-note with 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);
		}
	}
}