MalformedURL在读取文件时获取异常

时间:2011-06-09 14:47:45

标签: java xml jdom

我从我的weblogic 8.1环境中复制了一个代码,并在我的新环境weblogic 10.3.4中复制。以下代码安静在我的8.1环境中工作。当我使用相同的代码时,它给了我以下的例外。

  String xmlPath="e:\\domains\\devdamsdomain\\j2ee\\configurations\\dcd\\dams\\common\\interfaceconfig.xml";
  log.info("xmlpath" + xmlPath);
  SAXBuilder saxBuilder = new SAXBuilder();
  log.info("creating SAXBuilder");
  Document document = saxBuilder.build(xmlPath);

例外情况如下:

INFO [orabpel.invoke.pool-4.thread-12] (SubRegistration_ptClient.java:76) - exception occured: unknown protocol: e
java.net.MalformedURLException: unknown protocol: e
        at java.net.URL.<init>(URL.java:574)
        at java.net.URL.<init>(URL.java:464)
        at java.net.URL.<init>(URL.java:413)
        at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:250)
        at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:222)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:891)
        at com.ura.proxy.subregistration.proxy.SubRegistration_ptClient.callSubRegistration_process(SubRegistration_ptClient.java:68)
        at com.ura.dams.registration.businesscontrol.SubRegControlImpl.clientRequestwithReturn(SubRegControlImpl.java:19)
        at com.ura.dams.registration.process.RegistrationUpload.objSubRegClientRequestwithReturn(RegistrationUpload.java:137)
        at orabpel.registrationupload.ExecLetBxExe7.execute(ExecLetBxExe7.java:208)
        at com.collaxa.cube.engine.ext.bpel.common.wmp.BPELxExecWMP.__executeStatements(BPELxExecWMP.java:42)
        at com.collaxa.cube.engine.ext.bpel.common.wmp.BaseBPELActivityWMP.perform(BaseBPELActivityWMP.java:162)
        at com.collaxa.cube.engine.CubeEngine.performActivity(CubeEngine.java:2465)
        at com.collaxa.cube.engine.CubeEngine.handleWorkItem(CubeEngine.java:1132)
        at com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal(PerformMessageHandler.java:73)
        at com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage(DispatchHelper.java:219)
        at com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory(DispatchHelper.java:327)
        at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:4350)
        at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:4281)
        at com.collaxa.cube.engine.CubeEngine._createAndInvoke(CubeEngine.java:713)
        at com.collaxa.cube.engine.CubeEngine.createAndInvoke(CubeEngine.java:545)
        at com.collaxa.cube.engine.delivery.DeliveryService.handleInvoke(DeliveryService.java:654)
        at com.collaxa.cube.engine.ejb.impl.CubeDeliveryBean.handleInvoke(CubeDeliveryBean.java:355)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at com.bea.core.repackaged.springframework.jee.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:104)

        at oracle.security.jps.ee.ejb.JpsAbsInterceptor$1.run(JpsAbsInterceptor.java:88)
        at java.security.AccessController.doPrivileged(Native Method)
        at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
        at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:414)
        at oracle.security.jps.wls.JpsWeblogicEjbInterceptor.runJaasMode(JpsWeblogicEjbInterceptor.java:61)
        at oracle.security.jps.ee.ejb.JpsAbsInterceptor.intercept(JpsAbsInterceptor.java:106)
        at oracle.security.jps.ee.ejb.JpsInterceptor.intercept(JpsInterceptor.java:106)
        at sun.reflect.GeneratedMethodAccessor1264.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
        at com.bea.core.repackaged.springframework.jee.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:69)
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)

        at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
        at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
        at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)

        at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy250.handleInvoke(Unknown Source)
        at com.collaxa.cube.engine.ejb.impl.bpel.BPELDeliveryBean_5k948i_ICubeDeliveryLocalBeanImpl.handleInvoke(BPELDeliveryBean_5k948i_ICubeDelivery
LocalBeanImpl.java:462)
        at com.collaxa.cube.engine.dispatch.message.invoke.InvokeInstanceMessageHandler.handle(InvokeInstanceMessageHandler.java:35)
        at com.collaxa.cube.engine.dispatch.DispatchHelper.handleMessage(DispatchHelper.java:141)
        at com.collaxa.cube.engine.dispatch.BaseDispatchTask.run(BaseDispatchTask.java:82)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)

请建议我......

3 个答案:

答案 0 :(得分:8)

您使用的方法接受URL的字符串表示,并且e:根据url格式不是有效的协议(因为它在第一个冒号之前被视为原样)

您有多种方法可以解决此问题:

  • 使用.build(new File(path))(最好)
  • 添加文件协议file://e/etc..(解决当前问题)

答案 1 :(得分:1)

您可以尝试file:///e:/domains/...

答案 2 :(得分:1)

如前所述,这是因为文件路径格式错误。解决方案是使用类似的路径。

document = builder.parse(new File(<pathtoberead>).toURI().toString());