ATG does not allow property values with commas for String[] properties

Typically when you have a property of Strings, either an array or a collection, you would set them like this:

foos=hello,good-bye,this is a test

In the above example if the foos property is of type String [], then ATG initializes foos to { “hello”, “good-bye”, “this is a test” }.

However if one of the String’s has a comma in it then this method won’t work because ATG will treat the comma as a delimiter. For example if foos is configured like this:

foos=hello,good-bye,this is a test\, a big test

then foos is initialized to { “hello”, “good-bye”, “this is a test”, “a big test” }

To get around this apparent limitation, which is documented in Bug #29380, ATG provides a class called atg.core.util.StringList. If you set the type of the foos property to StringList and configure it like this:

foos=hello,good-bye,this is a test,, a big test

then fools will be initialized to { “hello”, “good-bye”, “this is a test, a big test” }. Note that “,,” is the method for escaping commas when using StringList.

java.io.FileNotFoundException for valid URL

In one of our ATG servlet’s we were making a normal HTTP call to a page located on our ATG Dynamo server.

url = new URL(urlString);
connection = (HttpURLConnection)url.openConnection();
reader = new InputStreamReader(connection.getInputStream());

Free Daddy and His Little Shadow Girls at The Skate Park Creative Commons on FlickrHowever when trying to get the input stream we got a FileNotFoundException yet we were able to go to the same URL using a browser. Googling around we found this lovely thread about the same problem.

To summarize the thread, the problem was in our proxy settings which are set on Windows in localconfig/environment.bat and on UNIX in localconfig/environment.sh. An example of proxy settings on Windows is set PROXY_ARGS=-Dhttp.proxyHost=192.168.1.134 -Dhttp.proxyPort=8080.

The proxy server did not recognize our machines as valid clients so it rejected our requests. Once we changed the proxyHost argument to point to a valid server then this problem was fixed.

locallib classes not loading

To override the classes that would run on the ATG server, one simply copies your new classes into the locallib directory under the correct directory which corresponds to the package. To learn more, Modifying the Environment Settings.

However on an ATG Dynamo 4.5.1 server running on FreeBSD I found the locallib classes were not loading no matter how many times I restarted the ATG Dynamo server. I realized finally by accident that the reason these classes weren’t being loaded was because another ATG Dynamo server was running and because of this the Java process was not releasing its understanding of the CLASSPATH. Only after killing the second ATG Dynamo server process was I finally able to get the ATG Dynamo server to load the new classes.

JSP Dynamo Request Retrieval

In JHTML pages, the request object is of class DynamoHttpServletRequest which has many methods that are not part of the HttpServletRequest interface including the very useful resolveName method for looking up components in Nucleus.

In JSP pages on ATG there is no guarantee that the request object is of class DynamoHttpServletRequest. According to the JSP specification the request object always implements the HttpServletRequest interface.

If you need to get the DynamoHttpServletRequest do something like this:

DynamoHttpServletRequest dynRequest  = atg.servlet.ServletUtil.getDynamoRequest(request);

If you need to get a PortalServletRequest do something like this:

PortalServletRequest portalRequest = (PortalServletRequest) request.getAttribute(atg.portal.servlet.Attributes.PORTALSERVLETREQUEST);

JDBC Optimization for Populating a Table

Today I was trying to determine how to optimize the populating of a table. I was using ATG Relational Views which took 3.5 minutes to add 6000 lines to a table.

After googling for awhile I learned how to do this using JDBC directly and was able to do the same populating in 0.14 minutes. That’s quite a performance improvement.

It would be interesting to contract the performance differences using ATG’s repository implementation but right now I am developing on ATG 4.5.1 so I can’t.

These are the links to the sites I used to educate me on PreparedStatement‘s and batching.

ONJava.com: An Introduction to JDBC, Part 3
JavaWorld.com: Overpower the Prepared Statement
PreciseJava.com: Best practices to improve performance in JDBC
DBA-oracle.com: Optimize Oracle INSERT performance

JHTML Structure

The typical JHTML file is structured like this.

<importbean bean="/atg/dynamo/service/jdbc/RelationalViewDroplet">

<nucleus type=import>
  /atg/dynamo/droplet/ForEach
  /atg/dynamo/droplet/Switch
</nucleus>

<java type="import">
  java.util.*
  java.net.*
</java>

<java>
  List ll = (List) request.resolveName("/betweengo/BigList");
</java>

ACC not connecting

If you cannot connect to a site using the ACC try the following.

  1. use the host name instead of the IP address
  2. check that you are using the correct RMI port
  3. telnet to the site using the RMI port and see if you can connect
  4. check the ACC output window to see if there were any exceptions. if there was an UnknownHostException then try adding the host to your hosts file to fix the problem

Note: The host name you use should be the same as the java.rmi.server.hostname Java argument that is set in the server’s postEnvironment.sh.
JAVA_ARGS="${JAVA_ARGS} -Djava.rmi.server.hostname=kimcityqa"

Mysterious 404 errors in ATG J2EE applications

Often during development of an ATG J2EE application one will suddenly run into a 404 error. 404 means that the server could not locate the requested page . But often when one sees this error it is not because ATG could not locate the requested page but because it could not generate the page due to some sort of error which unfortunately ATG sometimes does not log. The error could be one of several.

  1. The J2EE application that contains the page did not properly start or was not started at all. One can check if the application was started either by looking in the ACC under the J2EE Deployment Editor or checking in the dynamo.log if the application was started and/or listed in the list of modules at start up.
  2. A runtime exception occurred in one of the droplets that were invoked in the page. Unfortunately ATG does not log the runtime exception, it is swallowed up somewhere. The best way to debug this is to start removing parts of the JSP page until you discover which part of the page is causing the 404.

ATG forms do not work if action is an HTML page

When creating forms that are to interact with ATG form handlers, one cannot use an HTML page as the action. If one does then the ATG form handler will not be invoked.

For example, this form will not invoke the ATG form handler.

<form name="test" action="test.html" method="get">
  Name: <input type="text" bean="/TestFormHandler.name">
  <p><input type="submit" bean="/TestFormHandler.submit">
</form>

However this form will.

<form name="test" action="test.jhtml" method="get">
  Name: <input type="text" bean="/TestFormHandler.name">
  <p><input type="submit" bean="/TestFormHandler.submit">
</form>