public class Jni4netAuthenticator {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
System.out.println("classpath="+System.getProperty("java.classpath"));
Bridge.setVerbose(true);
Bridge.init();
File proxyAssemblyFile = new File("SharpAuthenticator.j4n.dll");
Bridge.LoadAndRegisterAssemblyFrom(proxyAssemblyFile);
sharpauthenticator.Authenticator auth = new sharpauthenticator.Authenticator();
boolean result = auth.Authenticate(args[0], args[1]);
if (!result) {
System.err.println("Not valid.");
} else {
System.out.println("Valid!");
}
}
}
When I run this as a Java application, using "user pass" as arguments, I get this in the console:
classpath=null
core loaded from C:/Users/Eric/workspace/jni4net/com.my.widget/jni4net.n-0.8.6.0.dll
clr.version :v4.0.30319
clr.arch :32bit
java.home :C:\Lotus\Notes6\jvm
java.version :1.6.0
sun.arch.data.model :32
loading SharpAuthenticator.j4n, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null from C:\Users\Eric\workspace\jni4net\com.my.widget\SharpAuthenticator.j4n.dll
loaded SharpAuthenticator.j4n, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null from C:\Users\Eric\workspace\jni4net\com.my.widget\SharpAuthenticator.j4n.dll
Valid!
So all compiles and runs correctly. Now I would like to call the DLL from within the Notes plugin. I am getting an error
java.lang.NoClassDefFoundError: net.sf.jni4net.Bridge
when I call Jni4netAuthenticator from another method that is invoked from a menu command:
public class Command1Handler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
String[] up = {"user","pass"};
try {
Jni4netAuthenticator.main(up);
} catch (IOException e) {
System.err.println("Bridge IOException.");
e.printStackTrace();
}
}
}
It seems to be unable to find the jar file jni4net.j-0.8.6.0.jar. It may have something to do with static methods. I do not know.
Here is the console log when the Lotus Notes menu item is selected:
Platform: 'Generic Web Application Server'
classpath=null
2014/09/03 00:58:00.440 SEVERE CLPDN0031E: Event loop exception ::class.method=com.ibm.rcp.personality.framework.internal.RCPWorkbenchAdvisor.eventLoopException() ::thread=main ::loggername=com.ibm.rcp.personality.framework.internal
java.lang.NoClassDefFoundError: net.sf.jni4net.Bridge
at com.my.widget.Jni4netAuthenticator.main(Jni4netAuthenticator.java:17)
at com.my.widget.Command1Handler.execute(Command1Handler.java:48)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:281)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:247)
at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:619)
at org.eclipse.ui.menus.CommandContributionItem.access$10(CommandContributionItem.java:605)
at org.eclipse.ui.menus.CommandContributionItem$4.handleEvent(CommandContributionItem.java:595)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4166)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3755)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.ibm.rcp.personality.framework.internal.RCPApplication.run(RCPApplication.java:67)
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 org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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 org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Caused by: java.lang.ClassNotFoundException: net.sf.jni4net.Bridge
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:483)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:399)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:387)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87)
at java.lang.ClassLoader.loadClass(ClassLoader.java:638)
... 40 more
Anyone know how to configure this correctly? ;-)
Thanks in advance!
-Eric
Two hints to check
- dlls in current directory of the process
- classloader and classpath
--
--
You received this message because you are subscribed to jni...@googlegroups.com
http://groups.google.com/group/jni4net?hl=en-GB?hl=en-GB
http://jni4net.sf.net/
---
You received this message because you are subscribed to the Google Groups "jni4net" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jni4net+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.