Sunday, February 10, 2013

Jersey + Multipart + Maven

I thought I should write about a problem that takes a long time for me to solve in case I forget about it.

I looked through tutorials and other articles to learn about Jersey Multipart. However, I ran into issues with missing dependency by following these tutorials. I finally solved it by setting up my maven POM file in the following way:

<dependencies>
  <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
        <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-server</artifactId>
      <version>1.9</version>
    </dependency>
   <dependency>
      <groupId>com.sun.jersey.contribs</groupId>
      <artifactId>jersey-multipart</artifactId>
      <version>1.9</version>
    </dependency>
    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-json</artifactId>
      <version>1.9</version>
    </dependency>
     <dependency>
      <groupId>org.jvnet.mimepull</groupId>
      <artifactId>mimepull</artifactId>
      <version>1.9</version>
    </dependency>
  </dependencies>

In short, problems seem to come from version differences across jersey libraries as well as mimepull libraries. All libraries should be the same version. So even if other Jersey libraries  already had 1.14 version, it should be safer to use 1.9 version since it was the latest version for mimepull.

The missing dependency error messages were not too informative at this case.

Thanks to authors of original articles and  their comments who contribute to the solution.

Hope it helps others.

中文翻譯:

最近花了不少時間解決了一個問題, 想說先把解決方案寫下來以免忘記.

之前幾日在網路上尋找關於Jersey Multipart的教學. 在讀完許多教學後自己寫了一個簡單的範例.但是在Deploy時卻遇到missing dependency的問題. 最後終於在把Maven的POM檔做出以下修改後解決了問題:


<dependencies>
  <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
        <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-server</artifactId>
      <version>1.9</version>
    </dependency>
   <dependency>
      <groupId>com.sun.jersey.contribs</groupId>
      <artifactId>jersey-multipart</artifactId>
      <version>1.9</version>
    </dependency>
    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-json</artifactId>
      <version>1.9</version>
    </dependency>
     <dependency>
      <groupId>org.jvnet.mimepull</groupId>
      <artifactId>mimepull</artifactId>
      <version>1.9</version>
    </dependency>
  </dependencies>


總結是Jersey libraries跟mimepull的版本必須要相同. 不然會出現Missing Dependency的問題. 所以即使Jersey libraries已有1.14版, 這裡必須使用1.9版, 因為mimepull只有到1.9版.

完全沒想到missing dependency會跟版本有相關性.

希望這篇文章可以幫到需要的朋友們.

Original Tutorial Site:
http://www.mkyong.com/webservices/jax-rs/file-upload-example-in-jersey/

Sincerely,
Danil

Thursday, January 10, 2013

Happy New Year 2013

DeviantArt Link: http://browse.deviantart.com/#/d5pzedp


I managed to finish before the New Year in US.

Artwork is completed in MyPaint with GIMP to add texts and some enhancements.

Hope you guys like it and wish you guys happy New Year 2013.


總算在美國新年前完成.

作品是在MyPaint中完成, Gimp 加上文字與修正.

希望您們會喜歡也祝福各位新年快樂.

Sincerely,
Danil