[컴][웹] Highchart export-server 사용 해 보기

highchart 에서 image file 만들기 / chart 를 image 로 / 이미지로 highchart 를 /





windows 에서 phantomjs 를 이용하는 highchart export-server 를 설치해 보자.[ref. 1]

Prerequisite

  1. Tomcat 이 설치되어 있어야 한다.



PhantomJS 설치

위 경로에서 windows 버전을 다운로드 하자. 그리고 특정 폴더에 압축을 풀어놓자. 여기서는 아래 경로에 풀어놓았다.
  • c:\Program Files\phantomjs\phantomjs-1.9.7-windows\



highcharts-export-web.war 만들기

아래 링크에서 export-server folder 내용을 가져온다.




app-convert.properties 

app-convert.properties 를 수정하자. 아래 경로에서 찾을 수 있다.

  • /exporting-server/java/highcharts-export/highcharts-export-web/src/main/webapp/WEB-INF/spring/app-convert.properties


이 설정파일에서 phantomjs 가 listen 할 "ip 주소/port" 를 정해주고, 실행파일의 경로(path) 를 지정해 주자. 이 밖에도 phantomjs 서버 pool의 사이즈등을 정할 수 있다. 나머지 부분은 특별히 수정할 이유는 없을 것이다. 자세한 사항은 설정파일안의 comment 를 확인하자.


#### phantomjs properties ####

# the host and port phantomjs listens to
host = 127.0.0.1
port = 7777

# location of the phantomjs executable, could be for example /usr/local/bin/phantomjs
exec = exec = c:/Program Files/phantomjs/phantomjs-1.9.7-windows/phantomjs.exe

# name of the convert script used by phantomjs
script = highcharts-convert.js 

...
...



mvn install


c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export>
"c:\Program Files\maven\apache-maven-3.2.1\bin\mvn.bat" install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Highcharts Export Project
[INFO] highcharts-export-convert
[INFO] highcharts-export-web
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Highcharts Export Project 2.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ highcharts-export ---
[INFO] Installing c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\pom.xml to C:\Users\namhadmin\.m2\repository\com\highcharts\export\highcharts-export\2.1.0\highcharts-export-2.1.0.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building highcharts-export-convert 2.1.0
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.pom (6 KB at 8.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.jar (34 KB at 59.9 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/commons-io/commons-io/1.3.2/commons-io-1.3.2.pom
Downloaded: http://repo.maven.apache.org/maven2/commons-io/commons-io/1.3.2/commons-io-1.3.2.pom (10 KB at 32.6 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/commons/commons-parent/3/commons-parent-3.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/commons/commons-parent/3/commons-parent-3.pom (12 KB at 38.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/log4j/log4j/1.2.14/log4j-1.2.14.pom
Downloaded: http://repo.maven.apache.org/maven2/log4j/log4j/1.2.14/log4j-1.2.14.pom (3 KB at 8.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/cglib/cglib/2.2.2/cglib-2.2.2.pom
Downloaded: http://repo.maven.apache.org/maven2/cglib/cglib/2.2.2/cglib-2.2.2.pom (2 KB at 5.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/asm/asm/3.3.1/asm-3.3.1.pom
Downloaded: http://repo.maven.apache.org/maven2/asm/asm/3.3.1/asm-3.3.1.pom (266 B at 0.9 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/asm/asm-parent/3.3.1/asm-parent-3.3.1.pom
Downloaded: http://repo.maven.apache.org/maven2/asm/asm-parent/3.3.1/asm-parent-3.3.1.pom (5 KB at 14.3 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/cglib/cglib/2.2.2/cglib-2.2.2.jar
Downloading: http://repo.maven.apache.org/maven2/log4j/log4j/1.2.14/log4j-1.2.14.jar
Downloading: http://repo.maven.apache.org/maven2/commons-io/commons-io/1.3.2/commons-io-1.3.2.jar
Downloading: http://repo.maven.apache.org/maven2/asm/asm/3.3.1/asm-3.3.1.jar
Downloaded: http://repo.maven.apache.org/maven2/asm/asm/3.3.1/asm-3.3.1.jar (43KB at 57.1 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/commons-io/commons-io/1.3.2/commons-io-1.3.2.jar (86 KB at 91.5 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/cglib/cglib/2.2.2/cglib-2.2.2.jar (281 KB at 255.2 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/log4j/log4j/1.2.14/log4j-1.2.14.jar (359 KB at 238.6 KB/sec)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ highcharts-export-convert ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 17 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ highcharts-export-convert ---
[INFO] Compiling 13 source files to C:\temp\highchart\highcharts.com-master\expo
rting-server\java\highcharts-export\highcharts-export-convert\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ highcharts-export-convert ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-convert\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ highcharts-export-convert ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ highcharts-export-convert ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ highcharts-export-convert ---
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2.1/plexus-archiver-2.1.jar
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-io/2.0.2/plexus-io-2.0.2.jar
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-io/2.0.2/plexus-io-2.0.2.jar (57 KB at 192.9 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2.1/plexus-archiver-2.1.jar (181 KB at 386.5 KB/sec)
[INFO] Building jar: C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-convert\target\highcharts-export-convert.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ highcharts-export-convert ---
[INFO] Installing C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-convert\target\highcharts-export-convert.jar
 to C:\Users\namhadmin\.m2\repository\com\highcharts\export\highcharts-export-convert\2.1.0\highcharts-export-convert-2.1.0.jar
[INFO] Installing C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-convert\pom.xml to C:\Users\namhadmin\.m2\repository\com\highcharts\export\highcharts-export-convert\2.1.0\highcharts-export-convert-2.1.0.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building highcharts-export-web 2.1.0
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.7/commons-codec-1.7.pom
Downloaded: http://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.7/commons-codec-1.7.pom (11 KB at 31.6 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/commons/commons-parent/26/commons-parent-26.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/commons/commons-parent/26/commons-parent-26.pom (47 KB at 63.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/commons-fileupload/commons-fileupload/1.2.2/commons-ileupload-1.2.2.pom
Downloaded: http://repo.maven.apache.org/maven2/commons-fileupload/commons-fileupload/1.2.2/commons-fileupload-1.2.2.pom (9 KB at 27.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/commons/commons-parent/16/commons-parent-16.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/commons/commons-paren
t/16/commons-parent-16.pom (30 KB at 90.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/taglibs/standard/1.1.2/standard-1.1.2.pom
Downloaded: http://repo.maven.apache.org/maven2/taglibs/standard/1.1.2/standard-1.1.2.pom (149 B at 0.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.pom
Downloaded: http://repo.maven.apache.org/maven2/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.pom (13 KB at 38.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/net/java/jvnet-parent/1/jvnet-parent-1.pom
Downloaded: http://repo.maven.apache.org/maven2/net/java/jvnet-parent/1/jvnet-parent-1.pom (5 KB at 14.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.7/commons-codec-1.7.jar
Downloading: http://repo.maven.apache.org/maven2/commons-fileupload/commons-fileupload/1.2.2/commons-fileupload-1.2.2.jar
Downloading: http://repo.maven.apache.org/maven2/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.jar
Downloading: http://repo.maven.apache.org/maven2/taglibs/standard/1.1.2/standard-1.1.2.jar
Downloaded: http://repo.maven.apache.org/maven2/commons-fileupload/commons-fileupload/1.2.2/commons-fileupload-1.2.2.jar (59 KB at 200.7 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.7/commons-codec-1.7.jar (254 KB at 418.3 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.jar (84 KB at 131.3 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/taglibs/standard/1.1.2/standard-1.1.2.jar (385 KB at 320.0 KB/sec)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ highcharts
-export-web ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ highcharts-export-web ---
[INFO] Compiling 5 source files to C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ highcharts-export-web ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ highcharts-export-web ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ highcharts-export-web ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ highcharts-export-web ---
[INFO] Packaging webapp
[INFO] Assembling webapp [highcharts-export-web] in [C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\target\highcharts-export-web]
[INFO] Processing war project
[INFO] Copying webapp webResources [C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\src/main/webapp/WEB-INF/pages] to [C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\target\highcharts-export-web]
[INFO] Copying webapp resources [C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\src\main\webapp]
[INFO] Webapp assembled in [476 msecs]
[INFO] Building war: C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\target\highcharts-export-web.war
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ highcharts-export-web ---
[INFO] Installing C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\target\highcharts-export-web.war to C:\Users\namhadmin\.m2\repository\com\highcharts\export\highcharts-export-web\2.1.0\highcharts-export-web-2.1.0.war
[INFO] Installing C:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\pom.xml to C:\Users\namhadmin\.m2\repository\com\highcharts\export\highcharts-export-web\2.1.0\highcharts-export-web-2.1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Highcharts Export Project ......................... SUCCESS [  0.832 s]
[INFO] highcharts-export-convert ......................... SUCCESS [  9.556 s]
[INFO] highcharts-export-web ............................. SUCCESS [  6.337 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.851 s
[INFO] Finished at: 2014-06-27T15:04:05+09:00
[INFO] Final Memory: 20M/163M
[INFO] ------------------------------------------------------------------------
c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export>




mvn clean

c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\
highcharts-export-web>"c:\Program Files\maven\apache-maven-3.2.1\bin\mvn.bat" clean
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building highcharts-export-web 2.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ highcharts-export-web
---
[INFO] Deleting c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.382 s
[INFO] Finished at: 2014-06-27T15:11:06+09:00
[INFO] Final Memory: 5M/123M
[INFO] ------------------------------------------------------------------------
c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\
highcharts-export-web>


maven pacakge

war 를 만들어 준다.

c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\
highcharts-export-web>"c:\Program Files\maven\apache-maven-3.2.1\bin\mvn.bat" pa
ckage
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building highcharts-export-web 2.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ highcharts-export-web ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ highcharts-export-web ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ highcharts-export-web ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ highcharts-export-web ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ highcharts-export-web ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ highcharts-export-web ---
[INFO] Packaging webapp
[INFO] Assembling webapp [highcharts-export-web] in [c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\target\highcharts-export-web]
[INFO] Processing war project
[INFO] Copying webapp webResources [c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\src/main/webapp/WEB-INF/pages] to [c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\target\highcharts-export-web]
[INFO] Copying webapp resources [c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\src\main\webapp]
[INFO] Webapp assembled in [302 msecs]
[INFO] Building war: c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\highcharts-export-web\target\highcharts-export-web.war
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.157 s
[INFO] Finished at: 2014-06-27T15:16:08+09:00
[INFO] Final Memory: 10M/156M
[INFO] ------------------------------------------------------------------------
c:\temp\highchart\highcharts.com-master\exporting-server\java\highcharts-export\
highcharts-export-web>

그러면, 아래 path 에 highcharts-export-web.war 가 생성된다.

  • highcharts-export-web/target/highcharts-export-web.war



highcharts-export-web.war 

highcharts-export-web.war 를 tomcat 의 webapps 안에 넣자.

c:\Program Files\tomcat\apache-tomcat-7.0.47\webapps\highcharts-export-web.war





eclipse 에서 .war 띄우기

servers windows 에서 서버를 하나 선택해서 double click 하면 설정을 할 수 있는데, 여기서 Module tab 으로 가자. 여기서 Web Module 를 추가해 주면 된다.

절차

  1. Servers window
  2. 서버 선택 > double click
  3. Modules tab
  4. Add External Web Modules
  5. highcharts-export-web.war 선택
  6. Path 지정(web url 이 된다.)







source debugging in eclipse

package 를 맞춰서 source 를 넣자.

  • com.highcharts.export

그리고 필요한 package 들과 관련된 dependency 를 pom.xml 에 추가하자.(단지 compile 을 위해서 이다.?)

build 를 하고,

server 에 external module 로 highcharts-export-web.war 을 추가하자. 여기서 URL path 는
  • /high

로 설정했다.(eclipse 에서 사용하기 참조)

com.highcharts.export.ExportController 의 exporter() 에 breakpoint 를 걸고
highcharts-export-web.war 의 path 로 접근하면 breakpoint 가 작동한다.
  • http://localhost:8080/high/



tomcat 의 server.xml 설정


<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">

Host 의 appBase 속성은 모든 webapp 들의 기본 디렉토리를 정의한다. 위의 경우에는
<CATALINA_HOME>\webapps
가 된다.[ref. 2]
webapps 밑에 있는 디렉토리 이름이 application 의 이름이다. 기본적으로 이 directory 이름이 application 의 URL 된다. 예를 들어

  • c:\Program Files\tomcat\apache-tomcat-7.0.47\webapps\docs\

인 경우는
  • http://localhost:8080/docs 

가 된다.

단, 예외적으로 ROOT 만 특정 url 에 연결되지 않는다. ROOT 는 기본적으로
  • http://localhost:8080/

처럼 empty string 에 mapping 된다.

unpackWARs

이녀석이 true 라면 .war file 을 풀어놓고(unpack) 사용한다는 뜻이다. 만약 false 라면 .war 인 채로 사용한다. 그래서 느리다. true 인 경우, 아래처럼 war 을 가져다 놓고 사용하면 unpack 된 상태가 된다.




autoDeploy

이녀석은 tomcat 이 실행되고 있는 가운데 web application 이 새롭게 deploy 되면 자동으로 읽어 드려 deploy 할 지를 정해준다.





Tomcat 의 web.xml [ref.2]

web.xml 은 두가지가 있다.

<CATALINA_HOME>\conf\web.xml : 모든 webapps 에 적용되는 녀석
ContextRoot\WEB-INF\web.xml: 특정 webapp 에 적용되는 녀석, global web.xml 을 override 한다.




References

  1. SETTING UP THE EXPORT SERVER >  EXPORT SERVER BASED ON JAVA AND PHANTOMJS, Highchart homepage
  2. Advanced Tutorial on Tomcat 7
  3. Web Server Module | PhantomJS

댓글 없음:

댓글 쓰기