skynav / ttt

Timed Text Toolkit
BSD 2-Clause "Simplified" License
74 stars 15 forks source link

Build failure on macOS #285

Closed llamafilm closed 3 years ago

llamafilm commented 3 years ago

The build instructions for ttpe say to use ant build but this gives an error

Buildfile: build.xml does not exist!

I figured out the project uses maven instead, so I ran mvn clean install and got an error about Too many open files in system. My Mac running Big Sur has maxfiles at 10000 by default, so I fixed it with

sudo launchctl limit maxfiles 20000

Then the build succeeds, but I cannot run it:

 % java -jar ttt-ttpe/target/ttt-ttpe-7.1-SNAPSHOT.jar 
no main manifest attribute, in ttt-ttpe/target/ttt-ttpe-7.1-SNAPSHOT.jar

So I tried extracting the JAR and running it this way.

% java com.skynav.ttpe.app.Version
7.1-SNAPSHOT
% java com.skynav.ttpe.app.Presenter
Error: Could not find or load main class com.skynav.ttpe.app.Presenter

I don't know Java code at all, but I think maybe it can't find the TimedTextTransformer class because I don't see this in the JAR.

The versions I'm using:

% java -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

% mvn -version 
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 1.8.0_282, vendor: Oracle Corporation, runtime: /usr/local/Cellar/openjdk@8/1.8.0+282/libexec/openjdk.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "11.1", arch: "x86_64", family: "mac"
llamafilm commented 3 years ago

I found that running ttt-ttpe-all gets a little further on the dependency issue. Then it throws an exception:

% java -jar ~/.m2/repository/com/skynav/ttt/ttt-ttpe-all/7.1-SNAPSHOT/ttt-ttpe-all-7.1-SNAPSHOT.jar --font ttt-ttpe/src/test/fonts/NotoSans.xml ~/Downloads/Netflix_sub.xml
Timed Text Presentation Engine (TTPE) [7.1-SNAPSHOT] Copyright 2014-19 Skynav, Inc.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.apache.fontbox.ttf.advanced.AdvancedTypographicTable.<clinit>(AdvancedTypographicTable.java:51)
    at org.apache.fontbox.ttf.OTFParser.readTable(OTFParser.java:106)
    at org.apache.fontbox.ttf.TTFParser.readTableDirectory(TTFParser.java:280)
    at org.apache.fontbox.ttf.TTFParser.parse(TTFParser.java:129)
    at org.apache.fontbox.ttf.OTFParser.parse(OTFParser.java:83)
    at org.apache.fontbox.ttf.OTFParser.parse(OTFParser.java:31)
    at org.apache.fontbox.ttf.TTFParser.parse(TTFParser.java:84)
    at org.apache.fontbox.ttf.OTFParser.parse(OTFParser.java:71)
    at com.skynav.ttpe.fonts.FontState.maybeLoad(FontState.java:410)
    at com.skynav.ttpe.fonts.FontState.getGlyphMapping(FontState.java:178)
    at com.skynav.ttpe.fonts.Font.getGlyphMapping(Font.java:209)
    at com.skynav.ttpe.layout.LineLayout$TextRun.getAdvance(LineLayout.java:1142)
    at com.skynav.ttpe.layout.LineLayout$TextRun.getAdvance(LineLayout.java:1131)
    at com.skynav.ttpe.layout.LineLayout.getNextBreakOpportunity(LineLayout.java:332)
    at com.skynav.ttpe.layout.LineLayout.layout(LineLayout.java:184)
    at com.skynav.ttpe.layout.ParagraphLayout.layout(ParagraphLayout.java:50)
    at com.skynav.ttpe.layout.ParagraphLayout.layout(ParagraphLayout.java:46)
    at com.skynav.ttpe.layout.BasicLayoutProcessor.layoutParagraph(BasicLayoutProcessor.java:551)
    at com.skynav.ttpe.layout.BasicLayoutProcessor.layoutParagraphs(BasicLayoutProcessor.java:543)
    at com.skynav.ttpe.layout.BasicLayoutProcessor.layoutParagraph(BasicLayoutProcessor.java:534)
    at com.skynav.ttpe.layout.BasicLayoutProcessor.layoutDivision(BasicLayoutProcessor.java:520)
    at com.skynav.ttpe.layout.BasicLayoutProcessor.layoutBody(BasicLayoutProcessor.java:503)
    at com.skynav.ttpe.layout.BasicLayoutProcessor.layoutRegion(BasicLayoutProcessor.java:484)
    at com.skynav.ttpe.layout.BasicLayoutProcessor.layoutISDInstance(BasicLayoutProcessor.java:441)
    at com.skynav.ttpe.layout.BasicLayoutProcessor.layout(BasicLayoutProcessor.java:366)
    at com.skynav.ttpe.app.Presenter.performPresentation(Presenter.java:645)
    at com.skynav.ttpe.app.Presenter.processResult(Presenter.java:353)
    at com.skynav.ttv.app.TimedTextVerifier.verify(TimedTextVerifier.java:2238)
    at com.skynav.ttv.app.TimedTextVerifier.verify(TimedTextVerifier.java:2363)
    at com.skynav.ttv.app.TimedTextVerifier.run(TimedTextVerifier.java:2440)
    at com.skynav.ttv.app.TimedTextVerifier.run(TimedTextVerifier.java:2406)
    at com.skynav.ttx.app.TimedTextTransformer.run(TimedTextTransformer.java:535)
    at com.skynav.ttx.app.TimedTextTransformer.run(TimedTextTransformer.java:531)
    at com.skynav.ttpe.app.Presenter.main(Presenter.java:224)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    ... 34 more

I managed to make it work by downloading commons-logging-1.2.jar from here and copying it to the jars folder. I'm sure there must be a better way to build this app. It would be great to document it for Java novices like myself.

% mvn -DskipTests clean package
% find . -name "*.jar" -exec cp {} jars \;
% java -cp "jars/*" com.skynav.ttpe.app.Presenter --font ttt-ttpe/src/test/fonts/NotoSans.xml ~/Downloads/Netflix_sub.xml 
skynavga commented 3 years ago

Thanks, I will update the documentation for TTPE. The problem you are facing is that you failed to follow the instructions at https://github.com/skynav/ttt before attempting to build the subordinate ttt-ttpe project. [The same applies to the ttt-ttv project.] N.B. that this software is intended to be built and used by someone with intermediate to advanced knowledge of Java and Maven.