David, all,

I'd like to clarify that this issue is not strictly related to OFBiz and service calls. It is an issue probably caused by my ignorance on the usage of the javax.print API:

http://java.sun.com/j2se/1.4.2/docs/api/javax/print/package-summary.html

In that service I've just tried to implement what is described at the bottom of that page; to that, I've added the code to search for a printer by its URI. Unfortunately, this is really the first time I play with this java api and I'm not even sure if the approach I've followed is correct. Even if this is a bit off topic in this list, if you could provide suggestions on how to locate a lan printer (by printer name/address) using the javax.printer api, I promise I will fix that service.

David, if it is simpler for you, you could try to implement a simple Java class (following the pattern used in the above link) and try to print a file with it; once you understand how this can be done I'll move the code to the OFBiz service. A second option could be to try to post this question ("How do I locate and print to a lan printer using javax.print api?") to one of the many Java forums in the Internet

Jacopo

David Shere wrote:
I have tried this, and have had no luck. I'm using this in WorkWithShipmentPlans.bsh:

//----------
Map screenInMap = UtilMisc.toMap("orderId", "WS10000");
String printerName = "LaserJet-2420";
Map inMap = UtilMisc.toMap("screenLocation",
"component://order/widget/ordermgr/OrderPrintForms.xml#ShipGroupsPDF",
"printerName", printerName,
"userLogin", userLogin,
"screenContext", screenInMap);

dispatcher.runAsync("sendPrintFromScreen", inMap);
//------------

and I've modified this line in PrintServices.java:

//------------
String errMsg = "The following printer was not found: [" + printerUriObj.toString() + "].";
//------------

and I've verified that I can print to this printer from Linux:

//------------
[EMAIL PROTECTED]:~$ lpstat -dP
system default destination: LaserJet-2420
[EMAIL PROTECTED]:~$ lpr -P LaserJet-2420 planes
//------------

and I get this error message in the OfBiz Log:

//------------

2007-03-21 16:25:25,617 (default-invoker-Thread-2) [ PrintServices.java:159:ERROR] The following printer was not found: [LaserJet-2420]. 2007-03-21 16:25:25,618 (default-invoker-Thread-2) [ ServiceDispatcher.java:415:ERROR] Service Error [sendPrintFromScreen]: The following printer was not found: [LaserJet-2420]. 2007-03-21 16:25:25,618 (default-invoker-Thread-2) [ TransactionUtil.java:252:ERROR] ---- exception report ----------------------------------------------------------
[TransactionUtil.rollback]
Exception: java.lang.Exception
Message: Stack Trace
---- stack trace ---------------------------------------------------------------
java.lang.Exception: Stack Trace
org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:251) org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:233)
org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:419)
org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:211)
org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:136)
org.ofbiz.service.job.GenericServiceJob.exec(GenericServiceJob.java:70)
org.ofbiz.service.job.JobInvoker.run(JobInvoker.java:221)
java.lang.Thread.run(Thread.java:595)
--------------------------------------------------------------------------------

2007-03-21 16:25:25,620 (default-invoker-Thread-2) [ TransactionUtil.java:262:INFO ] [TransactionUtil.rollback] transaction rolled back 2007-03-21 16:25:25,621 (default-invoker-Thread-2) [ ServiceDispatcher.java:459:DEBUG] [[Sync service finished- total:1.922,since last(Begin):1.923]] - 'JobDispatcher / sendPrintFromScreen' 2007-03-21 16:25:25,621 (default-invoker-Thread-2) [ GenericServiceJob.java:117:ERROR] ---- exception report ----------------------------------------------------------
Async-Service failed.
Exception: java.lang.Exception
Message: The following printer was not found: [LaserJet-2420].
---- stack trace ---------------------------------------------------------------
java.lang.Exception: The following printer was not found: [LaserJet-2420].
org.ofbiz.service.job.GenericServiceJob.exec(GenericServiceJob.java:76)
org.ofbiz.service.job.JobInvoker.run(JobInvoker.java:221)
java.lang.Thread.run(Thread.java:595)
--------------------------------------------------------------------------------
//-----------

Thoughts?


Jacopo Cappellato wrote:
Yes, literally millions of examples.

However, this morning I've committed a first draft of the service in svn so I'd suggest you to update your local copy with a clean trunk and then you can test it, for example, in this way:

//============================
Map screenInMap = UtilMisc.toMap("orderId", orderId);
Map inMap = UtilMisc.toMap("screenLocation",
"component://order/widget/ordermgr/OrderPrintForms.xml#OrderPDF",
"printerName", "//server/printer",
"userLogin", userLogin,
"screenContext", screenInMap);

dispatcher.runAsync("sendPrintFromScreen", inMap);
//============================

A quick way to run this code is to copy it at the bottom of a bsh script, for example: applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.bsh

then you'll submit the service call every time you'll visit the page:

https://localhost:8443/manufacturing/control/WorkWithShipmentPlans

You can edit the bsh script without the need to build and restart the server.

Jacopo


Scott Gray wrote:
I think it's a LocalDispatcher, but don't quote me on that. Anyway there's
a million examples in code, just search for runSync


On 20/03/07, David Shere <[EMAIL PROTECTED]> wrote:

Thanks!  That's the line I was missing.  I must ask, though, what class
is "dispatcher" and how do I construct it?

(I think I was dealing with ServiceXaWrapper)

Scott Gray wrote:
> Map results = dispatcher.runSync("myService", inputMap);








Reply via email to