톰켓과 안드로이드를 동영상 지원을 위해 다윈 스트리밍 서버를 이용중입니다.
rtsp://localhost(or 다른컴퓨터에서 서버 컴퓨터 아이디IP나 ddns주소)/sample.mp4 잘 나옵니다.
같은 서버주소로 회원가입과 데이터를 주고 받는것도 잘 됩니다.
09-29 14:18:49.652: E/dalvikvm(738): Could not find class 'org.apache.commons.httpclient.HttpClient', referenced from method kwc.vbns.VBNSUpload.uploadFile
09-29 14:19:02.232: E/AndroidRuntime(738): FATAL EXCEPTION: main
09-29 14:19:02.232: E/AndroidRuntime(738): java.lang.NoClassDefFoundError: org.apache.commons.httpclient.HttpClient
09-29 14:19:02.232: E/AndroidRuntime(738): at kwc.vbns.VBNSUpload.uploadFile(VBNSUpload.java:446)
09-29 14:19:02.232: E/AndroidRuntime(738): at kwc.vbns.VBNSUpload.access$4(VBNSUpload.java:442)
09-29 14:19:02.232: E/AndroidRuntime(738): at kwc.vbns.VBNSUpload$3.onClick(VBNSUpload.java:153)
09-29 14:19:02.232: E/AndroidRuntime(738): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
09-29 14:19:02.232: E/AndroidRuntime(738): at android.os.Handler.dispatchMessage(Handler.java:99)
09-29 14:19:02.232: E/AndroidRuntime(738): at android.os.Looper.loop(Looper.java:137)
09-29 14:19:02.232: E/AndroidRuntime(738): at android.app.ActivityThread.main(ActivityThread.java:4745)
09-29 14:19:02.232: E/AndroidRuntime(738): at java.lang.reflect.Method.invokeNative(Native Method)
09-29 14:19:02.232: E/AndroidRuntime(738): at java.lang.reflect.Method.invoke(Method.java:511)
09-29 14:19:02.232: E/AndroidRuntime(738): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-29 14:19:02.232: E/AndroidRuntime(738): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-29 14:19:02.232: E/AndroidRuntime(738): at dalvik.system.NativeStart.main(Native Method)
에러로그 입니다. 무엇이 잘못 된 것인지...
5번째 줄이 해당 라인입니다. 답답해 죽겠습니다.
--
private boolean uploadFile()
{
String strUrl = strServerIp + "vbns_upload.jsp";
org.apache.commons.httpclient.HttpClient client = new org.apache.commons.httpclient.HttpClient();
org.apache.commons.httpclient.methods.MultipartPostMethod mPost = new org.apache.commons.httpclient.methods.MultipartPostMethod(strUrl);
String strScreenPath = strFilePath.substring(0,strFilePath.lastIndexOf("."))+"_ss.jpg";
String strThumbPath = strFilePath.substring(0,strFilePath.lastIndexOf("."))+"_tn.jpg";
File fileMovie = new File(strFilePath);
File fileScreen = new File(strScreenPath);
File fileThumb = new File(strThumbPath);
File fileSrt = null;
if(isVbns)
{
String strSrtPath = strFilePath.substring(0,strFilePath.lastIndexOf("."))+".srt";
fileSrt= new File(strSrtPath);
}
try {
mPost.addParameter(fileMovie.getName(), fileMovie);
mPost.addParameter(fileScreen.getName(), fileScreen);
mPost.addParameter(fileThumb.getName(), fileThumb);
if(isVbns)
mPost.addParameter(fileSrt.getName(), fileSrt);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
client.executeMethod(mPost);
} catch (IOException e) {
e.printStackTrace();
}
try {
JSONObject jsonFileName = new JSONObject(mPost.getResponseBodyAsString().trim());
strUploadName = jsonFileName.getString("fileName");
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
if(mPost.getStatusCode()==200)
{
mPost.releaseConnection();
return true;
}
else
{
mPost.releaseConnection();
Toast.makeText(this, "파일 업로드에 실패하였습니다.", Toast.LENGTH_SHORT).show();
return false;
}
}위쪽이 java파일 소스입니다.
아래가jsp파일 소스입니다.
<
<% request.setCharacterEncoding("euc-kr"); %>
<%!
private String setFileName(String temDir, String fileName){
//String temDir = "c:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT";
String temDir = application.getRealPath("/files/movie");
String strName = fileName;
File uploadedFile = new File(temDir, fileName);
if(uploadedFile.exists())
{
strName = strName.substring(0, strName.lastIndexOf("."))+"_2" + strName.substring(strName.lastIndexOf("."));
strName = setFileName(temDir, strName);
}
return strName;
}
톰캣 설치 경로는
c:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT 입니다.
안드로이드에서 파일 업로드 누르면 어플이 응답하지 않습니다. 하고 종료 됩니다.
DMZ로 포트도 열어놨습니다.
(jsp 글자 수 제한으로 다 적지 못했습니다.)