SOA Suite 12c: Getting started with the Spring Component

3
Share this on .. Tweet about this on TwitterShare on LinkedIn6Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

The Oracle SOA Suite Spring component has been present since SOA Suite 11.1.1.3 (11gR1 PS2). This component allows easy integration of Java code with other SOA Suite components such as (among others) BPEL, BPM and Business Rules. In SOA Suite 12c (12.1.3.0) this component is still present. In This blog post I will provide a short example on how it can be used and how the first problem I encountered with this component can be avoided.

Oracle Spring

Implementation

First create a SOA Application and an empty project. Next create a Java class with a public method and extract an interface with the public method. You can also supply JARs in the SCA-INF/lib folder of the project with the class/interface.

Extract interface from Java class

The result in this example. The Java class extends the interface.


package nl.amis.smeetsm.springapp;
import org.eclipse.persistence.Version;
public class EclipselinkUtils implements IEclipselinkUtils {
public String getVersion() {
return Version.getVersion().toString();
}
}


package nl.amis.smeetsm.springapp;
public interface IEclipselinkUtils {
String getVersion();
}

Next drag the Spring component from the component palette to the composite editor.

Add Spring Component

Give your new component an understandable name. Open the component. Paste the following (specific to this example);


<sca:service name="EclipselinkUtilsService" target="impl" type="nl.amis.smeetsm.springapp.IEclipselinkUtils">
<interface.java interface="nl.amis.smeetsm.springapp.IEclipselinkUtils"/>
</sca:service>
<bean name="impl" class="nl.amis.smeetsm.springapp.EclipselinkUtils"/>

On the following page; http://www.oracle.com/technetwork/articles/soa/jellema-events-soasuite-1902429.html at ‘Implementing the Spring Bean’ you can find more explanation on how to provide services and references in a Spring Component.

Next in the composite editor, drag the service interface to the services lane and indicate you want a webservice.

Drag and drop

Compile and deploy.

To my own surprise (this was a simple example), the deployment failed.


<Line 43, Column 57>: XML-24509: (Error) Duplicated definition for: 'identifiedType'
<Line 60, Column 28>: XML-24509: (Error) Duplicated definition for: 'beans'
<Line 157, Column 34>: XML-24509: (Error) Duplicated definition for: 'description'
<Line 169, Column 29>: XML-24509: (Error) Duplicated definition for: 'import'
<Line 191, Column 28>: XML-24509: (Error) Duplicated definition for: 'alias'
<Line 220, Column 33>: XML-24509: (Error) Duplicated definition for: 'beanElements'
<Line 235, Column 44>: XML-24509: (Error) Duplicated definition for: 'beanAttributes'
<Line 510, Column 43>: XML-24509: (Error) Duplicated definition for: 'meta'
<Line 518, Column 35>: XML-24509: (Error) Duplicated definition for: 'metaType'
<Line 535, Column 27>: XML-24509: (Error) Duplicated definition for: 'bean'
<Line 555, Column 38>: XML-24509: (Error) Duplicated definition for: 'constructor-arg'
<Line 623, Column 51>: XML-24509: (Error) Duplicated definition for: 'property'
<Line 634, Column 32>: XML-24509: (Error) Duplicated definition for: 'qualifier'
<Line 650, Column 48>: XML-24509: (Error) Duplicated definition for: 'attribute'
<Line 660, Column 36>: XML-24509: (Error) Duplicated definition for: 'lookup-method'
<Line 696, Column 38>: XML-24509: (Error) Duplicated definition for: 'replaced-method'
<Line 733, Column 31>: XML-24509: (Error) Duplicated definition for: 'arg-type'
<Line 760, Column 26>: XML-24509: (Error) Duplicated definition for: 'ref'
<Line 798, Column 28>: XML-24509: (Error) Duplicated definition for: 'idref'
<Line 832, Column 28>: XML-24509: (Error) Duplicated definition for: 'value'
<Line 860, Column 27>: XML-24509: (Error) Duplicated definition for: 'null'
<Line 874, Column 39>: XML-24509: (Error) Duplicated definition for: 'collectionElements'
<Line 892, Column 27>: XML-24509: (Error) Duplicated definition for: 'list'
<Line 915, Column 26>: XML-24509: (Error) Duplicated definition for: 'set'
<Line 936, Column 26>: XML-24509: (Error) Duplicated definition for: 'map'
<Line 957, Column 45>: XML-24509: (Error) Duplicated definition for: 'entry'
<Line 966, Column 28>: XML-24509: (Error) Duplicated definition for: 'props'
<Line 988, Column 26>: XML-24509: (Error) Duplicated definition for: 'key'
<Line 999, Column 27>: XML-24509: (Error) Duplicated definition for: 'prop'
<Line 1018, Column 39>: XML-24509: (Error) Duplicated definition for: 'propertyType'
<Line 1061, Column 41>: XML-24509: (Error) Duplicated definition for: 'collectionType'
<Line 1073, Column 40>: XML-24509: (Error) Duplicated definition for: 'listOrSetType'
<Line 1082, Column 34>: XML-24509: (Error) Duplicated definition for: 'mapType'
<Line 1104, Column 36>: XML-24509: (Error) Duplicated definition for: 'entryType'
<Line 1143, Column 36>: XML-24509: (Error) Duplicated definition for: 'propsType'
<Line 1156, Column 45>: XML-24509: (Error) Duplicated definition for: 'defaultable-boolean'
<Line 17, Column 33>: XML-24509: (Error) Duplicated definition for: 'annotation'
<Line 36, Column 45>: XML-24509: (Error) Duplicated definition for: 'typedParameterType'
<Line 40, Column 38>: XML-24509: (Error) Duplicated definition for: 'exportsType'
<Line 63, Column 45>: XML-24509: (Error) Duplicated definition for: 'registersScopeType'
<Oct 8, 2014 7:01:13 PM CEST> <Error> <ServletContext-/soa-infra> <BEA-000000> <Error during deployment
oracle.fabric.common.FabricException: Deployment Failed: Error occurred during deployment of component: EclipselinkUtilsSpring to service engine: implementation.spring, for composite: StringProject: SCA Engine deployment failure.: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 6 in XML document from URL [oramds:/deployed-composites/default/StringProject_rev1.0/Spring/EclipselinkUtilsSpring.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 1523; <Line 6, Column 1523>: XML-24500: (Error) Can not build schema 'http://www.springframework.org/schema/util' located at 'http://www.springframework.org/schema/util/spring-util.xsd'
at oracle.integration.platform.blocks.deploy.StandaloneCompositeDeploymentCoordinatorImpl.coordinateCompositeDeployment(StandaloneCompositeDeploymentCoordinatorImpl.java:109)
at oracle.integration.platform.blocks.deploy.StandaloneCompositeDeploymentCoordinatorImpl.coordinateCompositeDeployment(StandaloneCompositeDeploymentCoordinatorImpl.java:70)
at oracle.integration.platform.blocks.deploy.servlet.BaseDeployProcessor.deployNewComposite(BaseDeployProcessor.java:514)
at oracle.integration.platform.blocks.deploy.servlet.BaseDeployProcessor.deploySARs(BaseDeployProcessor.java:305)
at oracle.integration.platform.blocks.deploy.servlet.BaseDeployProcessor.deploySARs(BaseDeployProcessor.java:157)
Truncated. see log file for complete stacktrace

To work around this you need to replace the line in the Spring XML file:


xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://xmlns.oracle.com/weblogic/weblogic-sca META-INF/weblogic-sca.xsd">

with the much shorter line


xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://xmlns.oracle.com/weblogic/weblogic-sca META-INF/weblogic-sca.xsd">

Something with the XML parser supplied with Weblogic server 12.1.3 apparently… (see http://stackoverflow.com/questions/5005901/duplicated-definition-for-identifiedtype)

Confirm it works

After deployment you can test the service to confirm it works.

Conclusion

The Spring component allows for easy integration with other SOA components. In release 12c, the error in 11g when a Java class is not compiled yet (see http://javaoraclesoa.blogspot.nl/2012/03/file-processing-using-spring-component.html) does not occur anymore, which is nice. However we get a different error in return. Luckily it is easily solved and we can enjoy this nice feature.

I’ve not yet found a way to give preference to a local class over the application server classes. I could alter the classpath of the entire server or soainfra but that could have other less pleasant side-effects. Maybe I´ll figure this one out in a later blogpost.

Share this on .. Tweet about this on TwitterShare on LinkedIn6Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

About Author

Maarten is a Senior Oracle Integration Consultant with focus on Oracle Fusion Middleware, Java and Continuous Integration / Continuous Delivery. In 2015 he was nominated ACE Associate. Over the past 10 years he has worked for numerous customers in the Netherlands where he has implemented integrations and streamlined software delivery processes. Maarten is passionate about his job and likes to share his knowledge through publications, frequent blogging and presentations.

3 Comments

  1. Hi,

    My analysis on the above issue is as below. Removing the XSD locations did not help me as I was referring to one of its namespaces(http://www.springframework.org/schema/context) to read an external properties file.

    1. SOA Suite 12.1.1.3 is shipping OOTB with Spring Framework 3.1 and Spring Framework 2.5 from 11g times.

    2. When a spring component is created the xsi:schemaLocation attribute of the root element “beans” in context.xml has values pointing to generic version of Spring Framework schemas like http://www.springframework.org/schema/util/spring-util.xsd
    This resolved to latest version available which is 4.1.
    http://www.springframework.org/schema/util/spring-util-4.1.xsd

    I believe above mismatch in versions is leading to org.xml.sax.SAXParseException during deployment. The Parser in SOA Suite as we know is very stringent and does not even tolerate white spaces in Annotations

    I modified all the schema locations to point to 3.1 schemas as below which resolved my problem.(I was using Spring 3.1 framework which is default)
    http://www.springframework.org/schema/util/spring-util-3.1.xsd

  2. Hi Do you think using Spring SCA is a good implementation approach ? I am afraid to embed technological lockin that will be deprecated in future Oracle SOA releases

Leave a Reply