使用java.lang.reflect.InvocationTargetException在Android上安装JAIN SIP

时间:2012-09-27 05:17:07

标签: android sip voip jain-sip

我是一名新的Android开发人员,目前我正在尝试在andorid中实现JSIP。当我在andorid中添加jsip api时,错误显示jsip的javax包与java的默认javax包冲突。

所以我将所有javax包更改为com.g5.javax。*这种格式。那么错误就会消失。但现在又出现了另一个错误,我附上了这条消息。它抛出java.lang.reflect.InvocationTargetException与javax.sip.PeerUnavailableException:堆栈名称丢失错误。我已经检查并仔细检查了jain sip源,发现属性键“com.g5.javax.sip.STACK_NAME”(通过使用eclipse进行重构更改)具有我给出的值。但每次出现错误。另一个有趣的信息是我创建的同一个jar包在桌面应用程序中完美运行。我已经坚持了2天这个错误。

09-27 04:58:13.819: I/System.out(564): class java.util.Properties
09-27 04:58:13.839: I/System.out(564): {com.g5.javax.sip.STACK_NAME=123}
09-27 04:58:13.869: E/com.g5(564): cannot instantiate
09-27 04:58:13.869: E/com.g5(564): com.g5.javax.sip.PeerUnavailableException: The Peer SIP Stack: gov.nist.javax.sip.SipStackImpl could not be instantiated. Ensure the Path Name has been set.
09-27 04:58:13.869: E/com.g5(564):  at com.g5.javax.sip.SipFactory.createStack(SipFactory.java:332)
09-27 04:58:13.869: E/com.g5(564):  at com.g5.javax.sip.SipFactory.createSipStack(SipFactory.java:154)
09-27 04:58:13.869: E/com.g5(564):  at com.shootme.Shootme.init(Shootme.java:104)
09-27 04:58:13.869: E/com.g5(564):  at com.shootme.Shootme.onCreate(Shootme.java:87)
09-27 04:58:13.869: E/com.g5(564):  at android.app.Activity.performCreate(Activity.java:4465)
09-27 04:58:13.869: E/com.g5(564):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-27 04:58:13.869: E/com.g5(564):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
09-27 04:58:13.869: E/com.g5(564):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-27 04:58:13.869: E/com.g5(564):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-27 04:58:13.869: E/com.g5(564):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-27 04:58:13.869: E/com.g5(564):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-27 04:58:13.869: E/com.g5(564):  at android.os.Looper.loop(Looper.java:137)
09-27 04:58:13.869: E/com.g5(564):  at android.app.ActivityThread.main(ActivityThread.java:4424)
09-27 04:58:13.869: E/com.g5(564):  at java.lang.reflect.Method.invokeNative(Native Method)
09-27 04:58:13.869: E/com.g5(564):  at java.lang.reflect.Method.invoke(Method.java:511)
09-27 04:58:13.869: E/com.g5(564):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-27 04:58:13.869: E/com.g5(564):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-27 04:58:13.869: E/com.g5(564):  at dalvik.system.NativeStart.main(Native Method)
09-27 04:58:13.869: E/com.g5(564): Caused by: java.lang.reflect.InvocationTargetException
09-27 04:58:13.869: E/com.g5(564):  at java.lang.reflect.Constructor.constructNative(Native Method)
09-27 04:58:13.869: E/com.g5(564):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
09-27 04:58:13.869: E/com.g5(564):  at com.g5.javax.sip.SipFactory.createStack(SipFactory.java:322)
09-27 04:58:13.869: E/com.g5(564):  ... 17 more
09-27 04:58:13.869: E/com.g5(564): Caused by: javax.sip.PeerUnavailableException: stack name is missing
09-27 04:58:13.869: E/com.g5(564):  at gov.nist.javax.sip.SipStackImpl.<init>(SipStackImpl.java:554)

3 个答案:

答案 0 :(得分:1)

我也有同样的问题,所以我试图深入挖掘,因为没有报告堆栈实现的错误。从这里我得到了这个错误:

11-11 18:51:01.025: W/System.err(17454): javax.sip.PeerUnavailableException: stack name is missing
11-11 18:51:01.025: W/System.err(17454):    at gov.nist.javax.sip.SipStackImpl.<init>(SipStackImpl.java:554)
11-11 18:51:01.025: W/System.err(17454):    at not.javax.sip.SipFactory.createStack(SipFactory.java:322)
11-11 18:51:01.025: W/System.err(17454):    at not.javax.sip.SipFactory.createSipStack(SipFactory.java:171)
11-11 18:51:01.025: W/System.err(17454):    at org.jaintest.MainActivity.init(MainActivity.java:110)
11-11 18:51:01.025: W/System.err(17454):    at org.jaintest.MainActivity.onCreate(MainActivity.java:68)
11-11 18:51:01.025: W/System.err(17454):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-11 18:51:01.025: W/System.err(17454):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
11-11 18:51:01.025: W/System.err(17454):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
11-11 18:51:01.025: W/System.err(17454):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-11 18:51:01.025: W/System.err(17454):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
11-11 18:51:01.025: W/System.err(17454):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-11 18:51:01.025: W/System.err(17454):    at android.os.Looper.loop(Looper.java:123)
11-11 18:51:01.025: W/System.err(17454):    at android.app.ActivityThread.main(ActivityThread.java:3691)
11-11 18:51:01.025: W/System.err(17454):    at java.lang.reflect.Method.invokeNative(Native Method)
11-11 18:51:01.025: W/System.err(17454):    at java.lang.reflect.Method.invoke(Method.java:507)
11-11 18:51:01.025: W/System.err(17454):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
11-11 18:51:01.025: W/System.err(17454):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
11-11 18:51:01.025: W/System.err(17454):    at dalvik.system.NativeStart.main(Native Method)

现在是问题所在。我查看了SipStackImpl类的代码并找到了这些行:

String name = configurationProperties
    .getProperty("com.tlccom.javax.sip.STACK_NAME");
if (name == null) 
    throw new PeerUnavailableException("stack name is missing");

因此,这意味着该名称未被提取。所以我给了名字一个字符串值,但仍然得到了错误,这让我相信SipStackImpl是从其他地方获取的。问题是我不知道在哪里,我已经在整个项目中搜索了该错误,这是唯一存在的地方,所以它必须来自某个地方(甚至评论错误检测仍然会留下错误) 。这就是我现在被困住的地方,希望这有帮助,如果你发现任何额外的东西让我知道

答案 1 :(得分:0)

刚刚完成Android 4.4.2。

我认为首先要做的就是做你做的事。您已将javax名称空间更改为其他名称:whatever.javax.*,例如。

然后我在他的回答中提到了同样的问题,我很感谢他在这里所说的话。看起来gov.nist名称空间在运行时也位于其他位置。所以我做的是:也将gov.nist.*名称空间更改为gov.nist.whatever(以及所有对它的引用,当然)。

此外,您还需要在某处提供属性"gov.nist.whatever.javax.sip.STACK_NAME" 。您可以使用以下方式执行此操作:

Properties properties = new Properties();
properties.setProperty("sipper.sip.STACK_NAME", "stack");
正如迈克在this answer中指出的那样,应用程序中的某个地方。

毕竟我遇到了NoClassFoundErrororg.apache.log4j.Logger异常的问题,即使我的类路径中有相应的jar。 所以我将所有的jar从“asset”项目目录移动到一个名为“libs”的新jar。使用新的目录方案重新配置了我的项目的类路径,它就像一个魅力(好的,没有夸大其词)。

答案 2 :(得分:0)

您需要在键 javax.sip.STACK_NAME

的属性中设置名称
properties.setProperty("javax.sip.STACK_NAME", "myStack");