0

Recently I've been trying to set and customize scheduler in our XPages project. I've tried to put the following snippet in our project:

import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator extends Plugin implements BundleActivator {

 @Override
    public void start(final BundleContext context) throws Exception {
       // Here you start your scheduler
    }

}

In the Code section of a template I can easily write this code I don't have a warning about unresolved dependencies. So, the org.eclipse.core.runtime and org.osgi.framework packages must be shipped with Domino I thought.

But it seems that it does not.

Whenever this code is executed I get 500 error in a browser and the stack as follows:

javax.servlet.ServletException: java.lang.NoClassDefFoundError: org.eclipse.core.runtime.Plugin
    at com.ibm.xsp.webapp.FacesServlet.handleError(FacesServlet.java:595)
    at com.ibm.xsp.webapp.FacesServlet.renderErrorPage(FacesServlet.java:424)
    at com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:182)
    at com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
    at com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
    at com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:588)
    at com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1335)
    at com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:865)
    at com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:808)
    at com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:577)
    at com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1319)
    at com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
    at com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
    at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:357)
    at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313)
    at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
Caused by: java.lang.NoClassDefFoundError: org.eclipse.core.runtime.Plugin
    at java.lang.ClassLoader.defineClassImpl(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:346)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:154)
    at com.ibm.domino.xsp.module.nsf.ModuleClassLoader$DynamicClassLoader.findClass(ModuleClassLoader.java:455)
    at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:850)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:829)
    at com.ibm.domino.xsp.module.nsf.ModuleClassLoader$DynamicClassLoader.loadClass(ModuleClassLoader.java:403)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:809)
    at ru.lanit.egrz.scheduler.RefreshEGRZTokenExecutor.executeAndScheduleRefreshToken(RefreshEGRZTokenExecutor.java:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at com.ibm.jscript.types.JavaAccessObject.call(JavaAccessObject.java:322)
    at com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
    at com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
    at com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
    at com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
    at com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
    at com.ibm.jscript.JSExpression.access$1(JSExpression.java:424)
    at com.ibm.jscript.JSExpression$2.run(JSExpression.java:414)
    at java.security.AccessController.doPrivileged(AccessController.java:686)
    at com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:410)
    at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
    at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
    at com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:222)
    at com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:111)
    at com.ibm.xsp.application.ActionListenerImpl.processAction(ActionListenerImpl.java:60)
    at javax.faces.component.UICommand.broadcast(UICommand.java:324)
    at com.ibm.xsp.component.UIEventHandler.broadcast(UIEventHandler.java:366)
    at com.ibm.xsp.component.UIDataPanelBase.broadcast(UIDataPanelBase.java:400)
    at com.ibm.xsp.component.UIViewRootEx.broadcast(UIViewRootEx.java:1535)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:307)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:428)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:94)
    at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:96)
    at com.ibm.xsp.controller.FacesControllerImpl.execute(FacesControllerImpl.java:256)
    at com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:227)
    at com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157)
    at com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:159)
    ... 13 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.Plugin
    at com.ibm.domino.xsp.module.nsf.ModuleClassLoader$DynamicClassLoader.loadClass(ModuleClassLoader.java:359)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:809)
    ... 54 more

IBM literally freaks me out over and over and over again (sorry for that).

I tried to add it as external jars in the section -> Still the same.

I even tried to add these two to lib/ext -> Still the same.

In the build path these two included as Plug-In Dependencies.

Literally, there's something wrong with importing jars and resolving dependencies in Domino (even beyond the scope of this particular problem) I believe.

This is my 3rd if not 4th question on IBM Domino. I sincerely apologize to the community for being that embarrassing but get me right please. In Domino you solve one problem and then the other two emerge. You solve these two and then the other 4 break the app down. And so on

How do I import it correctly without any problems?

Thanks in advance

UPD

To improve my question I'll add some code

So, the bean looks like this:

SchedulerActivatorBean:

import java.io.Serializable;

public class SchedulerActivatorBean implements Serializable  {

    /**
     * 
     */
    private static final long serialVersionUID = -3559937702716018697L;

    public static void activate() throws Exception 
    {
        new SchedulerActivator().start(null);
    }

}

SchedulerActivator (OSGI plugin):

import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;


public class SchedulerActivator extends Plugin implements BundleActivator {

     @Override
        public void start(final BundleContext context) throws Exception {
         // Here you start your scheduler
         QuartzScheduler.getInstance(); // starts the scheduler
        }

    }

Then I modified faces-config.xml as follows:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
  <managed-bean>
    <managed-bean-name>schedulerActivatorBean</managed-bean-name>
    <managed-bean-class>ru.lanit.egrz.scheduler.SchedulerActivatorBean</managed-bean-class>
    <managed-bean-scope>application</managed-bean-scope>
  </managed-bean>
</faces-config>

And finally I call the bean from SSJS:

 <xp:eventHandler event="onclick" submit="true"
    refreshMode="complete"
    action="#{javascript:schedulerActivatorBean.activate()}">
 </xp:eventHandler>

The bean is instantiated and available in the app. But when I call the method, I still get:

Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.Plugin
    at com.ibm.domino.xsp.module.nsf.ModuleClassLoader$DynamicClassLoader.loadClass(ModuleClassLoader.java:359)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:809)
    ... 54 more

Which, needless to say, left me clueless

Rus9Mus9
  • 160
  • 1
  • 17

1 Answers1

0

A plugin doesn’t live in the NSF. You might want to learn about that first. Use this as a starter: https://www.slideshare.net/fiorep/domino-osgi-development

You might want to revisit your whole approach. Why not use a Notes agent that is scheduled and refreshes token which you store in an NSF. Simple problem solved.

Then have your XPage lookup the values in the NSF. Saves you the whole headache.

For new users you can use agent.run from XPages. The trick is the storage in the NSF.

Use reader fields to secure documents, so users can’t see each other tokens.

stwissel
  • 20,110
  • 6
  • 54
  • 101
  • I wish I could import all the classes I've written in Code. But in Agent I can't simply do that.. https://stackoverflow.com/questions/43371591/how-to-include-self-created-java-files-in-java-agent I wouldn't have got my hands that dirty with Quartz then. The thing is that the classes are subject to change on SOOO many occasions. Even if I put them all in a jar, I'll have to recompile it all the time – Rus9Mus9 Dec 05 '19 at 10:39
  • Create a jar where the classes live. Dump it into lib/ext (the place where you find Notes.jar) and they are visible to any Java agent. Only catch: after an upgrade you need eventually copy it back – stwissel Dec 05 '19 at 10:49
  • Another option is to code your functionality as an XAgent, then trigger it via an external scheduler process or agent. If the NSF does not allow Anonymous access, your scheduler will need to authenticate. Also, unless you're generating a background thread, the call to the XAgent and the XAgent running will be synchronous not async. So it may be an issue for a long-running task. See https://www.youtube.com/watch?v=qn3TcefprOY&t=48s for running XAgents from Node-RED and using XOTS for background processing – Paul Stephen Withers Dec 05 '19 at 15:31