Skip to end of metadata
Go to start of metadata

Description

When the Loftware Universal Connector is in use with the Java API option, a common troubleshooting step is to run the included sample application.  This is also a good way to test your installation to make sure it is installed correctly.

 If you plan on using Eclipse IDE and want to run the sample applications from Eclipse, see Configuring Eclipse to Run Loftware Universal Connector Basic Samples

How to Run the Sample Applications

Construct the Path to All Necessary Files and Folders

There are three main components to the sample application that need to reference in the command line.  Make sure you know the locations of these files before starting.  When you know the locations, create a java classpath.

  • Configuration folder

    • See Universal Connector Installation Guide for configuration documentation
    • Contains jcfda_config.xml, log4j.properties, LPSConnector.properties
    • Default location: C:\Program Files\Loftware Labeling\Connector\ucfiledrop\conf
  • The log4j jar file

    • Used internally; an exception will be thrown if not included
    • Default location: C:\Program Files\Loftware Labeling\Connector\ucfiledrop\conf
  • The lwconnv2.jar fileEach item in the list is separated with a semicolon ";"

    • Main classes for the connector
    • Default location: C:\Program Files\Loftware Labeling\Connector\java\redist\lwconnv2.jar
  • If there are spaces in the path to a file, the entire path needs to be enclosed in double quotation marks.

For default locations, the path is as follows:

"C:\Program Files\Loftware Labeling\Connector\ucfiledrop\conf";"C:\Program Files\Loftware Labeling\Connector\java\redist\log4j-1.2.16.jar";"C:\Program Files\Loftware Labeling\Connector\java\redist\lwconnv2.jar"

Construct the Command

Once you have located all of the necessary files, you can format your command.  Each bullet below is a portion of the command that you will need to run

  • java: the executable needed to run the samples. (short for java.exe).

  • -cp: a java.exe switch.  java.exe will use the following paths and files to look for executable code.

  • <paths>: The paths/files needed to run the job.  The basic sample; com.loftware.basicSamples.LPSPrintControllerSample: is one of the basic Loftware supplied samples.

    • The path that we will need is "C:\Program Files\Loftware Labeling\Connector\ucfiledrop\conf";"C:\Program Files\Loftware Labeling\Connector\ucfiledrop\conf";"C:\Program Files\Loftware Labeling\Connector\java\redist\lwconnv2.jar"
  • /PRINTERNAME=<PRINTERNAME>: This tells the program to use the printer with the specified printername.

  • /LWL=<LABEL_FILE.LWL>: This tells the program to use the specified label file.

  • /COUNT=1: This tells the program to use the specified count.

When put together, the command (without specific values) is as follows:

java -cp <paths> com.loftware.basicSamples.LPSPrintControllerSample /PRINTERNAME=<PRINTERNAME> /LWL=<LABEL_FILE.LWL> /COUNT=1

The Complete Command

Using default locations, the entire command is as follows:

java -cp "C:\Program Files\Loftware Labeling\Connector\ucfiledrop\conf";"C:\Program Files\Loftware Labeling\Connector\java\redist\log4j-1.2.16.jar";"C:\Program Files\Loftware Labeling\Connector\java\redist\lwconnv2.jar" com.loftware.basicSamples.LPSPrintControllerSample /PRINTERNAME=<PRINTERNAME> /LWL=<LABEL_FILE.LWL> /COUNT=1

Run the Command

  1. Open a Command Prompt.

  2. Navigate to your Universal Connector conf directory.

  3. Run the command that you created above.

    1. Default location: C:\Program Files\Loftware Labeling\Connector\ucfiledrop\conf

Exceptions and Errors

There are three exceptions that you will commonly receive when the command is not properly formatted.  The three errors are all caused by an incorrect java classpath.

Missing or incorrect conf directory in the classpath

When you do not specify your conf directory in the classpath, you receive warnings with an exception that cause the sample to fail.  Log4j can not initialize, so you see log4j:WARN messages.  Also, parameters in the LPSConnector.properties file can not be read.  This throws a NullPointerException and causes execution to halt.  To avoid this, make sure the conf directory is present and correct in the classpath.

Missing or incorrect log4j.jar file in the classpath

If the path to the log4j.jar is missing or incorrect, an exception is thrown.  The specific text to look for is "java.lang.NoClassDefFoundError: org/apache/log4j/Logger". Ensure that the correct log4j jar file is specified in the classpath to avoid this error.

Missing or incorrect lwconnv2.jar file in the classpath.  Incorrect class name being called.

This same exception is thrown for several reasons.  The root cause is that the java class that it was told to run can not be found.  The most common reason for this is that the path to the lwconnv2.jar file is missing or incorrect.  To avoid this, ensure that the path to lwconnv2.jar is correct in the java classpath.

This exception also appears if the class that is being called is spelled incorrectly or does not exist.  Ensure that the spelling of the class (case sensitive) is correct and that it is a valid class.

Article Number

2014030

Versions

Universal Connector 4.0.3

Environment

 All supported environments