By: Sylvain BONNEFON user 29 Mar 2021 at 4:58 a.m. CDT

4 Responses
Sylvain BONNEFON gravatar
Hello we would like to make a Multipart post request to our verification server with data from a custom oxauth page form . To do so we tried to use from `org.apache.http.entity.mime import MultipartEntityBuilder` to build the request but it doesn't seems to find the `mime` module. So we tried to add apache jar files in '/opt/gluu/jetty/oxauth/custom/libs' folder. But it does'nt seems to change anything. ``` 2021-03-29 06:31:00,834 ERROR [oxAuthScheduler_Worker-5] [org.gluu.service.custom.script.CustomScriptManager] (CustomScriptManager.java:352) - Failed to destroy custom script '9298.6844' correctly 2021-03-29 06:31:00,931 ERROR [oxAuthScheduler_Worker-5] [org.gluu.service.PythonService] (PythonService.java:186) - Failed to load python file org.python.core.PyException: ImportError: No module named mime at org.python.core.Py.ImportError(Py.java:329) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.core.imp.import_logic(imp.java:1290) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.core.imp.import_module_level(imp.java:1369) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.core.imp.importName(imp.java:1528) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.core.ImportFunction.__call__(__builtin__.java:1285) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.core.PyObject.__call__(PyObject.java:433) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.core.__builtin__.__import__(__builtin__.java:1232) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.core.imp.importFromAs(imp.java:1620) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.core.imp.importFrom(imp.java:1595) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.pycode._pyx10.f$0(whispeak.py:31) ~[?:?] at org.python.pycode._pyx10.call_function(whispeak.py) ~[?:?] at org.python.core.PyTableCode.call(PyTableCode.java:173) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.core.PyCode.call(PyCode.java:18) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.core.Py.runCode(Py.java:1687) ~[jython-standalone-2.7.2.jar:2.7.2] at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:297) ~[jython-standalone-2.7.2.jar:2.7.2] at org.gluu.service.PythonService.loadPythonScript(PythonService.java:184) [oxcore-script-4.2.3.Final.jar:?] at org.gluu.service.PythonService$Proxy$_$$_WeldClientProxy.loadPythonScript(Unknown Source) [oxcore-script-4.2.3.Final.jar:?] at org.gluu.service.custom.script.CustomScriptManager.createExternalTypeFromStringWithPythonException(CustomScriptManager.java:417) [oxcore-script-4.2.3.Final.jar:?] at org.gluu.service.custom.script.CustomScriptManager$Proxy$_$$_WeldSubclass.createExternalTypeFromStringWithPythonException(Unknown Source) [oxcore-script-4.2.3.Final.jar:?] at org.gluu.service.custom.script.CustomScriptManager.createExternalType(CustomScriptManager.java:385) [oxcore-script-4.2.3.Final.jar:?] at org.gluu.service.custom.script.CustomScriptManager.reloadCustomScriptConfigurations(CustomScriptManager.java:293) [oxcore-script-4.2.3.Final.jar:?] at org.gluu.service.custom.script.CustomScriptManager.reloadImpl(CustomScriptManager.java:182) [oxcore-script-4.2.3.Final.jar:?] at org.gluu.service.custom.script.CustomScriptManager.reload(CustomScriptManager.java:152) [oxcore-script-4.2.3.Final.jar:?] at org.gluu.service.custom.script.CustomScriptManager.reloadTimerEvent(CustomScriptManager.java:128) [oxcore-script-4.2.3.Final.jar:?] at org.gluu.service.custom.script.CustomScriptManager$Proxy$_$$_WeldSubclass.reloadTimerEvent(Unknown Source) [oxcore-script-4.2.3.Final.jar:?] at jdk.internal.reflect.GeneratedMethodAccessor126.invoke(Unknown Source) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?] at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:85) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.jboss.weld.injection.MethodInvocationStrategy$SimpleMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:168) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at javax.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:124) [jakarta.enterprise.cdi-api-2.0.2.jar:?] at org.jboss.weld.util.Observers.notify(Observers.java:166) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:177) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:159) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:632) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.jboss.weld.util.ForwardingBeanManager.fireEvent(ForwardingBeanManager.java:104) [weld-core-impl-3.1.4.Final.jar:3.1.4.Final] at org.gluu.service.timer.TimerJob.execute(TimerJob.java:37) [oxcore-timer-weld-4.2.3.Final.jar:?] at org.gluu.service.timer.JobExecutionDelegate.execute(JobExecutionDelegate.java:31) [oxcore-timer-weld-4.2.3.Final.jar:?] at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-2.3.2.jar:?] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [quartz-2.3.2.jar:?] ``` So we don't know if we do it the good way or if something else is needed to import module in Jetty. So at this point we have 2 questions to solve our issue: - How to import this MultipartEntityBuilder class in our script ? - Do you know any other alternative to post a multipart request from a custom script ? Thanks for your help Best regards SB

By Madhumita Subramaniam staff 04 Apr 2021 at 10:42 a.m. CDT

Madhumita Subramaniam gravatar
Hi, I hope this helps you. Place the jar in the location mentioned in the docs. https://www.gluu.org/docs/gluu-server/4.2/authn-guide/customauthn/#adding-libraries

By Sylvain BONNEFON user 06 Apr 2021 at 12:09 p.m. CDT

Sylvain BONNEFON gravatar
Hi Madhumita. Thank for ypur answer I tried to put the jars in /opt/gluu/jetty/oxauth/lib/ext and also in /opt/gluu/jetty/oxauth/custom/libs, and /opt/gluu/jetty/oxauth/custom/libs/ext but I guess some steps are missing to make it work because I always have the same error. (I also set the read and execution right to this folders and jar files)

By Madhumita Subramaniam staff 06 Apr 2021 at 10:47 p.m. CDT

Madhumita Subramaniam gravatar
Hi Sylvian, Please take a look at this example: https://gluu.org/docs/gluu-server/4.2/authn-guide/sms-otp/#add-twilio-library-to-oxauth where the twilio library is being added to oxauth and used in the custom script. There were two missing steps - Step 1. Edit /opt/gluu/jetty/oxauth/webapps/oxauth.xml and add the following line: ``` <Set name="extraClasspath">/opt/gluu/jetty/oxauth/custom/libs/your-jar.jar</Set> ``` Step 2. Restart oxauth Thanks for catching this. I will update the previously shared link to reflect this more correctly. Regards Madhu

By Sylvain BONNEFON user 07 Apr 2021 at 2:54 p.m. CDT

Sylvain BONNEFON gravatar
Thanks a lot Madhumita, It is much better with this extra explaination ! Best regards SB