JAR behaves differently when running in MATLAB - Throws error that cannot be reproduced outside MATLAB

1 回表示 (過去 30 日間)
Dean
Dean 2012 年 9 月 24 日
コメント済み: Matt 2013 年 11 月 18 日
I have a pretty basic JAR file that contains a single class. It handles some network stuff, mainly transferring files between a matlab client application and a server. I'm having some weird behavior that I can't quite explain. When I run a request to my server that I expect to return a 404, it works fine when just running a jUnit test in Eclipse. When I import the class into matlab and do the exact same thing I instead get:
??? Java exception occurred:
ice.net.URLNotFoundException: Document not found on server
at ice.net.HttpURLConnection.getInputStream(OEAB)
at ice.net.HttpURLConnection.getResponseCode(OEAB)
at me.openconnecto.OcpUrl.query(OcpUrl.java:34)
This occurres when on the line where I am getting the response code:
this.responseCode = conn.getResponseCode();
I should still be able to get the response code even though I got a 404. Also I'm not using the ice library in my java code, so is MATLAB doing that instead of use just plain java.io*? Any tips from the java-matlab wiz's out there would be appreciated.
  1 件のコメント
Matt
Matt 2013 年 11 月 18 日
I'm having a similar problem with Java behaving differently inside MATLAB, described here
Did you find a solution to your issue?

サインインしてコメントする。

回答 (1 件)

Malcolm Lidierth
Malcolm Lidierth 2012 年 9 月 24 日
Are you using the same ice.net jar file in Eclipse & MATLAB? It ships with and is on the ML static jar path. Many jars shipped with MATLAB are legacy versions.
ice.net.URLNotFoundException sounds like a suitable exception to throw for 404.
  2 件のコメント
Dean
Dean 2012 年 9 月 24 日
No I'm just using the normal java.io.net libraries and would prefer to use those. In my class I read the response code and take some action before throwing an exception. I can try-catch around it, but it's kind of kludgy...is there a way to force MATLAB to not use the ice.net libraries?
Malcolm Lidierth
Malcolm Lidierth 2012 年 9 月 25 日
"at me.openconnecto.OcpUrl.query(OcpUrl.java:34)"
What is that, and where is that being called from?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Compiler SDK についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by