Friday, November 23, 2012

Scheduler with ATG StartSQLRepository

I was struggling to identify that how can I reuse the components that used by startSQLRepository batch file to import data to a repository using an ATG scheduler. After doing so much of research I found that it is very simple.

ATG internally uses TemplateParser component to load the repository. This class file has several static methods, here our interest would be on runParser() method which accepts a String[] and PrintWriter object. The String[] should pass the exactly same arguments as StartSQLRepository command without -m. Instead of -m, we need to pass -configPath (you can get the configPath using this.getNucleus.getConfigPath(String serverName)).

Example

String[] args = new String[5];
args[0]="-repository";
args[1]=getRepository();
args[2]="-outputSQL";
args[3]="-configPath";
args[4]=configPath;

int temp = TemplateParser.runParser(args, new PrintWriter(System.out, true));

This works!

Reference - http://www.oracle.com/technetwork/indexes/documentation/atgwebcommerce-393465.html

Inconsistent datatypes: expected CHAR got NUMBER

Did you ever get the following exception while deploying projects in BCC especially in case of an automated load or bulk load using importRepository or startSQLRepository utilities?


CONTAINER:atg.deployment.manifest.ManifestException; SOURCE:atg.versionmanager.exceptions.VersionException: Unable to check in workspace testProject.
        at atg.deployment.loader.RepositoryDataLoader.addError(RepositoryDataLoader.java:2069)
        at atg.deployment.loader.RepositoryDataLoader.doImport(RepositoryDataLoader.java:2722)
        at atg.deployment.loader.RepositoryDataLoader.execute(RepositoryDataLoader.java:1529)
        at atg.deployment.loader.RepositoryDataLoader.main(RepositoryDataLoader.java:1484)
Caused by: atg.versionmanager.exceptions.VersionException: Unable to check in workspace gopicheckin5.
        at atg.versionmanager.impl.WorkspaceRepositoryImpl.checkInAll(WorkspaceRepositoryImpl.java:1166)
        at atg.deployment.loader.RepositoryDataLoader.checkIn(RepositoryDataLoader.java:2977)
        at atg.deployment.loader.RepositoryDataLoader.doImport(RepositoryDataLoader.java:2718)
        ... 2 more
Caused by: CONTAINER:atg.repository.RepositoryException; SOURCE:java.sql.SQLException: ORA-00932: inconsistent datatypes: expected CHAR got NUMBER

        at atg.adapter.version.VersionItemDescriptor.isAnyOutOfDate(VersionItemDescriptor.java:7288)
        at atg.adapter.version.VersionRepository.checkInInternalOptimized(VersionRepository.java:3188)
        at atg.adapter.version.VersionRepository.checkIn(VersionRepository.java:3120)
        at atg.versionmanager.impl.WorkspaceRepositoryImpl.checkInAll(WorkspaceRepositoryImpl.java:1143)
        ... 4 more
Caused by: java.sql.SQLException: ORA-00932: inconsistent datatypes: expected CHAR got NUMBER

If anybody got this error, I am sure that you must have spent lot of time to figuring out whats the issue, indeed I had spent lot of time :)

Anyway there is no direct mapping between the error message displayed on the logs and the actual issue. The error logs must be misguiding you to look into your DB logs since the error had thrown from the DB (SQLException).

So what is the actual issue here? It is very simple, most of the time you will get this error when the number of assets in the project is more than configured (Strange indeed, why can't ATG give a proper error message- no idea on that ).

To resolve this issue, we need to update the total asset allowed in the project using the below component.

/atg/epub/version/VersionManagerService.workspaceOptimizationThresholdAssetCount