javaspringweb-servicesjakarta-eemalformedurlexception

Getting a org.springframework.remoting.RemoteAccessException: Could not access remote service when making a few calls one after the other?


I am using weblogic work managers to make a call from my webservice to an EJB (within the same ear) that calls an external websservice.

If I make 1 call it always work perfectly so I know that the setup is correct to call the service...

But as soon as I add another call(s) to it it sometimes fail (from the EJB to the web service) with this exception on the EJB to external web service call (the more calls I add to the work managers the more it fails)

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)
    ... 

My service is configured in Spring (2.5) in my application context as follows

<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>

I am using Java 5 and Weblogic 10. I added logging before and after the calls to the external webservice from the EJB: I can see that multiple calls via the workmanagers are made to the EJB. But inside the EJB it seems to throw the exception. Just to isolate if there was anything wrong with the workmanager setup but that seems to be fine.

The problem seems to be in the EJB making the call to the external web service.

Why would I get this error for concurrent calls but not 1 at a time?


Solution

  • The problem was with my bean definded in the spring config.

    Instead of defining it like that I saved the WSDL to my project and use WSDL2Code defined in my POM to generate a stub for me

    <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>
    

    Then in my code I create a new stub and invoke the methods that has been generated for me