Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help executing java from ASP

Status
Not open for further replies.

rtgordon

Programmer
Jan 17, 2001
104
US
I am trying to do run a java app from an ASP page. I had success with the sample apps on 4Guys and webmonkey. What I am attempting now is to start do an MQSeries put, and return a message.

The MQ Message gets put, but nothing gets returned. Any thoughts??

Here is the code... quite simple actually:

ASP Code:

<%

set javaObject = GetObject(&quot;java:javaput&quot;)
strResult = javaObject.start()
Response.Write(&quot;Result: &quot; & strResult)
set javaObject = nothing

%>

Java Code:

import com.ibm.mq.*;

public class javaput
{
public static void main(String[] args)
{
//do nothing
}
private String hostname = &quot;XXX&quot;;
private String channel = &quot;YYY&quot;;
private int port = 999;
private String qManager = &quot;XXX&quot;;
private MQQueueManager qMgr;

public void init()
{
MQEnvironment.hostname = hostname;
MQEnvironment.channel = channel;
MQEnvironment.port = port;
}

public String start()
{
try
{
qMgr = new MQQueueManager(qManager);

int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_OUTPUT;

MQQueue system_default_local_queue =
qMgr.accessQueue(&quot;PIPInput&quot;,openOptions);

MQMessage hello_world = new MQMessage();

hello_world.writeUTF(&quot;Yo&quot;);

MQPutMessageOptions pmo = new MQPutMessageOptions();

system_default_local_queue.put(hello_world,pmo);

system_default_local_queue.close();

qMgr.disconnect();

}

catch (MQException ex)
{
return &quot;An MQSeries Error Occurred : Completion Code &quot; + ex.completionCode + &quot; Reason Code &quot; + ex.reasonCode;

}

catch (java.io.IOException ex)
{
return &quot;An Error occurred while trying to write to the message buffer: &quot; + ex;

}

return &quot;Finised&quot;;

}

}


 
I don't know how good asp is at reporting java exceptions. You might try running your java class from a command-line java client and see what happens. You might also try commenting out all or various parts of your try block and see if you can isolate where there might be a problem. Of course the problem might be in the message queue service which might be more difficult to isolate.

--Will Duty
wduty@radicalfringe.com

 
It runs fine from the command line. Could the java class be cached?

gordon
 
Possibly, but I don't see how that would affect it's returning a value unless you mean an earlier version of the class file. You might try playing with it (commenting out parts, maybe catching just Exception, etc.).

Since you think it might be cached could try registering it again with a different class name. I seem to remember having to do that (it's been over six months since I setup a java-based component for use from asp).
--Will Duty
wduty@radicalfringe.com

 
Good Call! I re-registered, and it are gud B-)

Thanks,
Gordon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top