Friday, December 23, 2011

ATG - runAssembler The system cannot find the path specified

Problem

I was running ATG runAssembler script and got the following error

C:\ATGDEV\ATG\ATG10.0.2\home\bin>runAssembler DCSSampleCatalog.ear -m DCSSampleCatalog;DafEar.Admin
The system cannot find the path specified.

Solution

I opened up the runAssembler batch file, switched echo on and then reran the runAssembler command above. Figured out that the issue was with the path of the java exe, it was pointing to a wrong path. Actually I uninstalled JDK and reinstalled it onto some other path after I installed ATG and that was the cause of the issue. I had to open the dasEnv.bat inside ATG_HOME\localconfig folder and update the ATGJRE environment variable to point to the new java.exe path. Reran the runAssembler command it worked fine.

C:\ATGDEV\ATG\ATG10.0.2\home\bin>runAssembler DCSSampleCatalog.ear -m DCSSampleCatalog;DafEar.Admin
Assembly started.
Target application is C:\ATGDEV\ATG\ATG10.0.2\home\bin\DCSSampleCatalog.ear.
 Creating exploded ear file C:\ATGDEV\ATG\ATG10.0.2\home\bin\DCSSampleCatalog.ear.
Initializing...
 Before make meta-inf file.
Making meta-inf file C:\ATGDEV\ATG\ATG10.0.2\home\bin\DCSSampleCatalog.ear\META-INF
Creating application.xml...
 Creating Ear file MANIFEST...
 Importing classes...
Importing classes for module DafEar
 Importing classes for module DafEar.Admin
 Importing classes for module DafEar.base
      Importing classes for module DCSSampleCatalog
 Importing classes for module DCS
   Importing classes for module DSS
   Importing classes for module DPS
   Importing classes for module DAS-UI
    Importing classes for module DAS
  Ignoring classpath entry lib/servlet.jar from module DAS
 Ignoring classpath entry lib/jsp-api.jar from module DAS
      Importing classes for module manuals
  Importing J2EE module atg-admin.war declared in DafEar.Admin
  Parsing C:\ATGDEV\ATG\ATG10.0.2\home\bin\DCSSampleCatalog.ear\atg_admin.war\WEB-INF\web.xml
 Importing J2EE module atg-bootstrap.war declared in DafEar.base
  Parsing C:\ATGDEV\ATG\ATG10.0.2\home\bin\DCSSampleCatalog.ear\atg_bootstrap.war\WEB-INF\web.xml
 Importing J2EE module atg-bootstrap-ejb.jar declared in DafEar.base
 Importing J2EE module sampleCatalog.war declared in DCSSampleCatalog
  Parsing C:\ATGDEV\ATG\ATG10.0.2\home\bin\DCSSampleCatalog.ear\sampleCatalog.war\WEB-INF\web.xml
  Assembly took 2.72 seconds.

Thursday, December 22, 2011

ATG - Caused by: java.lang.IllegalStateException: jboss.web.deployment:war=/dyn is already installed.

Problem

I recently deployed my ATG application EAR onto my JBoss and started by JBoss Server. The server started but it threw the following exception almost at the end of the startup

5:32:00,577 ERROR [AbstractKernelController] Error installing to Real: name=vfsfile:/C:/jboss-
eap-5.1/jboss-as/server/Admin/deploy/Live.ear/ state=
PreReal mode=Manual requiredState=Real
org.jboss.deployers.spi.DeploymentException: Error deploying: jboss.web.deployment:war=/dyn
        at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
        at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:118)
        at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
        at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
        at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55)
        at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179)
        at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1454)
        at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1172)
        at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1193)
        at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1225)
        at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1113)
        at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)
        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)
        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)
        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:826)
        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:556)
        at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:789)
        at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:699)
        at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
        at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
        at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
        at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:403)
        at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)
        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)
        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)
        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:778)
        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:543)
        at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(AbstractProfileService.java:308)
        at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:256)
        at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
        at org.jboss.Main.boot(Main.java:221)
        at org.jboss.Main$1.run(Main.java:556)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: jboss.web.deployment:war=/dyn is already installed.
        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:719)
        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:543)
        at org.jboss.system.ServiceController.doInstall(ServiceController.java:670)
        at org.jboss.system.ServiceController.install(ServiceController.java:273)
        at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:90)
        ... 35 more
15:32:00,629 INFO  [ProfileServiceBootstrap] Loading profile: ProfileKey@462d62d9[domain=default, server=default, name=Admin]
15:32:00,632 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

DEPLOYMENTS IN ERROR:
  Deployment "vfsfile:/C:/jboss-eap-5.1/jboss-as/server/Admin/deploy/Live.ear/" is in error due to the following reason(s): java.lang.IllegalStateEx
ception: jboss.web.deployment:war=/dyn is already installed.

Solution

After a quick analysis I found that the above error was thrown when I had two ATG EARs inside my jboss server's deploy folder. Its always advisable to build all necessary modules into a single ATG EAR and deploy it onto to the application server. I removed the old unwanted EAR and the error vanished.The above error was caused because both my ATG EARs were built with DafEar.Admin which adds the dyn content. Having two EARs could also cause other issues, so watchout.


Tuesday, December 20, 2011

ATG - javax.naming.NameNotFoundException: ca not bound

Problem

I was getting the following error when I was starting my JBoss Server with an ATG Application deployed. I had a custom datasource by name DirectJTDataSource_CA which was having a JNDI configured as java:/ca - JNDIName=java:/ca

14:43:28,178 ERROR [DirectJTDataSource_CA]
javax.naming.NameNotFoundException: ca not bound
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
        at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
        at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at atg.nucleus.JNDIReference.getReference(JNDIReference.java:140)
        at atg.nucleus.JNDIReference.doStartService(JNDIReference.java:116)

Solution

The issue was because I did not have the JNDI "ca" configured in my jboss ds.xml file. I added the same (see below for what I added) pointing to the schema I had to point it to and restarted the server and the error was gone.

 <xa-datasource>
      <jndi-name>ca</jndi-name>
      <track-connection-by-tx>false</track-connection-by-tx>
      <isSameRM-override-value>false</isSameRM-override-value>
      <min-pool-size>5</min-pool-size>
      <max-pool-size>100</max-pool-size>
      <blocking-timeout-millis>5000</blocking-timeout-millis>
      <idle-timeout-minutes>15</idle-timeout-minutes>
      <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
      <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
      <xa-datasource-property name="URL">jdbc:oracle:thin:@localhost:1521:XE</xa-datasource-property>
      <xa-datasource-property name="User">atg_ca</xa-datasource-property>
      <xa-datasource-property name="Password">atg123</xa-datasource-property>
      <!-- Uncomment the following if you are using Oracle 9i
          <xa-datasource-property name="oracle.jdbc.V8Compatible">true</xa-datasource-property>
      -->
      <exception-sorter-class-name> org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
      </exception-sorter-class-name>
  </xa-datasource>

ATG - atg.repository.rql.RqlStatement java.lang.IllegalArgumentException: CONTAINER:atg.repository.RepositoryException

Problem

I got this pretty simple error when I tried to inject an RQLStatement through a component property file and try and start my component

10:52:59,566 ERROR [nucleusNamespace.] Cannot parse property value "id=?0 OR name CONTAINS ?1 OR myBillingAddrs INCLUDES ITEM(postalCode CONTAINS ?2 OR city CONTAINS ?3" of "/demoApp/customer/dao/Cust
omerDAO.organizationSearchRQL" as a atg.repository.rql.RqlStatement java.lang.IllegalArgumentException: CONTAINER:atg.repository.RepositoryException; SOURCE:atg.repository.rql.ParseException: Encounte
red "<EOF>" at line 1, column 100.
Was expecting one of:
    <AND> ...
    <OR> ...
    ")" ...
    "." ...

Solution

The error message was pretty clear. I was missing a closing brace ")" at the end of the RQLStatement at column 100 as rightly notified by the Exception.

id=?0 OR name CONTAINS ?1 OR myBillingAddrs INCLUDES ITEM(postalCode CONTAINS ?2 OR city CONTAINS ?3)


Monday, December 19, 2011

ATG - atg.search.routing.RoutingSearchException: No engines responded. Verify the configuration for environment 'default1'

Problem

I was getting the following error when I tried to start my Live aka Core aka StoreFront server which was using ATG Search and tried to do a Search.

atg.search.routing.RoutingSearchException: No engines responded. Verify the configuration for environment 'default1' 

I was also seeing a couple of warnings as below.

13:27:06,212 WARN  [RoutingSearchService] No running search engines for env default1, partition 1000117 in LP Content Set 1
13:27:06,346 WARN  [RoutingSearchService] No running search engines for env default1, partition 1000117 in LP Content Set 1



Solution

Assuming that you have had your Search configured properly and deployed and its been working before and suddenly it has started giving the above mentioned errors, here is the solution. Its probably because your atgsearch.exe isnt running anymore and you may have to start it manually by going into CA/Search Administration and start the default1 instance or you can follow the below steps to start it using the dyanmo admin of the Live server.


1. If you Live server is running on port 8180, navigate to http://localhost:8180/dyn/admin/nucleus/atg/search/routing/RoutingSystemService/


2. You should be able to see all the configured search environments in a table.


3. Click on the start link against the search environment which you have to start, in my case it was default1 as the error notified.


4. After clicking on the start link wait for the RunningEngineCount to show a value > 0

5. When the RunningEngineCount is greater than 0, do a search on your StoreFront application and it should work now.



Saturday, December 17, 2011

Software Tools

Some software that I have used
  • Microsoft Excel - Maintain use cases, list of requirements
  • Microsoft Word - Design Documents and user guides
  • Microsoft Powerpoint - Best tool for creating step by step screenshot based installation guide or test log screen captures - My onsite coordinator Keerthi @ Metlife did this once and I just loved it.
  • Microsoft Visio - Good to create flow diagrams and share with clients, if you feel there are complex designs better to represents as flow diagrams in Visio or draw them in Visio and export them as PDF - Mukundh you are the best :)
  • Textpad - I just love this. An amazing editor. I cannot live without it. I have been using it for 10 years and never repented. Find in files, Regex Search, Macros, Fill blocks and what not....Whoever has developed this and still working on updates - Great work guys.
  • ProcessExplorer - Funky tool that shows all information about the processes running in your box. Believe me it has lot more than task manager. Its good to find PID of java processes :D thats what I used initially for. Thanks to Bobby for navigating me to this tool.
  • Putty - This is another best utility to just login to any remote unix/linux/solaris box which you have access to and play around. Its just not one but a collection of small utilities like secure copy and a lot more.
  • UnxUtils - Are you a unix shell user and always wondered if you can do an "ls" or a "grep" on windows ??? Here is the solution. Courtesy - Bobby.
  • Autopatch - We always talked about Database updates being done through a single channel and updated properly to all environments - say you have a lot of developers making db changes and you want to make sure that the changes are recorded and executed along with the code changes when you move your code from INTEGRATION to QA to STAGING to PROD. This is an amazing little tool for that job. Worked fine for my projects.
  • Schema Spy - Recently found this amazing tool to maintain data dictionaries - Surely everybody should give it a shot. It does a very good reverse engineering so what I would suggest is dont use Microsoft excel to create data dictionary even if you Architect or team lead suggests it. Create all your tables in MS Access or something and reverse engineer using this tool. It rocks. You should try it once at least.
1. Install a JDK/JRE 1.5 in your machine and add the JDK/JRE bin folder to your PATH environment variable
2. Download SchemaSpy from - http://schemaspy.sourceforge.net/. Its just a Zip file. You can download it to a folder, say D:\Work
3. Download GraphViz from http://www.graphviz.org/Download..php and install the same. Add the <<GraphViz Install Dir>>/bin to your PATH environment variable.
4. You should have the JDBC driver jar/zip file for the database downloaded to your machine.
5. Open a new command prompt and run the following command in this directory - D:\Work [Directory that has the SchemaSpy zip file]
    java -jar <<schemaspy zip file name>> -db <<Database name>> -s <<Schema name>> -u <<user name>> -p <<password>> -o <<Output directory>> -dp <<full path to the jdbc driver including the jar/zip name>>

For Example
    java -jar schemaSpy_4.1.1.zip -db XE -s TEST -u TEST -p test -o "D:\Naga\DD_TEST" -dp "D:\OracleXE\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar"

After this command is run, the <<Output Directory>> will contain all the data dictionary information
  • Graphviz - This is a tool that works with Schema Spy to display the relationships between the tables, without this Schema spy displays the data dictionary but this would also be good to have integrated. Why not try this when its free :)
  • UMLGraph - I used UMLGraph recently to generate java docs. Its like you have to add umlgraph as a doclet when you generate javadocs and it will add a class diagram hierarchy automatically to your java docs...Sweeeeeeeet
1. Assuming you have already downloaded the umlgraph jar and you have jdk/jre installed and have javadoc on path. You also need to have GraphViz\bin in path. Its the same utility that we used above

2. Open a new command prompt and run the following command
    javadoc -encoding UTF-8 -docletpath <<Path to UmlGraph jar>> -doclet gr.spinellis.umlgraph.doclet.UmlGraphDoc -sourcepath <<Path to source files separate using ;>> -classpath <<Path to all dependant classes, remember to include UmlGraph jar as well>>  -d <<Output Directory>> -subpackages <<if you need only specific subpages to have java docs generated for, i was not interested in generated API for java packages ;)>>
   
For Example   
    javadoc -encoding UTF-8 -docletpath "D:\Naga\UmlGraph-4.8.jar" -doclet gr.spinellis.umlgraph.doclet.UmlGraphDoc -sourcepath "D:\ATG\ATG2006.3\ATGDemo\src" -classpath "D:\ATG\ATG2006.3\DAS\lib\classes.jar;D:\ATG\ATG2006.3\DPS\lib\classes.jar;D:\ATG\ATG2006.3\DSS\lib\classes.jar;D:\ATG\ATG2006.3\DCS\lib\classes.jar;D:\ATG\ATG2006.3\DAS\lib\servlet.jar;D:\ATG\ATG2006.3\ATGDemo\lib\classes.jar"  -d "D:\ATG\ATG2006.3\ATGDemo\javadocs" -subpackages com

  • Eclipse - Best IDE for Java.
  • VisualGC - For java garbage collection information. It connects to a JVM and shows GC info realtime - See this article for info.
  • GCViewer - Here is another tool which can analyse the logs after its generated like offline GC analyser which is good too. I liked the whole throughput thing :) - See this article for more information and good graphics to give you an idea.
  • Windows PowerShell - An object oriented shell for Microsoft OS. Easy to write scripts which can help you do anything with your OS. 1000 times better and easier when compared to the old Batch scripts. Courtesy - Bobby.
  • Eclipse Commons 4E Plugin - Got introduced to this plugin in one of my earlier projects. Nice and easy eclipse plugin to generate hashCode, toString, compareTo and equals methods using Apache Commons Lang library.
  • Eclipse Java Decompiler Plugin - I always had problem figuring out how things work in a framework when i am debugging my application from within Eclipse, because most of the time I dont have the source files for the framework. With JD-Decompiler and the realignment plugin that comes with the plugin, I was able to decompile the framework classes and also debug the classes from within Eclipse.

ATG - IPlanet/Dynamo Address already in use error

Problem

I got the following error when I was testing my iplanet  [sun java system web server] connected to dynamo server via the connection module
[27/Feb/2009:13:54:11] failure ( 2784): for host 10.2.30.43 trying to GET /demo/index.jsp, Dynamo NSAPI Module reports: Cannot connect to DRP server due to the error: Address already in use (WSAEADDRINUSE).
[27/Feb/2009:13:54:11] warning ( 2784): for host 10.2.30.43 trying to GET /demo/index.jsp, Dynamo NSAPI Module reports: Failure while attempting to use DRP server at 10.2.30.43:8850 to service a request.

Solution

I fixed it by adding a MaxUserPort property as mentioned in http://support.microsoft.com/kb/319502 and restarted my iplanet web and admin servers and it started working properly.

ATG - Illegal attempt to diff snapshots on different branches

Problem
    Are you getting the following error in your when you deploy projects from BCC to a target ? Are you using late staged deployment ?

[12/27/08 7:24:35:795 UTC] 000000be SystemOut     O /atg/epub/DeploymentServer  ---     CONTAINER:atg.deployment.common.DeploymentException: Deployment '{0}' to target '{1}' encountered a versioning error building the manifest.; SOURCE:atg.versionmanager.exceptions.VersionException: java.lang.IllegalArgumentException: illegal attempt to diff snapshots on different branches.
        at atg.deployment.common.ResourceUtil.exception(ResourceUtil.java:360)
        at atg.deployment.adapter.DistributedDeploymentAdapter.createStandardDeploymentData(DistributedDeploymentAdapter.java:1082)
        at atg.deployment.adapter.DistributedDeploymentAdapter.createDeploymentData(DistributedDeploymentAdapter.java:554)
        at atg.deployment.adapter.DistributedDeploymentAdapter.transferData(DistributedDeploymentAdapter.java:277)
        at atg.deployment.server.Deployment.run(Deployment.java:1549)
        at java.lang.Thread.run(Thread.java:570)
Caused by :atg.versionmanager.exceptions.VersionException: java.lang.IllegalArgumentException: illegal attempt to diff snapshots on different branches.
        at atg.versionmanager.impl.SnapshotRepositoryImpl.createSnapshotDiff(SnapshotRepositoryImpl.java:108)
        at atg.deployment.adapter.DistributedDeploymentAdapter.createStandardDeploymentData(DistributedDeploymentAdapter.java:1034)
        at atg.deployment.adapter.DistributedDeploymentAdapter.createDeploymentData(DistributedDeploymentAdapter.java:554)
        at atg.deployment.adapter.DistributedDeploymentAdapter.transferData(DistributedDeploymentAdapter.java:277)
        at atg.deployment.server.Deployment.run(Deployment.java:1549)
        at java.lang.Thread.run(Thread.java:570)
Caused by (#2):java.lang.IllegalArgumentException: illegal attempt to diff snapshots on different branches.
        at atg.versionmanager.impl.SnapshotRepositoryImpl.createSnapshotDiff(SnapshotRepositoryImpl.java:108)
        at atg.deployment.adapter.DistributedDeploymentAdapter.createStandardDeploymentData(DistributedDeploymentAdapter.java:1034)
        at atg.deployment.adapter.DistributedDeploymentAdapter.createDeploymentData(DistributedDeploymentAdapter.java:554)
        at atg.deployment.adapter.DistributedDeploymentAdapter.transferData(DistributedDeploymentAdapter.java:277)
        at atg.deployment.server.Deployment.run(Deployment.java:1549)
        at java.lang.Thread.run(Thread.java:570)

Solution
    I got this error because i was having both my staging and production targets in my late staged workflow point to the same node. When i made them point to two different customer facing node instances the issue got resolved.

ATG - IPlanet/Dynamo Failure to connect via TCP to Load Manager

Problem
    Are you getting the following error in your iplanet error log ?

[20/Mar/2009:01:58:50] info ( 4476): WEB0100: Loading web module in virtual server [https-machinename.com] at [/search]
[20/Mar/2009:01:58:50] failure ( 4476): Dynamo NSAPI Module reports: CMLDRP(TCP) Failure to connect via TCP to Load Manager=192.168.1.100:8880, io status=Connection refused.  Please check that the IP Address and Port of the Load Manager is correct and that the Load Manager is using TCP instead of UDP.

Solution
    I had my Dynamo and IPlanet connected via the Dynamo Connection module and the load manager component on the Dynamo App Server side was not started. So I started the following in the atg/dynamo/Configuration.properties and restart the app server and the issue got fixed

loadManagerEnabled=true
drpEnabled=true

ATG - atg.service.idgen.IdGeneratorException java.sql.SQLException: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

Problem
    Are you getting the following error when you start your dynamo server ?

**** Error      Thu Mar 19 23:46:20 CST 2009    1237527980062   /atg/dynamo/service/IdGenerator ---     CONTAINER:atg.service.idgen.IdGeneratorException; SOURCE:java.sql.SQLException: atg.service.resourcepool.ResourcePoolException: java.sql.SQLException: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
**** Error      Thu Mar 19 23:46:20 CST 2009    1237527980062   /atg/dynamo/service/IdGenerator         at atg.service.idgen.SQLIdGenerator.getConnection(SQLIdGenerator.java:624)
**** Error      Thu Mar 19 23:46:20 CST 2009    1237527980062   /atg/dynamo/service/IdGenerator         at atg.service.idgen.SQLIdGenerator.initializeIdSpaces(SQLIdGenerator.java:810)
**** Error      Thu Mar 19 23:46:20 CST 2009    1237527980062   /atg/dynamo/service/IdGenerator         at atg.service.idgen.PersistentIdGenerator.initialize(PersistentIdGenerator.java:305)
**** Error      Thu Mar 19 23:46:20 CST 2009    1237527980062   /atg/dynamo/service/IdGenerator         at atg.service.idgen.AbstractSequentialIdGenerator.doStartService(AbstractSequentialIdGenerator.java:621)
**** Error      Thu Mar 19 23:46:20 CST 2009    1237527980062   /atg/dynamo/service/IdGenerator         at atg.nucleus.GenericService.startService(GenericService.java:495)
**** Error      Thu Mar 19 23:46:20 CST 2009    1237527980062   /atg/dynamo/service/IdGenerator         at atg.nucleus.NucleusNameResolver.startService(NucleusNameResolver.java:1229)
**** Error      Thu Mar 19 23:46:20 CST 2009    1237527980062   /atg/dynamo/service/IdGenerator         at atg.nucleus.NucleusNameResolver.configureAndStartService(NucleusNameResolver.java:1002)
**** Error      Thu Mar 19 23:46:20 CST 2009    1237527980062   /atg/dynamo/service/IdGenerator         at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:705)
**** Error      Thu Mar 19 23:46:20 CST 2009    1237527980062   /atg/dynamo/service/IdGenerator         at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:576)
**** Error      Thu Mar 19 23:46:20 CST 2009    1237527980062   /atg/dynamo/service/IdGenerator ....stack trace CROPPED after 10 lines.

Solution
     By default ATG adds Solid database driver to the classpath. But I changed the JTDatasource/FakeXA configurations to point to my oracle express and changed it to use the the Oracle JDBC Driver. So I had to add Oracle JDBC driver jar file ojdbc14.jar to classpath. So I edited the home/localconfig/postEnvironment.bat and added the path to ojdbc14.jar to the CLASSPATH environment variable and restarted the server to fix the issue.

ATG - Could not create log file

Problem
    Are you getting the following error when you start your dynamo server ?

Could not create log file: .\servers\devserver\logs\dynamo.log (The system cannot find the path specified)
java.io.FileNotFoundException: .\servers\devserver\logs\dynamo.log (The system cannot find the path specified)
        at java.io.FileOutputStream.openAppend(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:177)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
        at atg.core.io.SystemOutRecorder.pushLogFileImpl(SystemOutRecorder.java:152)
        at atg.core.io.SystemOutRecorder.pushLogFile(SystemOutRecorder.java:105)
        at atg.nucleus.Nucleus.startNucleusCheckLicense(Nucleus.java:3582)
        at atg.nucleus.Nucleus.startNucleus(Nucleus.java:3464)
        at atg.nucleus.Nucleus.main(Nucleus.java:3452)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at atg.applauncher.AppLauncher.launch(AppLauncher.java:795)
        at atg.applauncher.dynamo.DynamoServerLauncher.main(DynamoServerLauncher.java:305)
Dynamo exited abnormally.  For troubleshooting information go to the URL:
  http://www.atg.com/support
Press any key to continue . . .


Solution
    I have created a new dynamo server folder by name devserver and just added localconfig and put in some component overrides inside that folder. I had to create a logs folder inside devserver to fix the issue. Make sure you create the logs folder inside dynamo_home/servers/devserver. If not just go ahead and create the directory tree and bounce the server. The error should go away.

ATG - Unable to start service /atg/dynamo/service/j2ee/JarFileCache

Problem
    Are you getting the following error when you start your dynamo server ?

**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197078   /       Unable to start service "/atg/dynamo/service/j2ee/JarFileCache": atg.nucleus.ServiceException: Could not create directory servers\devserver\j2ee\runtime\jar-cache
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /       Unable to resolve component /atg/dynamo/service/j2ee/J2EEContainer      java.lang.NullPointerException
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /at atg.j2ee.service.jarcache.JarFileCachingService.getZipFileSystem(JarFileCachingService.java:172)
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /at atg.j2ee.configuration.ConfigVirtualFileOpener.createZipFileSystem(ConfigVirtualFileOpener.java:115)
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /at atg.vfs.VirtualFileOpenerImpl.getVFSFromFile(VirtualFileOpenerImpl.java:166)
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /at atg.vfs.VirtualFileOpenerImpl.openVirtualFileFromFile(VirtualFileOpenerImpl.java:185)
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /at atg.j2ee.configuration.ConfigurationImpl.getClassLoaderVirtualFileForFile(ConfigurationImpl.java:702)
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /at atg.j2ee.configuration.WebModuleConfigurationBuilder.createRootModuleClassLoader(WebModuleConfigurationBuilder.java:219)
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /at atg.j2ee.configuration.ModuleConfigurationBuilderImpl.setRootClassPathAndLoader(ModuleConfigurationBuilderImpl.java:437)
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /at atg.j2ee.configuration.ModuleConfigurationBuilderImpl.initializeModuleConfiguration(ModuleConfigurationBuilderImpl.java:414)
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /at atg.j2ee.configuration.ModuleConfigurationBuilderImpl.parseModule(ModuleConfigurationBuilderImpl.java:257)
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /       ....stack trace CROPPED after 10 lines.
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197187   /
**** Error      Thu Mar 19 23:49:57 CST 2009    1237528197296   /       Unable to set configured property "/atg/dynamo/service/Initial.initialServices" atg.nucleus.ConfigurationException: Unable to resolve component /atg/dynamo/service/j2ee/J2EEContainer

Solution
    I had created dynamo server folder by name devserver and just had localconfig folder and some contents in it nothing else. I had to create the required folder structure and it worked. Make sure you already have this directory structure under dynamo_home/servers/devserver - j2ee\runtime\jar-cache. If not just go ahead and create the directory tree and bounce the server. The error should go away.

ATG - runAssembler Document root element is missing

Problem
    Are you getting an error "Document root element is missing" while building an EAR or deploying an application ? I got that when I was bundling ATG modules using runassembler :)

CAUGHT AT:CONTAINER:atg.appassembly.ApplicationAssemblerException
Document root element is missing

Solution
    Guess which XML its trying to read, mine was application.xml inside the META-INF folder. Open it in an editor delete the first character and retype it usually it be the less than sign (<). Save the file and try redoing what you did more chance that it would work :)

JBoss - Shutdown script throws Security Exception

Problem
    Do you get this error when you try and shutdown the JBoss420EAP server using the shutdown script ?

D:\JBoss420EAP\jboss-as\bin>shutdown.bat -s jnp://localhost:1199
Exception in thread "main" java.lang.SecurityException: Failed to authenticate principal=admin, securityDomain=jmx-console
        at org.jboss.jmx.connector.invoker.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:97)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.invocation.jrmp.server.JRMPProxyFactory.invoke(JRMPProxyFactory.java:179)
Solution
1. Kill you currently runnin JBoss instance, ctrl+c or kill the java process whichever way you usually do.
2. Navigate to <<JBOSS_HOME>>\jboss-as\server\default\conf\props\jmx-console-users.properties
3. Uncomment the admin=admin line
4. Restart your JBoss server
5. Now try to shutdown using the following command.
shutdown.bat -s jnp://localhost:1199 -u=admin -p=admin

JBoss - Incomplete Deployment listing

Problem
    Are you getting the following error when you start your JBoss server

14:55:55,734 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

--- Packages waiting for a deployer ---
org.jboss.deployment.DeploymentInfo@e717061e { url=file:/D:/JBoss403SP1/server/test/deploy/test.ear/testapp/ }
  deployer: null
  status: Starting
  state: START_SUBDEPLOYMENTS
  watch: file:/D:/JBoss403SP1/server/test/deploy/test.ear/testapp/
  altDD: null
  lastDeployed: 1236372861437
  lastModified: 1236371083734
  mbeans:
Solution
    This is because JBoss tries to deploy everything that you drop in the deploy folder...if your EAR has some folders which are not understandable like in the above case i had a web app [testapp] which doesnt have .war in the folder name and it couldnt deploy it...

JBoss - Port Bind Error

Problem
    Are you getting a port bind error when starting a java process, like here is one I got when i started my JBoss.

16:19:06,578 ERROR [Http11Protocol] Error initializing endpoint
java.net.BindException: Address already in use: JVM_Bind:8080
        at org.apache.tomcat.util.net.PoolTcpEndpoint.initEndpoint(PoolTcpEndpoint.java:297)
        at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:142)
        at org.apache.catalina.connector.Connector.initialize(Connector.java:928)
        at org.jboss.web.tomcat.tc5.StandardService.initialize(StandardService.java:688)
        at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:764)


Solution
    There is some other process running in the same port 8080 in the above case. Stop/Kill the process if that isnt required or change the port of that process or for JBoss. In case you decide to change the JBoss port, navigate to your JBoss servers conf/jboss-service.xml and search for server bindings and uncomment that section and make it point to ports-01 [8180] / ports-02 [8280] / ports-03 [8380]. The default in there would be ports-default which is again 8080 so you have to change it to 01/02/03. This is the best way to change JBoss ports dont just search for 8080 and change it to something else.

MySQL - Changing root Password

Problem

The default password for root user in mysql is nothing. i.e no password is required for root user to login and I had to change it as PHPMyAdmin kept on complaining about it and it makes sense to change it too.

Solution

1. Open a new command prompt window and navigate to the mysql bin directory for me it was here - D:\WAMP\bin\mysql\mysql5.1.30\bin

2. Type mysql -u root to login as root, remember it doesnt need a password

3. When you are at the mysql prompt [mysql>] type the following, replace new_password to anything that you want to change it to and wait for update confirmation.
    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');

4. To test whether this has taken exit from the prompt and try to relogin using mysql -u root. System wouldnt allow now with no password, try to do mysql -u root -p and at the prompt provide your new password and it should let you in.

Linux - Finding the flavor

Problem
    Finding the flavor of Linux you are working on.

Solution
     Login to the machine and issue the following command at the prompt

     cat /etc/issue

Sample Results

[nseshadr@machine1 ~]$ cat /etc/issue
Red Hat Enterprise Linux AS release 4 (Nahant Update 6)

machine2:~ # cat /etc/issue
Welcome to openSUSE 10.3 (i586) - Kernel \r (\l).

Java - JUnit Partial Mocking using Mockito

I recently started writing a lot of JUnits as part of the development activities. Explored working with ATGDust, EasyMock and Mockito frameworks for various reasons. ATGDust for testing ATG Components, EasyMock and Mockito for writing JUnits using Mocking.

In this post, I am going to try and provide a sample to partially mock the objects (using Mockito) under test.

Need for partial Mocking - Most of the time when we write test classes to test the various methods in the class we use Mocks to make sure that the class/method is tested without much dependencies, assuming that the dependencies will be tested by their own test classes. Mocks are a great help for this situation and I think they are doing their job perfectly. But usually when you use mocks, you can only mock the dependent classes/interfaces and not really mock the class to be tested, because there is no point if you mock even class to be tested. Agreed. But there could be situations where there are too many dependencies for a particular method with other methods in the same class and you would run into a situation where you have to provide write a lot of test code before you could even invoke the method under test and see a Junit run. Partial mocking helps in situations like this, where it can mock some of the method invocations and return whatever responses you want to provide instead of executing the dependent method themselves but still allowing the real implementations to be called for the rest.


For example in the code below, MainClass has three methods - method1, method2 and method3. Assume method1 here is dependent on some external interface, you can mock that up and test method1, but if you have to test method2 and method3 you still have to do the same and also take care of other dependencies if method2 and method3 were dependent on some external interfaces. This is really time taking and tiring.

/**
 *
 */
package com.demo;

/**
 * @author Naga Seshadri
 *
 */
public class MainClass
{

  public String method1()
  {
    // some external invocations
    return "Main Class method1 called";
  }

  public String method2()
  {
    String method1Response = method1();
    return method1Response + ", Main Class method2 called";
  }

  public String method3()
  {
    String method2Response = method2();
    return method2Response + ", Main Class method3 called";
  }
}
To avoid the issue, Mockito provides a way in which you can invoke method2 for test without really calling method1's real implementation but fake it, also you can invoke method3 for test without really calling method1 and/or method2's real implementation, which is called partial mocking as illustrated by the code sample MainClassTest below

package com.demo;

import static org.mockito.Mockito.*;
import junit.framework.TestCase;

import org.junit.Test;

public class MainClassTest extends TestCase
{

  private MainClass mainClassObj;
  private MainClass mainClassSpy;

  @Override
  protected void setUp() throws Exception
  {
    super.setUp();
    mainClassObj = new MainClass();
    mainClassSpy = spy(mainClassObj);
  }

  @Test
  public void testMethod1()
  {
    System.out.println(mainClassSpy.method1());
  }

  @Test
  public void testMethod2()
  {
    doReturn("Main Class Spy method1 called").when(mainClassSpy).method1();
    System.out.println(mainClassSpy.method2());
  }

  @Test
  public void testMethod3()
  {
    doReturn("Main Class Spy method1 called").when(mainClassSpy).method1();
    System.out.println(mainClassSpy.method3());
  }
}


Here is the console output. In this case if you notice we spyed on the object on which we are calling the real methods and stubbed a couple of internal method calls which is very handy. Even though this is good we may not have a good way of doing this when you have private methods being invoked from within you public calls.

Main Class method1 called
Main Class Spy method1 called, Main Class method2 called
Main Class Spy method1 called, Main Class method2 called, Main Class method3 called