Search This Blog

Thursday, January 17, 2013

LS2J in Notes Form: cache or bug?

Hi guys

Do you know something about caching issues in LS2J technology?
I discovered a strange thing about it. Let me show you.
I work in IBM Notes 9 beta.

I have a database with Java library that contains a simple class with a single method

public class myTestClass {
public void someMethod() {
System.out.println("Test LS2J: 111");
}
}

I am going to use this Java class in a Notes Form and then in a Notes Agent.
Lotus script code is the same for both cases:

Option Declare
Uselsx "*javacon"
Use "TestJavaLib"

Dim js As New JavaSession
Dim myClass As JavaClass
Dim myObject As JavaObject

Set myClass = js.GetClass("myTestClass")
Set myObject = myClass.CreateObject

Call myObject.someMethod()

Let's test it for both form and agent:


It works from the Notes Agent

It works from the Notes Form


Now I will show you the issue.
Let's back to the Java library and change Class method to output something different to Java Console.


Save both myTestClass.java and TestJavaLib library.
Let's test our changes for both form and agent:

Notes Agent
Notes Form
Do you see?
Notes Form does not get the changes.

I tried everything I could: Build project, Recompile All Lotus Scripts, Clean project, rename Java Library, rename Java method, recreated Java class with the same name - nothing helped.

Only complete reopen of Lotus Notes worked for Notes Form.

Do you know how to force LS2J to see the changes in Notes Form?

You may check it yourself using my example: ypastov.ls2jIssue.nsf

14 comments:

  1. The same issue in 8.5.3

    ReplyDelete
  2. Did you close Notes Form after change Form in Designer?

    ReplyDelete
  3. Replies
    1. Hi
      i have the same problem
      how you solved the problem of me, please help me
      thank you (rguruz@yahoo.com)

      Delete
    2. Hi

      I didn't :-D
      It was the reason why I decided to make this post.
      I also hoped that someone else makes me a hint.

      Delete
    3. hi
      i did Lotus Client Version 8.5.3Fix1,Fix2,Fix3 the problem solved
      Current Version LotusClient (Lotus,Designer) 8.5.3FP3 there is no problem

      Delete
  4. Can you elaborate, on your Project Properties, especially those concerning the Packages, Libraries, and Build Properties ?
    Unless offcourse, you just accepted all the default setting as is.

    I'm asking, since:
    I have now moved to 8.5.3 FP3 today, and find myself having still less hair on my head due to a dreaded 'ExceptionClassNotFound' condition...
    Not much help on Internet on the LS2J interface to Java...

    ReplyDelete
    Replies
    1. >>Unless offcourse, you just accepted all the default setting as is.

      I use default settings.

      I would say that 'ExceptionClassNotFound' means that your lotusscript cannot find such Java class in your Java library.

      If you take my example , open form in Designer and change "LS2Java" button code from
      Set myClass = js.GetClass("myTestClass")
      to
      Set myClass = js.GetClass("myTestClass2")
      you will get a similar error:

      ---------------------------
      IBM Notes
      ---------------------------
      LS2J Error: Threw java.lang.ClassNotFoundException: myTestClass2
      ---------------------------
      OK
      ---------------------------

      Delete
  5. Forgot to mention around the NSF sample you link to.
    I download it to my Notes data folder.
    Open it and accepting the cross certificate, I get.
    Open the Form via the Create menu.
    Press the button.
    I receive 'Instance member SOMEMETHOD does not exist' from LN. It seems a problem to get JVM kicked in...
    I use LN 8.5.* and has set all Preferences to 'Enable Java...'
    So, even you are using a valid approach even within Notes 8.5, I cannot really reproduce you scenario.
    This is also why I ask for the possible settings you may have had for Libraries etc.

    ReplyDelete
    Replies
    1. Hello

      You are right.
      I got the same error.
      It seems that some time ago I made another one attempt to resolve this issue and I broke this sample. Sorry about that.

      I just updated it.
      You may download it again and try.
      Now the sample should work.

      Delete
  6. Hi, did you manage the situation? I have similar problem on 9.0.1 FP10 IF7.
    Thanks, Ciprian

    ReplyDelete
  7. I am getting ls2j error: Threw java.lang exception class not found
    can any body reslove it ?

    ReplyDelete
  8. We just ran into the same issue using Notes 10. Thank you for posting this so we know we were not losing our minds. We are painfully working around it now.

    ReplyDelete