jBoss WebアプリケーションからRemoteConverter
を使用して、documents4jプロジェクトにデフォルトのserver-standalone
として組み込まれているスタンドアロンサーバーを使用しています。Documents4jのRemoteConverter用のカスタムHttpClient
私は必要なライブラリの古いバージョンを持っていますhttpclient-4.0.1.jar
と関連するhttpcore-4.0.1.jar
私は多くのClassDefNotFoundException
に直面しているので、JVMによってロードされたJARの異なるバージョンによって引き起こされます。
まだ
私は、理由により以前の問題のために、standalone-server
用のカスタムHTTPクライアントをbluildしたいのですが、この問題を回避するために、それはだバージョンでは利用できませんHttpClientConnectionManager
オブジェクトとの具体的な問題があります私はJersey
を使用することはできません。
誰かがそれに対してstandalone-server
の別のクライアントを構築していますか?カスタムRemoteClient
を構築するスペックは何ですか?
UPDATE 1スニッフィングツールの助けを借りて、分析を少しした後、私はメッセージの構図を考え出したので、私はちょうど、次のようにそのサーバ用のカスタムHttpClient
を終了しました
:
File wordFile = new File("C:/temp/test.docx");
InputStream targetStream = new FileInputStream(wordFile);
URL url = new URL("http://localhost:9998");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/vnd.com.documents4j.any-msword");
conn.setRequestProperty("Accept", "application/pdf");
conn.setRequestProperty("Converter-Job-Priority", "1000");
OutputStream os = conn.getOutputStream();
os.write(IOUtils.toByteArray(targetStream));
os.flush();
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
FileWriter ostream = new FileWriter("C:/temp/test.pdf");
BufferedWriter out = new BufferedWriter(ostream);
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
out.write(output+"\n");
}
br.close();
out.close();
os.close();
conn.disconnect();
私が作成したばかりのtest.pdfファイルを開こうとすると、すべて白であるが適切なページ数で問題が発生する。私は、テキストエディタでファイルを開き、ファイルの先頭と末尾を分析する場合、私は、次の文字を見つけました:
%PDF-1.5
%µµµµ
1 0 obj
[...]
startxref
1484122
%%EOF
良いPDFファイルのようです。
RESTサーバーから受信したファイルとは何か関係がありますか?