I’ve been eyeing up the ATG Commerce Reference Store’s native iOS app ever since it was added with Commerce Reference Store (CRS) 10. It’s not too bad and proves the point that Oracle Commerce/ATG can be ported into mobile environments. Here are the steps I took to get the app completely functional.
Note: You will need an Apple computer with Xcode installed.
The mobile app differs from traditional Oracle Commerce/ATG because it uses a REST API to communicate with Oracle Commerce/ATG, rather than the HTML/JSP route. The REST API was released in ATG 9 and is bundled with the core platform.
First, start your publishing and storefront servers because CIM (and we) require them for the importing of some targeters. Then run CIM:
1. From the main menu, navigate to “Product Selection” and add the “Oracle Commerce REST” option. From there, you’re going to need to step through much of the configuration you did with the CRS installation.
- For the CRS Addons menu, add “Mobile Reference Store”
- For “Mobile Reference Store Web Services”, add “REST Web Services for Native Applications”
2. Next, step through the database steps. Both servers are going to have a bit of data to load because of the new mobile configurations.
3. In the server instance configuration menu, select the production server and then chose the option to provision the EAC application.
4. Do a full deployment from the BCC. Ensure that an index is kicked off by checking the progress in Dyn/admin from the /atg/commerce/endeca/index/ProductCatalogSimpleIndexAdmin component.
5. If the index was successful, push the index to production using:
6. Download “CRS-IUA for version 11.1 (includes the Objective-C REST client for version 11.1)” from here. This is the code that interfaces directly with the iOS device and the REST API.
7. Open the file up and click the StoreWorkspace.xcworkspace file. It should open up the project in Xcode.
8. From the file navigator, search for MobileCommerce-info.plist and open it. Edit the ATG_REST_SERVER_HOST and ATG_REST_SERVER_PORT values as shown.
9. From the top menu, select Product >> Run to build and start the app in the emulator.
10. Once up, use the hardware >> home option to go to home, then head into the settings. Select the Mobile Store app and add in the hostname and port of the store. It should be localhost and 8080 respectively.
At this point the app should be functional. The application has a lot of logging, so you can monitor things pretty well using the log provided in xcode. If there is a problem see the troubleshooting section below.
Make sure to try keyword search to ensure full Endeca functionality. Check the storefront log along with the xcode log for any issues.
Keep in mind that the app was created for iOS 7.1, so there could be some compatibility issues with the iOS 8 simulators, particularly the new screen sizes with the iPhone 6. If you have a newer version of xcode with only iOS 8.x simulators available, I’d recommend going into preferences >> downloads and downloading the iOS 7.1 simulator just in case.
I had lots of problems with getting the mobile environment setup. I think they stemmed from the fact that I was doing two sets (one for initial CRS and one for iOS) of configurations, two database imports, two full deployments, two Endeca application provisioning, etc. If the CRS had been installed with the REST-iOS App configurations at the same time, it would have been less error-prone.
Endeca Application Provisioning
During the CIM step where you deploy the updated Endeca application, it was failing because there was the existing CRS application already in its place, and CIM is not smart enough to delete it. I created this script to remove the Endeca app. Run it as Oracle and it should completely wipe the CRS Endeca application out and allow CIM to import the new one without errors.
CIM Data Import
First, I found in the CIM log ($DYNAMO_ROOT/CIM/log/cim.log):
“/atg/dynamo/server/RmiServer unable to register atg/devtools/DevAgent to /atg/dynamo/server/RmiServer java.rmi.AlreadyBoundException: atg/devtools/DevAgent”
The CIM nucleus instance steals port 8860 for RMI, which kicks the production port out. I solved this problem by moving around the prod and pub ports and changing the server configs at:
$DYNAMO_HOME/servers/atg_(production | publishing)_lockserver/localconfig/atg/dynamo/Configuration.properties and changing rmiPort=8760 for production and rmiPort=8950 for publishing.
Then I was immediately faced with:
“/atg/dynamo/service/loader/LoaderManager caught exception in ArrayBackedJob.runJob atg.repository.loader.LoaderEventException: You have one or more initialized target sites. An import directly into a workspace will prevent deployment of imported assets. Please import into a process.”
This is solved easily by deleting the “Production” site and associated agent in the BCC and retrying the import.
Then, with the full deployment, I found the error:
“Snapshot ID XXXX is not valid for target ‘Production’. Please verify that each agent server in target XXXX has a valid snapshot, or delete all deployment meta-data on each agent server before attempting to re-use it as a part of a new target.”
Which I fixed (based on this thread) by deleting the following directories and restarting each server:
rm -rf $DYNAMO_HOME/servers/atg_publishing_lockserver/Publishing/deployment/data
rm -rf $DYNAMO_HOME/servers/atg_production_lockserver/PublishingAgent/data
In a nutshell, BCC deployments became out of line because of deleting and re-creating the deployment target.
Running the App
At first, the app was throwing errors like this:
“ATGMobileCommerce[fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][74328:60b] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSDictionaryM attributes]: unrecognized selector sent to instance 0x78656e20’”
I soon became smart enough to check my storefront log and also found some Endeca errors:
“[atg.endeca.assembler.multisite.ExtendedSiteManager] (http-/0.0.0.0:8080-3) Unable to retrieve site definition for site id: /mobileStoreSiteUS: com.endeca.store.exceptions.PathNotFoundException: No node found at path [//pages/mobileStoreSiteUS]”
If these things happen, your Endeca, especially for mobile, is broken. Some tips:
- Check the workbench to verify all Endeca services for the CRS application are running.
- Browse the desktop site to see if anything is also breaking.
- Check the experience manager and ensure you have mobile site pages defined for the CRS application. If they don’t exist, you’ll have to reprovision the Endeca application from CIM.