Using Zebra's jpos sdk in Spring boot application

// Expert user has replied.
G George Biryukov 3 years 7 months ago
407 1 0

The application returns an error:
jpos.JposException: Service does not exist in loaded JCL registryI'm writing a Java application that should work with Zebra bar code scanners. The application itself is written on the Spring boot in conjunction with Java FX. For testing at start, I'm trying to get a list of connected devices: In the main method, I run the Java FX launcher. After that, in the start Java FX method, I run Spring. Then I'm trying to get a list of devices:
Scanner scannerObj = new Scanner(); String defaultLogicalName = "ZebraScannerUSB"; scannerObj.open(defaultLogicalName);After this line, the exception is thrown. I understand that this is due to the fact that the program can not find jpos.xml. But I put it in src/main/resources, and in src/main/resources/jpos/res, and in the code I wrote the path to the external file:
System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, "C:"+File.separator + "Program Files" + File.separator + "Zebra Technologies" + File.separator + "Barcode Scanners" + File.separator + "Scanner SDK" + File.separator + "JPOS" + File.separator + "Sample Applications" + File.separator + "bin" + File.separator + "jpos.xml");In the project, I also specified in the "project properties" in the build path the path to the native device drivers. What could be the problem? Maybe I missed something when configuring jpos?

Please Register or Login to post a reply

1 Replies

R Riad Benallou

Hello George,

From Jpos driver developer guide i can see under chapter 5 following

https://www.zebra.com/content/dam/zebra_new_ia/en-us/manuals/software/J…
Through the DirectIO feature a POS application communicates directly with the underlying CoreScanner Service. This method provides a means for a UnifiedPOS Service to provide functionality to the application that is not otherwise supported by UnifiedPOS control for its device category.

basically one application will be able to communicate with multiple scanners , each scanner will have unique scanner id

From manual

The DirectIO Method
The Zebra JPOS driver allows direct RSM attribute GET/SET access in order to leverage features not
otherwise able to be exposed through the JPOS API Specification.
The JPOS DirectIO method has the following prototype (as of Zebra JPOS driver 1.0):

directIO ( command: int32, inout data: int32, inout obj: object ):
void { raises-exception }

DirectIO Method Arguments
For the purposes of the Zebra scanner device class, the DirectIO method arguments are defined as:

command: int32: The command is passed to the CoreScanner service which is responsible for
communicating with the scanner. This command is defined in the JposService.jar.

inout data: int32: For Zebra devices, this is used to identify the device/scanner instance ID. In the case
where one device is attached, this value is typically ‘1’.

inout obj: object: This is an object type because this argument type varies depending on the DirectIO
context. Following is a list of the expected object types and their usage contexts.

• DirectIODeviceData - Used when performing a GET_SCANNERS DirectIO command,
see DirectIOCommand definition above.
• DirectIOData - Used when performing all other DirectIO commands besides
GET_SCANNERS (see DirectIOCommand on page 5-2)

DirectIO Java Package The necessary classes to perform DirectIO are contained in the JposService.jar file under the two namespaces:
• com.motorola.jpos.service
• com.motorola.jpos.service.directio
The package com.motorola.jpos.service contains the DirectIO method, while the package com.motorola.jpos.service.directio contains the supporting classes to leverage the DirectIO method.

com.motorola.jpos.service.directio The directio package contains the following supporting classes:
• DirectIOCommand
• DirectIOData
• DirectIODeviceData
• DirectIOStatus

DirectIOCommand
public class DirectIOCommand {
public static final int GET_SCANNERS = 1; // get scanners list
public static final int RSM_ATTR_GETALL = 0x1388; // Opcode 5000
public static final int RSM_ATTR_GET = 0x1389; // Opcode 5001
public static final int RSM_ATTR_GETNEXT = 0x138A; // Opcode 5002
public static final int RSM_ATTR_SET = 0x138C; // Opcode 5004 public static final int RSM_ATTR_STORE = 0x138D; // Opcode 5005 }

GET_SCANNERS: This command must be used first when setting up DirectIO. It returns an array of scanner IDs used in all other DirectIO calls. See the sample code in Using DirectIO on page 5-6 for how this is used.

Under same manual page36 there is code example that demonstrates how to use DirectIO with scanner JPOS control.

Hope it helps .
Riad

CONTACT
Can’t find what you’re looking for?