Sunday, October 8, 2017

Create Configure Deploy new JAX-RS ATG Module in Oracle ATG Commerce 11.3

Create Configure Deploy new JAX-RS ATG Module in Oracle ATG Commerce 11.3 ATG Module structure remains same where we need to create new ... thumbnail 1 summary
Create Configure Deploy new JAX-RS ATG Module in Oracle ATG Commerce 11.3

ATG Module structure remains same where we need to create new configuration files for JAX-RS service.

Final JAX-RS Module will contains the following folder structure and files.




We will see all major components and configurations on this module.

1    1.Web.xml

We will start with Application deployment descriptor file(web.xml). Here we are going to add Jersey servlet configuration in addition with our NucleusServlet.

If you already deployed the atg-jaxrspublic-version1.war into your EAR then simply copy the web.xml from there and paste into your new module.  [Refer here to deploy atg-jaxrspublic-version1.war]
·             Change the context-root to public/service [You can give the value as per the needs]
·             You can see the Jersey servlet configuration to load jaxrs servlet classes and other swagger related classes.




1    2. JerseyClassLoaderService.properties

This component is registers the classpathFiles files and childFirstPrefixes.

#JerseyClassLoaderService.properties
childFirstPrefixes+=\
              atg/service/jaxrs/security,\
              atg/userprofiling/restresources

classpathFiles+=\
       {appModuleResource?moduleID=JAX-RS.REST&resourceURI=lib/classes.jar}

[Note: Instead of classes.jar you can create a jar file with jersey-classloader.jar and that can be specified here]


3. RestResourceRegistry.properties

The RestResourceRegistry   register a Nucleus REST resource with Jersey. [This is similar to /atg/rest/registry/ActorChainRestRegistry.properties in MVC REST]

#RestResourceRegistry.properties

nucleusRestResources+=\
/com/userprofiling/UserLookupByEmailResource

1    4. PayloadSchemaRegistry.properties

This component provides the path to the payloadSchema.xml.
Payload schema framework provides validation framework to handles validation and updating target dynamic beans

definitionFile=atg/dynamo/service/payloadschema/payloadSchema.xml
[This is similar to Bean filtering in MVC REST]

2.      payloadSchema.xml
This file defines the actual payload schema tags. Each schema tag represents a java-bean class or a repository item type and specifies the entity that validation input represents.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE payload-schemas PUBLIC "-//Art Technology Group, Inc.//Payload Schema Specifier
Specifier 1.0//EN" "http://www.atg.com/dtds/payloadschema/payloadschema_1.0.dtd">
<payload-schemas>

  <!--***********************************************************************-->
  <!--    The filters defined below should be kept in alphabetical order.    -->
  <!--***********************************************************************-->

  <!--*************************************************-->
  <!--                   RESPONSE VOs  for filterId attribute in service  operation  -->
  <!--*************************************************-->
  <schema id="xxx-id-validate" include-all-simple="true">
    <untyped-bean/>
    <property name="email" required="true">
      <validator-instance class="EmailValidator"/>
    </property>

  </schema>
  </payload-schemas>

<!-- @version $Id: //product/DCS/version/11.3/templates/DCS/config/atg/dynamo/service/payloadschema/payloadSchema.xml#4 $$Change: 1392901 $ -->


Once you assemble the EAR files with this module you can access your custom service. We will see how to create a new custom service and end points in up coming posts.

Thanks.

1 comment

  1. Hi Bala,

    I am trying to create ATG module with jaxrs but when I add a class with jersey annotations somehow server is not getting started Server is throwing error: weblogic.application.ModuleException: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map.

    I looked into this error and found out getProperties method exist in Application class of javax.ws.rs-api-2.1.0.jar. I added 2.0 jersey jar files in module Manifiest.mf still application is not starting up. Actually javax.ws.rs.core.Application class is being reffered from weblogic libraray /opt/app/weblogic/oracle_common/modules/jsr181-api.jar.

    My question is: have you faced this issue while creating resource locally? if yes what did you do to sole this. if not then Can you please share your custom MENIFEST.MF and web.xml.

    ReplyDelete