Zimbra extension adding lib

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Dinamots
Posts: 10
Joined: Wed May 29, 2019 8:03 am

Zimbra extension adding lib

Postby Dinamots » Wed Jun 05, 2019 1:33 pm

Hi,

With my extension I need to do a connection with a postgresql database.

When i'm running in local the Driver can find my lib but when zimbra try to connect I have this error :

[java.net.URLClassLoader.findClass(URLClassLoader.java:381), java.lang.ClassLoader.loadClass(ClassLoader.java:424), java.lang.ClassLoader.loadClass(ClassLoader.java:357), java.lang.Class.forName0(Native Method), java.lang.Class.forName(Class.java:264), com.objectifpi.tasks.services.Connection.init(Connection.java:16), com.objectifpi.tasks.TasksExtension.init(TasksExtension.java:12), com.zimbra.cs.extension.ExtensionUtil.initAllMatching(ExtensionUtil.java:126), com.zimbra.cs.extension.ExtensionUtil.initAll(ExtensionUtil.java:152), com.zimbra.cs.util.Zimbra.startup(Zimbra.java:267), com.zimbra.cs.util.Zimbra.startup(Zimbra.java:180), com.zimbra.soap.SoapServlet.init(SoapServlet.java:126), javax.servlet.GenericServlet.init(GenericServlet.java:244), org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:626), org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:405), org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:875), org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:346), org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1380), org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342), org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772), org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259), org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:518), org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68), org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132), org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114), org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61), org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161), org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68), org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132), org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114), org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61), org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68), org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132), org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106), org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61), org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68), org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132), org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106), org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61), org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:212), org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68), org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132), org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106), org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61), org.eclipse.jetty.server.handler.DebugHandler.doStart(DebugHandler.java:143), org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68), org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132), org.eclipse.jetty.server.Server.start(Server.java:405), org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106), org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61), org.eclipse.jetty.server.Server.doStart(Server.java:372), org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68), org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1510), java.security.AccessController.doPrivileged(Native Method), org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1435), sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62), sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.lang.reflect.Method.invoke(Method.java:498), org.eclipse.jetty.start.Main.invokeMain(Main.java:214), org.eclipse.jetty.start.Main.start(Main.java:457), org.eclipse.jetty.start.Main.main(Main.java:75)]

But how can make zimbra load the lib ?
Or how can I import an external lib in zimbra ?
Can I add my lib in the jetty classpath ?


Dinamots
Posts: 10
Joined: Wed May 29, 2019 8:03 am

Re: Zimbra extension adding lib

Postby Dinamots » Wed Jun 05, 2019 1:44 pm

Ok so, I found that the jetty server available libs are in /opt/zimbra/jetty/common/lib
So if you want to add a new jar file this is the destination
User avatar
msquadrat
Advanced member
Advanced member
Posts: 183
Joined: Mon Oct 14, 2013 10:09 am

Re: Zimbra extension adding lib

Postby msquadrat » Wed Jun 05, 2019 2:05 pm

The proper way is to just put the 3rd party jar next to your extension jar in the extensions folder. Each extension gets its own classloader so they don't step on each other toes.

Maybe the code of our recently open sourced extension here https://github.com/silpion/zimbra-crowd-extension helps to understand.
Dinamots
Posts: 10
Joined: Wed May 29, 2019 8:03 am

Re: Zimbra extension adding lib

Postby Dinamots » Wed Jun 05, 2019 2:33 pm

Ok I see, I have a zimlet who use my server ext, so in /opt/zimbra/lib/myextfolder I put my libs next to my zimlet jar !
Thx for your help

Return to “Developers”

Who is online

Users browsing this forum: No registered users and 3 guests