Re: Long Response Problems
Re: Long Response Problems
- Subject: Re: Long Response Problems
- From: Michael Engelhart <email@hidden>
- Date: Sun, 1 Aug 2004 18:53:49 -0500
I just ran into part of your error message today. From what I found
on the web you can't get the session context from within a
WOLongResponsePage. What I did was just create a setter in my
WOLongResponsePage like
public void setSession(Session session) {
this.session = session;
)
and pass it in from the calling page. That got rid of this error:
Session.context() evaluates to null.
You may be trying to get the context object from an archived session
object
I'm not sure if this is the root of your problem or not though but it's
worth getting rid of the first set of errors and it may fix your other
issue as well since the code is relying on the session.
Cheers
Mike
On Aug 1, 2004, at 6:41 PM, Greg Hulands wrote:
Hi,
I am trying to implement a long response page that processes images and
then generates a config file from a component to write to disk. The
config file can only be generated once all the images are processed.
When I try and do this I am getting the following exception:
2004-08-02 09:21:04,832 DEBUG ShoeBox[598:50212 7] NSLog
(ERXNSLogLog4jBridge.java:44) - Session.context() evaluates to null.
You may be trying to get the context object from an archived session
object. there is no context object outside of the request-response
loop.
2004-08-02 09:21:04,834 DEBUG ShoeBox[598:50212 7] NSLog
(ERXNSLogLog4jBridge.java:44) - Session.context() evaluates to null.
You may be trying to get the context object from an archived session
object. there is no context object outside of the request-response
loop.
2004-08-02 09:21:04,837 WARN ShoeBox[598:50212 7] NSLog
(ERXNSLogLog4jBridge.java:41) - <ConsumerProcessOrder> long response
thread raised : java.lang.IllegalArgumentException: <Application>:
Unable to create page 'ConsumerFotowireXMLGenerator'. No context was
passed.
2004-08-02 09:21:04,839 WARN ShoeBox[598:50212 7] NSLog
(ERXNSLogLog4jBridge.java:41) - STACK TRACE:
[2004-08-02 09:21:04 EST] <Thread-1>
java.lang.IllegalArgumentException: <Application>: Unable to create
page 'ConsumerFotowireXMLGenerator'. No context was passed.
at
com.webobjects.appserver.WOApplication.pageWithName(WOApplication.java:
1934)
at
com.webobjects.appserver.WOComponent.pageWithName(WOComponent.java:
1200)
at ConsumerProcessOrder.performAction(ConsumerProcessOrder.java:56)
at
com.webobjects.woextensions.WOLongResponsePage.run(WOLongResponsePage.j
a
va:155)
at java.lang.Thread.run(Thread.java:552)
From what I can tell is that I cannot generate the config file in the
perform Action method of the long response as it seems to be in a
seperate thread. Is there a way to get notified once the processing is
complete so that I can generate the config file in the main thread?
Any help is greatly appreciated.
Regards,
Greg
here is the performAction method.
public Object performAction() {
while (current < imgCount) {
processChunk();
}
Session s = ((Session)session());
//generate the xml
ConsumerFotowireXMLGenerator xml =
(ConsumerFotowireXMLGenerator)pageWithName("ConsumerFotowireXMLGenerato
r
");
xml.setImages(images);
WOResponse xmlData = xml.generateResponse();
String content = new String(xmlData.content().bytes());
try {
FileWriter file = new FileWriter(stagingFolder + "JOB_" +
s.onlineSale().saleID() + ".FWJ");
file.write(content);
file.close();
} catch (IOException e) {
System.out.println(e);
}
// Generate the pdf job sheet
FOPOnlineJobSheet pdf =
(FOPOnlineJobSheet)pageWithName("FOPOnlineJobSheet");
pdf.setFotowireData(s.tempArray());
WOResponse fop = pdf.generateResponse();
NSData pdfData = new NSData(fop.content().bytes());
// Write to temp dir, print it, delete it.
String pdfFile = "/tmp/" +
generator.generateRandomBasedUUID().toString() + ".pdf";
File f = new File(pdfFile);
try {
FileOutputStream fos = new FileOutputStream(pdfFile);
pdfData.writeToStream(fos);
} catch (IOException e) {
System.out.println("Failed to write pdf job sheet to " + pdfFile);
}
String printerQueue =
((Application)application()).preferenceForKey("ShoeBoxPrinterQueue").va
l
ue();
try {
Process pr = Runtime.getRuntime().exec("open " + pdfFile);
//Process pr = Runtime.getRuntime().exec(printerQueue + " " +
pdfFile);
pr.waitFor();
//pr = Runtime.getRuntime().exec("rm " + pdfFile);
//pr.waitFor();
}
catch (Exception e)
{
System.out.println("Error printing file: " + pdfFile + "\n" + e);
}
s.setOnlineSale(null);
isProcessing = false;
return null;
}
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.