0
votes

I want to create a log for all my webservices. I have the log in java, it works. I want to do the same thing in Lotus Domino using the java's class I do with LS2J class.

It works to compil my java class and the ls2j code. When i try to call this java in lotus it works ! But i have a null value when i call it in java with the getter !

Class GetAllDocuments

Private logDTO As LogWSDTO
Private objectJavaA As JAVAOBJECT   
Private a  As LogWebService
Private db As NotesDatabase

Public Sub New()                
    Set logDTO = New LogWSDTO() 
        Set a = New LogWebService()     
    Set objectJavaA = a.getJavaObject   
End Sub

Public Function GetAllDocuments()
    call logDTO.setNomBaseNotesWS(db.FileName)           
    objectJavaA.setLog(logDTO.getJavaObject())  
End Function 

I have a class in lotus which called my java class :

UseLSX "*javacon" 

Class LogWSDTO
sessionJava As JAVASESSION      
classJava As JAVACLASS
objectJava As JAVAOBJECT        
methodJava As JAVAMETHOD    

Public Sub New()
    Set sessionJava = New JAVASESSION
    Set classJava = sessionJava.GetClass("com.pasquier.DTO.WS/LogWSDTO")
    Set objectJava = classJava.CreateObject     
End Sub

Public Function getNomBaseNotesWS()
    Set methodJava = classJava.GetMethod("getNomBaseNotesWS","()Ljava/lang/String;")
    getNomBaseNotesWS = objectJava.getNomBaseNotesWS()      
End Function

Public Sub setNomBaseNotesWS(nomBaseNotesWS As String)      
    Set methodJava = classJava.GetMethod("setNomBaseNotesWS","(Ljava/lang/String;)V")
    objectJava.setNomBaseNotesWS(nomBaseNotesWS)        
End Sub

In java : I can't have to have a session, this is always null

public void setLog(LogWSDTO log) {
    System.out.println("entrée java");      
    System.out.println(log.getNomBaseNotesWS()); <== I Have the data !!
    this.logDTO = log;  
            if (session == null)
    {

        System.out.println("alert !");              
        session =  session.getSession(); <== it doesn't compil i pass it in comment to test         
        System.out.println("alert !");
    }       
    System.out.println("Session :" + session );     
}

the result is :

"entrée java"
"GetAllDocuments"
"alert!"
"alert!"
Session :"null

UPDATE 2 :

I modify my code, I take with an agent the token of my session LotusScript, I put in myLogBean. In java, I try to create a new session :

public void setLog(LogWSDTO log) {
        this.logDTO = log;  
        String sessionParam = logDTO.getSessionParam();             

        if (session == null)
        {               
            try {

                session = lotus.domino.NotesFactory.createSession("myhost",sessionParam);


            } catch (NotesException e) {
                // TODO Bloc catch auto-généré
                e.printStackTrace();
            }
            System.out.println("alert !");
        }

        System.out.println("Session :" + session );     
    }

And the result is :

NotesException: Could not get IOR from Domino Server: http://myhost/diiop_ior.txt at lotus.domino.NotesFactory.requestIORPlain(Unknown Source) at lotus.domino.NotesFactory.requestIORUsingArgs(Unknown Source) at lotus.domino.NotesFactory.getIOR(Unknown Source) at lotus.domino.NotesFactory.createSessionC(Unknown Source) at lotus.domino.NotesFactory.createSession(Unknown Source) at com.pasquier.launcher.LogWebService.setLog(LogWebService.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:611) at lotus.domino.JavaConnectInvoker.invoke(Unknown Source) at sun.reflect.GeneratedMethodAccessor3780.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:611)

I try to change some point in config of the server :

In the Server document, I go to the Internet Protocols tab, then the DIIOP tab. I specify the Internet host name for the server in the Host name/Address field. I go to the Internet Protocols tab, HTTP tab, and R5 Basics tab. Then I set the "Allow HTTP clients to browse databases" field to Yes.

I add the task DIIOP and it is'nt the same error :

 NotesException: Invalid user name/password

But I put the token ? what I do wrong ?

An idea ?

1
change logDTO.setDateHeureDebutWS(dt) to call logDTO.setDateHeureDebutWS(dt)user784540
does it compile lotusscript when you add call directive as I mentioned in previous comment?user784540
i try "call logDTO.setDateHeureDebutWS(dt)" but i have this error : 108: Not a member SETDATEHEUREDEBUTWSsissi49
add lotusscript code that shows how did you declare and initialize logDTOuser784540
variable logDTO refers to an instance of class LogWSDTO and there's only one method setDateHeureDebutWS(dateHeureDebut As String) As you can see it takes a string parameter, and you are trying to pass a NotesDateTime parameter value.user784540

1 Answers

0
votes

I won't be able to answer your exact issue as I think there is more information required to do so. At a guess it looks like you didn't create the session object before calling it.

I can cover two points though.

You mention WebServices and LS2J. Do you mean SOAP web services are in your Java code? If so then your code will never work as LotusScript uses a reserved object in relation to WebServices. This reserved object prevents LS2J from working correctly.

If this is the case the only solution is to go full Java.

The other point is in relation to your logging. It seems overkill to create a logging mechanism in Java. You could accomplish the same thing in LotusScript. It even has it's own logging mechanism called NotesLog