我有从lotusscript代理调用java代理的代码
Sub insertDealDetails()
On Error GoTo errhandler
MsgBox "inside deal details"
Dim agent As NotesAgent
On Error GoTo errhandler
Set agent = db.GetAgent("Procs")
If agent.RunOnServer(doc.Noteid) = 0 Then
MessageBox "Agent ran",, "Success"
Else
MessageBox "Agent did not run",, "Failure"
End If
Exit Sub
errhandler:
MsgBox "Error in function insertDealDetails in agtSubmit Agent" & Erl & Error
End Sub
现在,如果Procs
代理中发生任何异常,那么调用insertDealDetails()
的主代理如何提供异常,以便它停止主代理。
答案 0 :(得分:3)
使用In-Memory Document,
在Java代理中将您的错误消息写入此文档中
阅读LotusScript代码中的错误消息。
的LotusScript
Call agent.RunWithDocumentContext(doc)
If doc.ErrorMessage(0) <> "" Then
print doc.ErrorMessage(0)
' handle the error
End If
Java代理
Document doc = agentContext.getDocumentContext();
...
doc.replaceItemValue("ErrorMessage", "Your Error Message from Java Agent");
您无需随时保存In-Memory文档。
答案 1 :(得分:0)
它是更新的代码
`Sub insertDealDetails()
On Error GoTo errhandler
MsgBox "inside deal details"
Dim agent As NotesAgent
Dim in_doc As Notesdocument
On Error GoTo errhandler
Set agent = db.GetAgent("Procs")
Set in_doc = db.createDocument()
If agent.Runwithdocumentcontext(in_doc,doc.Noteid) Then`
MsgBox "doc.ErrorMessage(0):::::::::"&in_doc.ErrorMessage(0)
If in_doc.ErrorMessage(0)<>"" Then
Call prompt("2")
End If
End If
Exit Sub
errhandler:
MsgBox "Error in function insertDealDetails in agtSubmit Agent" & Erl & Error
End Sub
现在的问题是它没有从Procs
agent中调用的java代码返回。我将在这里做错。
public class JavaAgent extends AgentBase {
public void NotesMain() {
Connection con = null;
CallableStatement stmt = null;
Database db;
lotus.domino.Document doc = null;
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
doc = agentContext.getDocumentContext();
con = JavaAgent.getConnection(); //making connectiion here
//executing code here and exception occurs
System.out.println("success");
} catch(Exception e) {
try {
doc.replaceItemValue("ErrorMessage", e.getMessage());
} catch (NotesException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}finally{
try {
stmt.close();
con.close();
} catch (SQLException e) {
try {
doc.replaceItemValue("ErrorMessage", e.getMessage());
} catch (NotesException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
}
}
相同的日志如下:
**[0DCC:01AD-053C] 01/27/2016 01:24:56 PM HTTP JVM: class load: JavaAgent from: <unknown>
[0DCC:04B2-199C] 01/27/2016 01:24:56 PM HTTP JVM: before connection:::::
[0DCC:04B2-199C] 01/27/2016 01:24:56 PM HTTP JVM: inside dobi
[0DCC:04B2-199C] 01/27/2016 01:24:56 PM HTTP JVM: inside dobi 2
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: inside dobi 3
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: after connection:::::Oracle Database 11g Release 11.1.0.0.0 - Production
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: message is Invalid column index
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: java.sql.SQLException: Invalid column index
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: at oracle.jdbc.driver.OraclePreparedStatement.setStringInternal(OraclePreparedStatement.java:4596)
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: at oracle.jdbc.driver.OracleCallableStatement.setString(OracleCallableStatement.java:4249)
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: at JavaAgent.NotesMain(Unknown Source)
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: at lotus.domino.AgentBase.runNotes(Unknown Source)
[0DCC:04B2-199C] 01/27/2016 01:25:28 PM HTTP JVM: at lotus.domino.NotesThread.run(Unknown Source)
[0DF8:000A-0F84] Router: DNS server returned an error searching for MX records. The destination domain may not exist: 11.17.108.223, Error: Not implemented(NOTIMP)**
答案 2 :(得分:0)
具有相同步骤的工作代码如下:
%REM
Sub insertDetailsOracle
Description: To insert details in Oracle Table
Date: 28/03/2014
'******************* Logic ***************************
'Validation In submit agent
'1)Create in-memory document
'2)Run java agent with Runwithdocumentcontext passing newly created in-memory document
' as well as note-id of original request document context
'If pass i.e. no exceptions in Java agent
'1) submit the Case
'Else
'1) Log Error message and exit the agent
'***************************************************
%END REM
Function insertDetailsOracle() As String
On Error GoTo errhandler
Dim agent As NotesAgent
Dim agentValue As Boolean
Set agent = db.GetAgent("Procs")
'Create in-memory document
Set in_doc = db.createDocument()
'Running java agent with Runwithdocumentcontext
agentValue = agent.Runwithdocumentcontext(in_doc,doc.Noteid)
'Return error message as per message passed by java agent in in-memory document's field
If in_doc.ErrorMessage(0)<>"" Then
insertDealDetails = in_doc.ErrorMessage(0)
Else
insertDealDetails = "1"
End If
Exit Function
errhandler:
MsgBox "Error in function insertDealDetailsOracle in agtSubmit Agent" & Erl & Error
End Function
java方法将如下所示。