plantuml / plantuml-server

PlantUML Online Server
https://plantuml.com/
GNU General Public License v3.0
1.67k stars 477 forks source link

Add JLatexMath support in Docker image #116

Closed ttobsen closed 1 year ago

ttobsen commented 5 years ago

The Jetty Docker image does not support JLatexMath and therefore the tags are not working.

Would it be possible to add JLatexMath support? I'm no Java expert, but I can help with the Dockerfile. I just have to know where the JAR files from the Zip archive needs to be placed.

shizhaojingszj commented 4 years ago

the documentation says the jar files are large, so they need to be downloaded seperated and put into the same folder as plantuml.jar file. So I'm thinking maybe you can download the jar files and mount them to the right folder.

ttobsen commented 4 years ago

The image has a size of over 400MB, I think the 3.7MB of the JLatexMath extension shouldn't be any problem.

I can't find any plantuml.jar in the Docker image, therefore I don't know where I should mount the JLatexMath files. Any ideas?

shizhaojingszj commented 4 years ago

Sorry, I just read the instructions, don't know what to do with it. And in docker image, there is a plantuml.war file in tomcat folder, I guess this is the 'plantuml.jar' file.... But, no definitive information I can give you.

ttobsen commented 4 years ago

If I remeber correctly, I already tried this without success. :-(

tphani commented 4 years ago

I believe the instructions you are referring to are for a standalone setup. For docker setup it is packaged as war and deployed into jetty/tomcat. We can either add JLatex libs as dependencies to pom.xml or keeps them in WEB-INT/lib and build the docker image. Not sure if any other easy options available.

ttobsen commented 4 years ago

Hi @tphani, does this mean that extracting the JLatexMath files into /var/lib/jetty/lib should be enough to get this working? If copying the JLatexMath to this place and restart the container, I get the same error message as before:

plantuml         | java.lang.ClassNotFoundException: org.scilab.forge.jlatexmath.TeXFormula
plantuml         |      at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
plantuml         |      at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
plantuml         |      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
plantuml         |      at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
plantuml         |      at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:555)
plantuml         |      at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
plantuml         |      at java.lang.Class.forName0(Native Method)
plantuml         |      at java.lang.Class.forName(Class.java:264)
plantuml         |      at net.sourceforge.plantuml.math.TeXIconBuilder.<init>(TeXIconBuilder.java:53)
plantuml         |      at net.sourceforge.plantuml.math.LatexBuilder.buildIcon(LatexBuilder.java:66)
plantuml         |      at net.sourceforge.plantuml.math.LatexBuilder.getImage(LatexBuilder.java:82)
plantuml         |      at net.sourceforge.plantuml.math.AsciiMath.getImage(AsciiMath.java:106)
plantuml         |      at net.sourceforge.plantuml.math.ScientificEquationSafe.getImage(ScientificEquationSafe.java:113)
plantuml         |      at net.sourceforge.plantuml.creole.AtomMath.drawU(AtomMath.java:102)
plantuml         |      at net.sourceforge.plantuml.creole.SheetBlock1.drawU(SheetBlock1.java:174)
plantuml         |      at net.sourceforge.plantuml.creole.SheetBlock2.drawU(SheetBlock2.java:82)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox.drawU(FtileBox.java:251)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.UGraphicInterceptorUDrawable2.draw(UGraphicInterceptorUDrawable2.java:67)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple.drawU(FtileAssemblySimple.java:113)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.FtileWithConnection.drawU(FtileWithConnection.java:72)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.UGraphicInterceptorUDrawable2.draw(UGraphicInterceptorUDrawable2.java:67)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.FtileMargedVertically.drawU(FtileMargedVertically.java:58)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.UGraphicInterceptorUDrawable2.draw(UGraphicInterceptorUDrawable2.java:67)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple.drawU(FtileAssemblySimple.java:112)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.FtileWithConnection.drawU(FtileWithConnection.java:72)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.UGraphicInterceptorUDrawable2.draw(UGraphicInterceptorUDrawable2.java:67)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.FtileMargedVertically.drawU(FtileMargedVertically.java:58)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.UGraphicInterceptorUDrawable2.draw(UGraphicInterceptorUDrawable2.java:67)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple.drawU(FtileAssemblySimple.java:112)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.FtileWithConnection.drawU(FtileWithConnection.java:72)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.UGraphicInterceptorUDrawable2.draw(UGraphicInterceptorUDrawable2.java:67)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.FtileMargedVertically.drawU(FtileMargedVertically.java:58)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.UGraphicInterceptorUDrawable2.draw(UGraphicInterceptorUDrawable2.java:67)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple.drawU(FtileAssemblySimple.java:112)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.FtileWithConnection.drawU(FtileWithConnection.java:72)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.TextBlockInterceptorUDrawable.drawU(TextBlockInterceptorUDrawable.java:56)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ftile.SwimlanesA.drawU(SwimlanesA.java:198)
plantuml         |      at net.sourceforge.plantuml.ugraphic.comp.TextBlockCompressedOnXorY.drawU(TextBlockCompressedOnXorY.java:61)
plantuml         |      at net.sourceforge.plantuml.ugraphic.comp.TextBlockCompressedOnXorY.drawU(TextBlockCompressedOnXorY.java:61)
plantuml         |      at net.sourceforge.plantuml.graphic.TextBlockRecentred.drawU(TextBlockRecentred.java:56)
plantuml         |      at net.sourceforge.plantuml.ugraphic.ImageBuilder.writeImageInternal(ImageBuilder.java:259)
plantuml         |      at net.sourceforge.plantuml.ugraphic.ImageBuilder.writeImageTOBEMOVED(ImageBuilder.java:180)
plantuml         |      at net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3.exportDiagramInternal(ActivityDiagram3.java:224)
plantuml         |      at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:201)
plantuml         |      at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:135)
plantuml         |      at net.sourceforge.plantuml.servlet.DiagramResponse.sendDiagram(DiagramResponse.java:112)
plantuml         |      at net.sourceforge.plantuml.servlet.UmlDiagramService.doDiagramResponse(UmlDiagramService.java:101)
plantuml         |      at net.sourceforge.plantuml.servlet.UmlDiagramService.doGet(UmlDiagramService.java:68)
plantuml         |      at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
plantuml         |      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
plantuml         |      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
plantuml         |      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1623)
plantuml         |      at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:214)
plantuml         |      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
plantuml         |      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
plantuml         |      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
plantuml         |      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
plantuml         |      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
plantuml         |      at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
plantuml         |      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1700)
plantuml         |      at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
plantuml         |      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
plantuml         |      at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
plantuml         |      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
plantuml         |      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1667)
plantuml         |      at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
plantuml         |      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
plantuml         |      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
plantuml         |      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:220)
plantuml         |      at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:152)
plantuml         |      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
plantuml         |      at org.eclipse.jetty.server.Server.handle(Server.java:505)
plantuml         |      at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370)
plantuml         |      at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267)
plantuml         |      at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
plantuml         |      at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
plantuml         |      at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
plantuml         |      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:698)
plantuml         |      at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:804)
plantuml         |      at java.lang.Thread.run(Thread.java:748)
plantuml         | formula=I(x, y) = I(x, y) // 2^n
plantuml         | Latex={I}{\left({x},{y}\right)}={I}{\left({x},{y}\right)}/{2}^{{n}}

So there must be another place for copying the files?

tphani commented 4 years ago

Sorry, if I was not clear. As plant uml is running inside Jetty as a webapp (war file), there is no way of copying the jars into it. We need to build the war with the dependent jars and for that the docker file needs to be modified accordingly. I will try to do this and share in couple of days.

ttobsen commented 4 years ago

Alright, thanks. I'm a total noob with this whole Jetty stuff. If you need any help for testing let me know. :smiley:

tphani commented 4 years ago

As we cannot add the libs directly to Jetty, I have added them as dependencies to pom.xml as below in the dependencies section:

    <dependency>
        <groupId>org.scilab.forge</groupId>
        <artifactId>jlatexmath</artifactId>
        <version>1.0.7</version>
    </dependency>
    <dependency>
        <groupId>org.scilab.forge</groupId>
        <artifactId>jlatexmath-font-greek</artifactId>
        <version>1.0.7</version>
    </dependency>
    <dependency>
        <groupId>org.scilab.forge</groupId>
        <artifactId>jlatexmath-font-cyrillic</artifactId>
        <version>1.0.7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.xmlgraphics</groupId>
    <artifactId>batik-all</artifactId>
    <version>1.12</version>
    </dependency>

Now build the docker image: docker build -t plantumlwithmath .

And run it: docker run --rm -d -p 8080:8080 --name pu plantumlwithmath

This works well for me, not sure if there is any simple way of doing it.

Thanks!

ttobsen commented 4 years ago

Hi @tphani, I just tested it, and it works perfectly. I will create a PR and hope that the changes are finding its way into the repo very soon.

TimSoethout commented 4 years ago

I would love to have this feature. Any progress on merging this?

tphani commented 4 years ago

Sorry it took so long, but I managed to get the alternate way of copying the jar files into the container working fine. Till the changes make it to the official repo, we can do this:

  1. Start and stop the container docker run -p 8080:8080 --name puml plantuml/plantuml-server:tomcat
  2. Download the jar files from site and unzip (say ~/downloads/jlatex)
  3. Copy the jar files to the container docker cp ~/downloads/jlatex/. puml:/usr/local/tomcat/webapps/ROOT/WEB-INF/lib Where ~/downloads/jlatex - is the folder containing the jar files. Also note the "." at the end puml - is the container name
  4. Start the container back docker container start puml

We will loose the changes if we remove the container, but we can run latest version of puml without building it.

ttobsen commented 4 years ago

And for the jetty image, use /var/lib/jetty/lib/ext instead of /usr/local/tomcat/webapps/ROOT/WEB-INF/lib :-)