• Welcome to KonaKart Community Forum. Please login or sign up.
 

Custom Java Project with Konakart

Started by fallenangel321, February 14, 2012, 04:57:33 pm

Previous topic - Next topic

fallenangel321

Hello,
I am trying to integrate Konakart with a current web application.  Because Konakart has a struts framework, we cannot use the front end that comes with it.  Instead, we need to include the jar files and make the API calls to the back-end while keeping our current web application as the front-end.  I am having a bit of a rough time getting this started, Here is my setup and what I am trying to do:
I am working in Netbeans and added the jar files to the project and placed the properties file in my source package.  I am using Tomcat to deploy a war file that the project builds.  The issue is I get an error message from Konakart when trying to run the java api sample file for GetCustomer.java:

public class GetCustomer extends BaseApiExample
{
    private static final String usage = "Usage: GetCustomer\n" + COMMON_USAGE;

    /**
     * @param args
     */
    public static void main(String[] args)
    {
        parseArgs(args, usage, 0);

        try
        {
            /*
             * Get an instance of the KonaKart engine and login. The method called can be found in
             * BaseApiExample.java
             */
            EngineConfig engConf = new EngineConfig();
            engConf.setMode(getEngineMode());
            engConf.setStoreId(getStoreId());
            engConf.setCustomersShared(isCustomersShared());
            engConf.setProductsShared(isProductsShared());

            /*
             * Instantiate a KonaKart Engine
             */
            // You can load the class by name or instantiate it directly...
            // Class engineClass = Class.forName("com.konakart.app.KKEng");
            // eng = (KKEngIf) engineClass.newInstance();
            eng = new KKEng(engConf);

            MgrFactory mgrFactory = new MgrFactory(eng);
            CustomerMgrIf mgr = mgrFactory.getCustMgr(/* new */true);
            CustomerIf cust = mgr.getCustomerForEmail(getDEFAULT_USERNAME());

            if (cust == null)
            {
                System.out.println("Customer not found");
            } else
            {
                System.out.println(cust.toString());
            }

            System.out.println("Completed Successfully");

        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}


I have the BaseApiExample.java file in the project as well.  The error is thrown at:

eng = new KKEng(engConf)

with the exception being:

com.konakart.app.KKException: org.apache.torque.TorqueException: org.apache.commons.configuration.ConfigurationException: Cannot locate configuration source /C:/Development/Tomcat%207.0.23/lib/konakart.properties

I have no idea how it got that path to look for a properties file, I don't believe I ever set anything, just put the classes in my project and tried to run them. 

Any help would be greatly appreciated as I am stuck and frustrated at something that is probably very simple. 

Thanks, Please let me know if you need more information from me.

kate

QuoteI am trying to integrate Konakart with a current web application.  Because Konakart has a struts framework, we cannot use the front end that comes with it.  Instead, we need to include the jar files and make the API calls to the back-end while keeping our current web application as the front-end.


Yes this is a common approach.

I'm not sure what's wrong with your Netbeans set up and I don't actually recognise that exception.

One thing you could do is to install KonaKart on your system, move into the java_api_examples directory then run ANT on the build file that's there which should run that same API example:

Here is the first bit of what you should see:

C:\Program Files\KonaKart\java_api_examples>..\custom\bin\kkant
Buildfile: build.xml

clean:
     [echo] Cleanup...

generate.custom.schema:

compile:
     [echo] Compile the examples
    [mkdir] Created dir: C:\Program Files\KonaKart\java_api_examples\classes
    [javac] Compiling 34 source files to C:\Program Files\KonaKart\java_api_examples\classes
     [echo] Compile the admin custom engine
     [echo] Copy Properties for the examples
     [copy] Copying 1 file to C:\Program Files\KonaKart\java_api_examples\classes

compile_custom_schema:

run:
     [java] store:             store1
     [java] Engine Mode:       Single Store
     [java] Shared Customers?  false
     [java] Shared Products?   false
     [java] Shared Categories? false
     [java]
     [java]
     [java] **********************************************************************************
     [java] * KONAKART LICENSE AGREEMENT                                                     *
     [java] * You may not use this software except in compliance with the licenses.          *
     [java] * Please study the licenses on the KonaKart website  for the rights, obligations *
     [java] * and limitations governing the use of this software.                            *
     [java] * For users of the Community Edition of KonaKart see:                            *
     [java] *         http://www.konakart.com/documents/COMMUNITY-LICENSE.txt                *
     [java] * For users of the Enterprise Extensions of KonaKart see:                        *
     [java] *         http://www.konakart.com/documents/ENTERPRISE-LICENSE.txt               *
     [java] **********************************************************************************
     [java] KonaKart V6.1.0.0-E built 10:42AM 13-Feb-2012 GMT
     [java]
     [java] Order 328 inserted successfully
     [java] Order Inserted:
     [java] Order:
     [java] id = 328


Once you get that to work perhaps you could compare that with your Netbeans set-up ...  look at the build file to see what is on the classpath..  does that give you any clues?

I don't know what the problem is but I am suspicious of your tomcat location...  I wouldn't use one with spaces in the directory name.   That always used to be a problem so I would avoid that like the plague.



fallenangel321

Hey,
I just wanted to let you know that the issue was indeed the space in the tomcat folder name.  Things appear to work now.  I am just curious, since there is very little specific java documentation, what jar files are exactly needed?  I currently have:
konakart.jar,konakart_util.jar,konakartadmin.jar,konakart_village.jar,konakart_torque-3.3-RC1.jar

I also have the necessary database connector files. 

I am trying to setup a store-front that works with paypal, so a fairly simple setup.  I just want to make sure I don't miss anything.  If I should start a new thread for this, please let me know.

Thank you for your help, your advice about the space in the folder name was incredibly helpful.   

Thanks