解决Opentaps/OFBiz在Eclipse启动时"Could not load VFS configuration"的问题
在命令行使用./startofbiz.sh启动Opentaps正常, 而在Eclipse中启动时出现异常,异常信息如下:
org.ofbiz.base.start.StartupException: Cannot start()org.ofbiz.commons.vfs.CommonsVfsContainer (InitializingStandardFileSystemManager (Could not load VFS configuration from"file:/home/engineers/workspaces/ws-opentaps-tpg/opentaps/bin/META-INF/vfs-providers.xml ".))at org.ofbiz.base.container.ContainerLoader.start(ContainerLoader.java:104)at org.ofbiz.base.start.Start.startStartLoaders(Start.java:264)at org.ofbiz.base.start.Start.startServer(Start.java:313)at org.ofbiz.base.start.Start.start(Start.java:317)at org.ofbiz.base.start.Start.main(Start.java:400)org.ofbiz.base.container.ContainerException: InitializingStandardFileSystemManager (Could not load VFS configuration from"file:/home/engineers/workspaces/ws-opentaps-tpg/opentaps/bin/META-INF/vfs-providers.xml ".)atorg.ofbiz.commons.vfs.CommonsVfsContainer.start(CommonsVfsContainer.java:51)at org.ofbiz.base.container.ContainerLoader.start(ContainerLoader.java:102)at org.ofbiz.base.start.Start.startStartLoaders(Start.java:264)at org.ofbiz.base.start.Start.startServer(Start.java:313)at org.ofbiz.base.start.Start.start(Start.java:317)at org.ofbiz.base.start.Start.main(Start.java:400)Caused by: org.apache.commons.vfs.FileSystemException: Could not load VFSconfiguration from "file:/home/engineers/workspaces/ws-opentaps-tpg/opentaps/bin/META-INF/vfs-providers.xml ".atorg.apache.commons.vfs.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:199)atorg.apache.commons.vfs.impl.StandardFileSystemManager.configurePlugins(StandardFileSystemManager.java:156)atorg.apache.commons.vfs.impl.StandardFileSystemManager.init(StandardFileSystemManager.java:129)atorg.webslinger.commons.vfs.VFSUtil.createStandardFileSystemManager(VFSUtil.java:351)atorg.webslinger.commons.vfs.VFSUtil.createStandardFileSystemManager(VFSUtil.java:345)atorg.ofbiz.commons.vfs.CommonsVfsContainer.start(CommonsVfsContainer.java:45)... 5 moreCaused by: org.apache.commons.vfs.FileSystemException: Multiple providersregistered for URL scheme "ofbiz-home".atorg.apache.commons.vfs.impl.DefaultFileSystemManager.addProvider(DefaultFileSystemManager.java:174)atorg.apache.commons.vfs.impl.StandardFileSystemManager.addProvider(StandardFileSystemManager.java:362)atorg.apache.commons.vfs.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:262)atorg.apache.commons.vfs.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:195)... 10 more
<container name="commons-vfs-container" name="code">protected void configurePlugins() throws FileSystemException {ClassLoader cl = findClassLoader();Enumeration enumResources = null;try{enumResources = cl.getResources(PLUGIN_CONFIG_RESOURCE);}catch (IOException e){throw new FileSystemException(e);}while (enumResources.hasMoreElements()){URL url = (URL) enumResources.nextElement();configure(url);}}
protected void configurePlugins() throws FileSystemException{...enumResources = cl.getResources(PLUGIN_CONFIG_RESOURCE);...}
public Enumeration<URL> getResources(String name) throws IOException {Enumeration[] tmp = new Enumeration[2];if (parent != null) { tmp[0] = parent.getResources(name);} else { tmp[0] = getBootstrapResources(name);}tmp[1] = findResources(name);return new CompoundEnumeration(tmp); }
protected void configurePlugins() throws FileSystemException {ClassLoader cl = findClassLoader();Enumeration enumResources = null;try{enumResources = cl.getResources(PLUGIN_CONFIG_RESOURCE);}catch (IOException e){throw new FileSystemException(e);}Set set = new HashSet();while (enumResources.hasMoreElements()){URL url = (URL) enumResources.nextElement();if (!set.contains(url.toString())){set.add(url.toString());}}Iterator itr = set.iterator();while (itr.hasNext()){String url = (String)itr.next();try {configure(new URL(url));} catch (MalformedURLException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}