jain-sip v1.2学习笔记
2006-11-16 10:03
465 查看
刚刚sip,第一次使用jain-sip包来做开发时遇到了一些问题。我写出来,方便自己回顾同时也给后来者提供借鉴。
我在https://jain-sip.dev.java.net/上面下在JainSipApi1.2.jar(sip的接口)和JainSipRi1.2.jar(NIST对sip的参考实现) 然后建立了一个java工程(我是用eclipse)。然后把这两个包导入,写了一个很简单的代码;如下:
package com.wwm.uas;
import java.util.Properties;
import javax.sip.PeerUnavailableException;
import javax.sip.SipFactory;
import javax.sip.SipStack;
public class SimpleUAS {
public SimpleUAS(){
//Configuration s;
SipStack sipStack = null;
SipFactory sipFactory = SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
Properties properties = new Properties();
// If you want to try TCP transport change the following to
String transport = "udp";
String peerHostPort = "127.0.0.1:5060";
properties.setProperty("javax.sip.OUTBOUND_PROXY", peerHostPort + "/"
+ transport);
// If you want to use UDP then uncomment this.
properties.setProperty("javax.sip.STACK_NAME", "shootist");
// The following properties are specific to nist-sip
// and are not necessarily part of any other jain-sip
// implementation.
// You can set a max message size for tcp transport to
// guard against denial of service attack.
properties.setProperty("gov.nist.javax.sip.DEBUG_LOG",
"shootistdebug.txt");
properties.setProperty("gov.nist.javax.sip.SERVER_LOG",
"shootistlog.txt");
// Drop the client connection after we are done with the transaction.
properties.setProperty("gov.nist.javax.sip.CACHE_CLIENT_CONNECTIONS",
"false");
// Set to 0 (or NONE) in your production code for max speed.
// You need 16 (or TRACE) for logging traces. 32 (or DEBUG) for debug + traces.
// Your code will limp at 32 but it is best for debugging.
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "TRACE");
try {
sipStack = sipFactory.createSipStack(properties);
} catch (PeerUnavailableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(-1);
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SimpleUAS test= new SimpleUAS();
}
}
然后运行问题就出来了:
报如下错误:
javax.sip.PeerUnavailableException: The Peer SIP Stack: gov.nist.javax.sip.SipStackImpl could not be instantiated. Ensure the Path Name has been set.
at javax.sip.SipFactory.createStack(SipFactory.java:324)
at javax.sip.SipFactory.createSipStack(SipFactory.java:152)
at com.wwm.uas.SimpleUAS.<init>(SimpleUAS.java:42)
at com.wwm.uas.SimpleUAS.main(SimpleUAS.java:55)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at javax.sip.SipFactory.createStack(SipFactory.java:314)
... 3 more
Caused by: java.lang.NoClassDefFoundError: EDU/oswego/cs/dl/util/concurrent/ConcurrentHashMap
at gov.nist.javax.sip.stack.SIPTransactionStack.<init>(SIPTransactionStack.java:360)
at gov.nist.javax.sip.SipStackImpl.<init>(SipStackImpl.java:252)
at gov.nist.javax.sip.SipStackImpl.<init>(SipStackImpl.java:293)
... 8 more
后来折腾了很久才发现没有concurrent.jar的包.我在http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html 这个包大致作用是线程同步操作,数据通道。我没有仔细研究过。
下载后的文件时需要编译的。注意参看上面链接中的内容。当然如果你有jboss4的话,下面直接就有concurrent.jar($jboss_home/lib/)
引入该包后运行程序,出现以下问题:
javax.sip.PeerUnavailableException: The Peer SIP Stack: gov.nist.javax.sip.SipStackImpl could not be instantiated. Ensure the Path Name has been set.
at javax.sip.SipFactory.createStack(SipFactory.java:324)
at javax.sip.SipFactory.createSipStack(SipFactory.java:152)
at com.wwm.uas.SimpleUAS.<init>(SimpleUAS.java:43)
at com.wwm.uas.SimpleUAS.main(SimpleUAS.java:56)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at javax.sip.SipFactory.createStack(SipFactory.java:314)
... 3 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Layout
at gov.nist.javax.sip.SipStackImpl.<init>(SipStackImpl.java:316)
... 8 more
有了上面的经验,立刻就知道什么原因了。确log4j的包。不用多说,到apache网站上下载吧.
引入log4j运行成功了;)
我在https://jain-sip.dev.java.net/上面下在JainSipApi1.2.jar(sip的接口)和JainSipRi1.2.jar(NIST对sip的参考实现) 然后建立了一个java工程(我是用eclipse)。然后把这两个包导入,写了一个很简单的代码;如下:
package com.wwm.uas;
import java.util.Properties;
import javax.sip.PeerUnavailableException;
import javax.sip.SipFactory;
import javax.sip.SipStack;
public class SimpleUAS {
public SimpleUAS(){
//Configuration s;
SipStack sipStack = null;
SipFactory sipFactory = SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
Properties properties = new Properties();
// If you want to try TCP transport change the following to
String transport = "udp";
String peerHostPort = "127.0.0.1:5060";
properties.setProperty("javax.sip.OUTBOUND_PROXY", peerHostPort + "/"
+ transport);
// If you want to use UDP then uncomment this.
properties.setProperty("javax.sip.STACK_NAME", "shootist");
// The following properties are specific to nist-sip
// and are not necessarily part of any other jain-sip
// implementation.
// You can set a max message size for tcp transport to
// guard against denial of service attack.
properties.setProperty("gov.nist.javax.sip.DEBUG_LOG",
"shootistdebug.txt");
properties.setProperty("gov.nist.javax.sip.SERVER_LOG",
"shootistlog.txt");
// Drop the client connection after we are done with the transaction.
properties.setProperty("gov.nist.javax.sip.CACHE_CLIENT_CONNECTIONS",
"false");
// Set to 0 (or NONE) in your production code for max speed.
// You need 16 (or TRACE) for logging traces. 32 (or DEBUG) for debug + traces.
// Your code will limp at 32 but it is best for debugging.
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "TRACE");
try {
sipStack = sipFactory.createSipStack(properties);
} catch (PeerUnavailableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(-1);
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SimpleUAS test= new SimpleUAS();
}
}
然后运行问题就出来了:
报如下错误:
javax.sip.PeerUnavailableException: The Peer SIP Stack: gov.nist.javax.sip.SipStackImpl could not be instantiated. Ensure the Path Name has been set.
at javax.sip.SipFactory.createStack(SipFactory.java:324)
at javax.sip.SipFactory.createSipStack(SipFactory.java:152)
at com.wwm.uas.SimpleUAS.<init>(SimpleUAS.java:42)
at com.wwm.uas.SimpleUAS.main(SimpleUAS.java:55)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at javax.sip.SipFactory.createStack(SipFactory.java:314)
... 3 more
Caused by: java.lang.NoClassDefFoundError: EDU/oswego/cs/dl/util/concurrent/ConcurrentHashMap
at gov.nist.javax.sip.stack.SIPTransactionStack.<init>(SIPTransactionStack.java:360)
at gov.nist.javax.sip.SipStackImpl.<init>(SipStackImpl.java:252)
at gov.nist.javax.sip.SipStackImpl.<init>(SipStackImpl.java:293)
... 8 more
后来折腾了很久才发现没有concurrent.jar的包.我在http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html 这个包大致作用是线程同步操作,数据通道。我没有仔细研究过。
下载后的文件时需要编译的。注意参看上面链接中的内容。当然如果你有jboss4的话,下面直接就有concurrent.jar($jboss_home/lib/)
引入该包后运行程序,出现以下问题:
javax.sip.PeerUnavailableException: The Peer SIP Stack: gov.nist.javax.sip.SipStackImpl could not be instantiated. Ensure the Path Name has been set.
at javax.sip.SipFactory.createStack(SipFactory.java:324)
at javax.sip.SipFactory.createSipStack(SipFactory.java:152)
at com.wwm.uas.SimpleUAS.<init>(SimpleUAS.java:43)
at com.wwm.uas.SimpleUAS.main(SimpleUAS.java:56)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at javax.sip.SipFactory.createStack(SipFactory.java:314)
... 3 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Layout
at gov.nist.javax.sip.SipStackImpl.<init>(SipStackImpl.java:316)
... 8 more
有了上面的经验,立刻就知道什么原因了。确log4j的包。不用多说,到apache网站上下载吧.
引入log4j运行成功了;)
相关文章推荐
- SIP别人的学习笔记,很好
- 【NGN学习笔记】3 软交换中的协议1--SIP、SIP-I/SIP-T/BICC
- SIP学习笔记----包
- SIP学习笔记
- SIP学习笔记
- 注册——SIP学习笔记(六)
- 【SIP协议】学习初学笔记
- 【SIP协议】学习初学笔记
- RFC3261 SIP协议学习笔记----sip协议基本功能描述
- SIP学习笔记
- VOLTE学习笔记(二)——IMS相关标识及SIP知识
- NGN学习笔记3——软交换中的协议1--SIP、SIP-I/SIP-T/BICC
- 通用用户代理行为——SIP学习笔记(五)
- SIP学习笔记
- SIP学习笔记(1)----消息集合
- FreeSWITCH学习笔记 第一场 第五个镜头 添加新SIP用户
- SIP学习笔记
- 【SIP协议】学习初学笔记
- sip学习笔记(1)--电路交换网络中的信令
- RFC 3261 SIP学习笔记