Hi,

Using Class.forName() in OSGi always cause problem.
Seems you already figure out the solution, but I think you need add dynamic import for jain-sip bundle. Another solution is use fragment bundle which contain the classes that jain-sip need init using Class.forName() and attach this fragment to the jain-sip bundle, in this case the jain-sip bundle play the role as a host and all resources in fragment is available for host.

Freeman
On 2011-6-8, at 下午3:26, shooding wrote:

We're using jain-sip 1.2 to develop a sip-bc and deployed to SMX4.3
without an error. Then we create an SA to start it.
While SIPReceiverEndpoint.start, SipFactory.createStack, we got a
PeerUnavailableException.
I wonder if Class.forName (aka Java reflection) does not work.
Here is a page talking about dynamic import.
http://billhiggins.us/blog/2011/02/24/using-reflection-in-osgi/
http://billhiggins.us/blog/2011/02/24/using-reflection-in-osgi/
Therefore, we added
<servicemix.osgi.dynamic.import>*</servicemix.osgi.dynamic.import> to the
pom.xml of sip-bc.
Still got the same exception.

The following code is a snippet of SipFactory.java.

        private SipStack createStack(Properties properties)
                        throws PeerUnavailableException {
                try {
                        // create parameters argument to identify constructor
                        Class[] paramTypes = new Class[1];
                        paramTypes[0] = Class.forName("java.util.Properties");
                        // get constructor of SipStack in order to instantiate
                        Constructor sipStackConstructor = Class.forName(
                                        getPathName() + 
".javax.sip.SipStackImpl").getConstructor(
                                        paramTypes);
                        // Wrap properties object in order to pass to 
constructor of
                        // SipSatck
                        Object[] conArgs = new Object[1];
                        conArgs[0] = properties;
                        // Creates a new instance of SipStack Class with the 
supplied
                        // properties.
SipStack sipStack = (SipStack) sipStackConstructor.newInstance(conArgs);
                        sipStackList.add(sipStack);
                        String name = 
properties.getProperty("javax.sip.STACK_NAME");
                        this.sipStackByName.put(name, sipStack);
                       return sipStack;
                } catch (Exception e) {
                        String errmsg = "The Peer SIP Stack: "
                                        + getPathName()
                                        + ".javax.sip.SipStackImpl"
+ " could not be instantiated. Ensure the Path Name has been set.";
                        throw new PeerUnavailableException(errmsg, e);
                }
        }


-----
Industrial Technology Research Institute
Rm. 226 Bldg. 14, 2F, 195, Sec. 4, Chung Hsing Rd.,
Chutung, Hsinchu, Taiwan 31040, R.O.C.
--
View this message in context: 
http://servicemix.396122.n5.nabble.com/Problem-when-developing-sip-binding-component-tp4468146p4468146.html
Sent from the ServiceMix - Dev mailing list archive at Nabble.com.

---------------------------------------------
Freeman Fang

FuseSource
Email:[email protected]
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com









Reply via email to