Using interface.wsdl in .componentType side file fails as it can't find the WSDL.
It looks like the import.wsdl doesn't get processed until after the side file is processed. The JavaScript sample 7 can be used to recreate the problem, look in HelloWorldImpl.componentType and there's a commented out interface.wsdl, change to use that gives this exception:
java.lang.IllegalArgumentException: Cannot find WSDL definition for
http://helloworld.samples.tuscany.apache.org
at org.apache.tuscany.model.types.wsdl.impl.WSDLServiceContractImpl.getPortType(WSDLServiceContractImpl.java:158)
at org.apache.tuscany.model.types.wsdl.impl.WSDLServiceContractImpl.initialize(WSDLServiceContractImpl.java:103)
at org.apache.tuscany.model.assembly.impl.PortImpl.initialize(PortImpl.java:77)
at org.apache.tuscany.model.assembly.impl.ComponentTypeImpl.initialize(ComponentTypeImpl.java:117)
at org.apache.tuscany.model.assembly.impl.ComponentImplementationImpl.initialize(ComponentImplementationImpl.java:62)
at org.apache.tuscany.container.js.assembly.impl.JavaScriptImplementationImpl.initialize(JavaScriptImplementationImpl.java:73)
at org.apache.tuscany.model.assembly.impl.ComponentImpl.initialize(ComponentImpl.java:115)
at org.apache.tuscany.model.scdl.loader.impl.SCDLModelContentHandlerImpl$9.run(SCDLModelContentHandlerImpl.java:409)
at org.apache.tuscany.model.util.ModelTransformerImpl.transformPass2(ModelTransformerImpl.java:122)
at org.apache.tuscany.model.util.ModelTransformerImpl.transform(ModelTransformerImpl.java:42)
at org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl.transform(SCDLAssemblyModelLoaderImpl.java:198)
at org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl.loadModule(SCDLAssemblyModelLoaderImpl.java:107)
at org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl.loadModule(ModuleComponentConfigurationLoaderImpl.java:48)
at org.apache.tuscany.core.config.impl.AbstractModuleComponentConfigurationLoader.loadModuleComponent(AbstractModuleComponentConfigurationLoader.java:98)
at org.apache.tuscany.core.config.impl.AbstractModuleComponentConfigurationLoader.loadModuleComponent(AbstractModuleComponentConfigurationLoader.java:88)
at org.apache.tuscany.core.config.impl.AbstractModuleComponentConfigurationLoader.loadModuleComponent(AbstractModuleComponentConfigurationLoader.java:61)
at org.apache.tuscany.core.client.TuscanyRuntime.<init>(TuscanyRuntime.java:100)
at org.apache.tuscany.core.client.TuscanyRuntime.<init>(TuscanyRuntime.java:64)
at sample.Sample7Client.invoke(Sample7Client.java:38)
at sample.Sample7TestCase.testGeetings(Sample7TestCase.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Usage of WSDL interfaces on components doesn't work at all so I am also raising the priority of this JIRA issue to critical.
I am getting a new exception now. See the exception I pasted at the bottom.
My analysis after stepping through the code is the following:
- o.a.t.core.loader.assembly.ComponentLoader is invoking ComponentInfoImpl.initialize() too early, I think it's actually the only case where initialize is called explicitly and so early in the loading cycle. I don't think that this right. We should wait for all the fragments of a module and all the <import.wsdl> they contain to be loaded before trying to initialize model objects.
- o.a.t.core.loader.assembly.ImportWSDLLoader is now using a new WSDLDefinitionRegistry to load WSDL files, and the WSDLDefinitionRegistry is not used by WSDLServiceContract to lookup the portType specified on <interface.wsdl>. Actually WSDLDefinitionRegistry is not even passed to WSDLServiceContract so I don't understand how this can work at all. I looked for references to WSDLDefinitionRegistry and could only find references to it in the loader and WSDLDefinitionRegistryImpl.
Jeremy, you added the new loader code and this new WSDLDefinitionRegistry recently and you understand how they are supposed to be used. It looks to me like a piece is missing in the integration of the WSDLDefinitionRegistry. So I'm going to assign the JIRA to you, more work is necessary to integrate the WSDLDefinitionRegistry and get support for WSDL working. Can you please help? Thanks.
Here's the new exception:
Exception in thread "main" java.lang.IllegalArgumentException: Cannot find WSDL definition for http://helloworld.samples.tuscany.apache.org
at org.apache.tuscany.model.types.wsdl.impl.WSDLServiceContractImpl.getPortType(WSDLServiceContractImpl.java:158)
at org.apache.tuscany.model.types.wsdl.impl.WSDLServiceContractImpl.initialize(WSDLServiceContractImpl.java:103)
at org.apache.tuscany.model.assembly.impl.PortImpl.initialize(PortImpl.java:59)
at org.apache.tuscany.model.assembly.impl.ComponentInfoImpl.initialize(ComponentInfoImpl.java:118)
at org.apache.tuscany.model.assembly.impl.ImplementationImpl.initialize(ImplementationImpl.java:47)
at org.apache.tuscany.core.loader.assembly.ComponentLoader.load(ComponentLoader.java:83)
at org.apache.tuscany.core.loader.assembly.ComponentLoader.load(ComponentLoader.java:1)
at org.apache.tuscany.core.loader.impl.StAXLoaderRegistryImpl.load(StAXLoaderRegistryImpl.java:62)
at org.apache.tuscany.core.loader.assembly.AggregateLoader.loadAggregate(AggregateLoader.java:43)
at org.apache.tuscany.core.loader.assembly.ModuleLoader.load(ModuleLoader.java:39)
at org.apache.tuscany.core.loader.assembly.ModuleLoader.load(ModuleLoader.java:1)
at org.apache.tuscany.core.loader.impl.StAXLoaderRegistryImpl.load(StAXLoaderRegistryImpl.java:62)
at org.apache.tuscany.core.config.impl.StAXModuleComponentConfigurationLoaderImpl.loadModule(StAXModuleComponentConfigurationLoaderImpl.java:50)
at org.apache.tuscany.core.config.impl.AbstractModuleComponentConfigurationLoader.loadModuleComponent(AbstractModuleComponentConfigurationLoader.java:98)
at org.apache.tuscany.core.config.impl.AbstractModuleComponentConfigurationLoader.loadModuleComponent(AbstractModuleComponentConfigurationLoader.java:88)
at org.apache.tuscany.core.config.impl.AbstractModuleComponentConfigurationLoader.loadModuleComponent(AbstractModuleComponentConfigurationLoader.java:61)
at org.apache.tuscany.core.client.TuscanyRuntime.<init>(TuscanyRuntime.java:105)
at org.apache.tuscany.core.client.TuscanyRuntime.<init>(TuscanyRuntime.java:69)
at sample.Sample7Client.invoke(Sample7Client.java:38)
at sample.Sample7Client.main(Sample7Client.java:31)