Technote

(troubleshooting)
ClassNotFoundException when using WebSphere Commerce CommandFactory.createCommand()
Problem(Abstract)
You are unable to instantiate a WebSphere Commerce command using the CommandFactory, using Java™ code similar to the following:

SomeControllerCmd somecmd = (SomeControllerCmd) CommandFactory.createCommand("com.ibm.websphere.commerce.SomeControllerCmdImpl", getCommandContext().getStoreId());
Symptom [10/24/07 20:24:25:337 EDT] 00000040 CommerceSrvr E CommandManager createCommand CMN0110E: Cannot instantiate com.ibm.websphere.commerce.SomeControllerCmdI
for command com.ibm.websphere.commerce.SomeControllerCmdImpl.java.lang.
ClassNotFoundException: com.ibm.websphere.commerce.SomeControllerCmd
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:121)
at com.ibm.commerce.command.CommandFactory.createCommand(CommandFactory.java:241) Cause The problem is in the usage of the CommandFactory.createCommand() method. This method searches the command registry (CMDREG table) for an entry correspnding to the specified command (interface) name and store ID. If no entry is found for the specified store, it will look for an entry corresponding to storeID 0. If both fail, it will check for a default implementation of the command from the interface and returns an entry that represents the default implementation of the interface (ie. the defaultCommandClassName, usually a constant in the interface class). Resolving the problem When constructing a command with theCommandFactory class, pass in the interface name, rather than the implementation class, since the field looked up in the database is the CMDREG.INTERFACE field. Specifying the implementation class (for example SomeControllerCmdImpl) rather than the interface (SomeControllerCmd) may result in a ClassNotFoundException.
Cross Reference information
Segment Product Component Platform Version Edition
Commerce WebSphere Commerce Enterprise Development AIX, Linux, Solaris, Windows 5.6, 5.6.1, 6.0
Commerce WebSphere Commerce Business Edition Development AIX, Linux, Solaris, Windows 5.6, 5.6.1, 6.0
Commerce WebSphere Commerce Professional Development AIX, Linux, Solaris, Windows 5.6, 5.6.1, 6.0
Commerce WebSphere Commerce - Express Development AIX, Linux, Solaris, Windows 5.6, 5.6.1, 6.0
Commerce WebSphere Commerce Developer Enterprise Development AIX, Linux, Solaris, Windows 5.6, 5.6.1, 6.0
Commerce WebSphere Commerce Developer Business Edition Development AIX, Linux, Solaris, Windows 5.6, 5.6.1, 6.0
Commerce WebSphere Commerce Developer Professional Development AIX, Linux, Solaris, Windows 5.6, 5.6.1, 6.0
Commerce WebSphere Commerce Developer Express Development AIX, Linux, Solaris, Windows 5.6, 5.6.1, 6.0
   

Document Information

Current web document: http://www.ibm.com/support/docview.wss?uid=swg21285764