Shiam Shabbir Himel
Shiam Shabbir Himel

Reputation: 79

JAIN SIP on android with java.lang.reflect.InvocationTargetException

I am a new android developer and currently I am trying to implement JSIP in andorid. when I add jsip api in andorid, an error show me that jsip's javax package conflicts with java's default javax package.

So I have changed all javax package to com.g5.javax.* this format. then the error goes off. but now another error came up which I attached with this message. it throws me java.lang.reflect.InvocationTargetException with javax.sip.PeerUnavailableException: stack name is missing error. I've checked and double checked the jain sip source and found that the properties key "com.g5.javax.sip.STACK_NAME"(changed by refactoring using eclipse) has the value which I 've given. but the error came up each time. another interesting information is the same jar package which I 've created works perfectly in desktop application. I've stuck with this error for 2 days.

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)

Upvotes: 1

Views: 728

Answers (3)

user2818782
user2818782

Reputation: 756

You need to set a name in the properties for the key javax.sip.STACK_NAME

properties.setProperty("javax.sip.STACK_NAME", "myStack");

Upvotes: 0

Gustavo Meira
Gustavo Meira

Reputation: 3063

Just finished it to work on Android 4.4.2.

The first thing I believe is to do what you did. You changed the javax name space to something else: whatever.javax.*, for example.

Then I had the same problem Martin mentioned in his answer, and I'm thankful for his words here on SO. It looks like the gov.nist name space is also present somewhere else at runtime. So what I did was: changed the gov.nist.* name space to gov.nist.whatever as well (and all the references to it, off course).

Also, you'll need to provide the property "gov.nist.whatever.javax.sip.STACK_NAME" somewhere. You can do that using:

Properties properties = new Properties();
properties.setProperty("sipper.sip.STACK_NAME", "stack");

somewhere in the app, as pointed out by Mike in this answer.

After all that I had problems with a NoClassFoundError exception with the org.apache.log4j.Logger class, even with the respective jars in my classpath. So I moved all the jars from the "asset" project directory to a new one called "libs". Reconfigured my project's classpath with the new directory scheme, and it worked like a charm (OK, no overstatements).

Upvotes: 0

Martin
Martin

Reputation: 123

I'm also having the same problem, so I tried to dig a bit deeper, as the error on the implementation of the stack isn't being reported. From this i got this error:

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)

Now heres the problem. I looked at the code for the SipStackImpl class and found these lines:

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

So it means the name isn't being picked up. So i gave the name a string value, but still got the error, which leads me to belive that the SipStackImpl is being picked up from somewhere else. Problem is I've no idea where, I've searched the whole project for that error and thats the only place it exists, so it must be coming from somewhere (even commenting out the error detection still leaves the error). Thats where I'm stuck right now, hope this helps, if you find anything extra let me know

Upvotes: 1

Related Questions