others - 获取 org.springframework.remoting.RemoteAccessException: 在进行调用时无法访问远程服务?

当我向它添加另一个调用时,它有时会失败(从EJB到web服务),在EJB到外部web服务调用中出现此异常。


org.springframework.remoting.RemoteAccessException: Could not access remote service [SomeServicePort]; nested exception is java.net.MalformedURLException
 at org.springframework.remoting.rmi.RmiClientInterceptorUtils.convertRmiAccessException(RmiClientInterceptorUtils.java:190)
 at org.springframework.remoting.jaxrpc.JaxRpcPortClientInterceptor.handleRemoteException(JaxRpcPortClientInterceptor.java:737)
 at org.springframework.remoting.jaxrpc.JaxRpcPortClientInterceptor.doInvoke(JaxRpcPortClientInterceptor.java:595)
 at org.springframework.remoting.jaxrpc.JaxRpcPortClientInterceptor.invoke(JaxRpcPortClientInterceptor.java:562)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at $Proxy112.obtainClinicalCode(Unknown Source)
 ...
Caused by: java.net.MalformedURLException
 at java.net.URL.<init>(URL.java:601)
 at java.net.URL.<init>(URL.java:464)
 at java.net.URL.<init>(URL.java:413)
 at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:133)
 ... 

在我的应用程序上下文中,在Spring(2.5)中配置了服务,如下所示


<bean id="MyService"
 class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean"
 lazy-init="true" scope="prototype">
 <property name="serviceFactoryClass">
 <value>org.apache.axis.client.ServiceFactory</value>
 </property>
 <property name="wsdlDocumentUrl">
 <value>myWSDLPath...</value>
 </property>
 <property name="namespaceUri">
 <value>com.controller</value>
 </property>
 <property name="serviceName">
 <value>Mine</value>
 </property>
 <property name="portName">
 <value>MinePort</value>
 </property>
 <property name="portInterface">
 <value>com.MineServiceRemote</value>
 </property>
 <property name="serviceInterface">
 <value>com.MineService</value>
 </property>
 <property name="lookupServiceOnStartup" value="false" />
 </bean>

我使用的是Java 5和web logic 10,我从EJB调用外部web service之前和之后添加了日志记录:可以看到通过workmanagers对EJB进行了多个调用,但在EJB内部,它引发了异常。

问题出在EJB调用外部Web服务。

时间:

问题出在spring配置中定义的bean。

不能像这样定义它,将WSDL保存到项目中,并使用在POM中定义的WSDL2Code生成一个stub


<plugin>
 <groupId>org.apache.axis2</groupId>
 <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
 <version>1.5.4</version>
 <executions>
 <execution>
 <id>myWebService</id>
 <goals>
 <goal>wsdl2code</goal>
 </goals>
 <configuration>
 <packageName>PackageWhereIWantTheCodeToBeGeneratedTo</packageName>
 <wsdlFile>${project.basedir}/src/main/resources/pathToWhereMyWsdlIsSavedInMyProject</wsdlFile>
 <databindingName>jaxbri</databindingName>
 <syncMode>sync</syncMode>
 <generateTestcase>false</generateTestcase>
 </configuration>
 </execution>

 </executions>
 <dependencies>
 <dependency>
 <groupId>org.apache.axis2</groupId>
 <artifactId>axis2-jaxbri</artifactId>
 <version>1.5.4</version>
 </dependency>
 </dependencies>
</plugin>

然后在代码中,我创建了一个新的stub,并调用为我生成的方法

...