Search the FirstSpirit Knowledge Base
Hallo zusammen,
ich versuche Testweise in einem Beanshell-Skript auf eine Klasse (CoreContextFactory) zuzugreifen die in einem jar liegt, welche als lib in einer Library-Komponente auf dem Server installiert ist.
// LDAP-Connection
Hashtable env = new Hashtable(6);
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.core.jndi.CoreContextFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:10389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=system administrator");
env.put(Context.SECURITY_CREDENTIALS, "admin");
DirContext ldap = new InitialDirContext(env);
dabei kommt es in der letzten Zeile zu einer ClassNotFoundException weil er die Factory-Klasse nicht findet. Habe ich eine falsche Vorstellung davon wie auf eine Library vom BeanShell-Skript aus zugegriffen werden kann?
Bin Dankbar für jeden Tipp,
Viele Grüße
Dominik
Fehler bei der Skriptausführung in Zeile 50.
FSVersion=5.0.210.55494#3070;JDK=1.7.0_15 64bit Oracle Corporation;OS=Windows 7 6.1 amd64;Date=21.03.2013 14:02:22
de.espirit.firstspirit.access.script.ExecutionException: Typed variable declaration : Object constructor : at Line: 50 : in file: inline evaluation of: ``__execute() { import javax.naming.NamingEnumeration; import javax.naming.Contex . . . '' : new InitialDirContext ( env )
Called from method: __execute
Target exception: javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.directory.server.core.jndi.CoreContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.directory.server.core.jndi.CoreContextFactory]
at line 50
at de.espirit.firstspirit.server.script.BeanshellScriptEngine$BeanshellExecutable.execute(BeanshellScriptEngine.java:108)
at de.espirit.firstspirit.client.gui.applications.ApplicationTabRegistry$IdentifiableExecutable.execute(ApplicationTabRegistry.java:129)
at de.espirit.firstspirit.common.ScriptUtil.execute(ScriptUtil.java:97)
at de.espirit.firstspirit.client.action.ScriptMenuAction$ScriptAction$1.run(ScriptMenuAction.java:218)
at de.espirit.firstspirit.client.gui.util.GuiUtil$RunnableWrapper.run(GuiUtil.java:1928)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.directory.server.core.jndi.CoreContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.directory.server.core.jndi.CoreContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at javax.naming.directory.InitialDirContext.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at bsh.Reflect.constructObject(Reflect.java:574)
at bsh.BSHAllocationExpression.constructObject(BSHAllocationExpression.java:125)
at bsh.BSHAllocationExpression.objectAllocation(BSHAllocationExpression.java:114)
at bsh.BSHAllocationExpression.eval(BSHAllocationExpression.java:62)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
at bsh.BSHVariableDeclarator.eval(BSHVariableDeclarator.java:86)
at bsh.BSHTypedVariableDeclaration.eval(BSHTypedVariableDeclaration.java:84)
at bsh.BSHBlock.evalBlock(BSHBlock.java:130)
at bsh.BSHBlock.eval(BSHBlock.java:80)
at bsh.BshMethod.invokeImpl(BshMethod.java:362)
at bsh.BshMethod.invoke(BshMethod.java:258)
at bsh.BshMethod.invoke(BshMethod.java:161)
at bsh.PreparsedScript.invoke(PreparsedScript.java:65)
at de.espirit.firstspirit.server.script.BeanshellScriptEngine$BeanshellExecutable.execute(BeanshellScriptEngine.java:99)
... 7 more
Caused by: java.lang.ClassNotFoundException: org.apache.directory.server.core.jndi.CoreContextFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 31 more
Was aber in Beanshell auch funktionieren soll ist folgendes:
instance = new org.apache.directory.server.core.jndi.CoreContextFactory();