Missing javax.sip.STACK_NAME property and gov.nist.javax.sip.SipStackImpl could not be instantiated in Java

754 Views Asked by At

I want to connect to sip server on a different server, register and then search the form.

I am trying to register on a Java form using Jain-Sip framework. However, in a more basic setting, I encountered an error when creating a Sip Stack, and I can not pass it.

I use the Maven Infrastructure to build the application

  • jain-sdp-1.0.1111.jar
  • jain-sdp-src-1.0.1111.jar
  • jain-sip-api-1.2.jar
  • jain-sip-api-1.2-src.jar
  • jain-sip-ri-1.2.1111.jar
  • jain-sip-sdp-1.2.1111.jar
  • jain-sip-src-1.2.1111.jar
  • jain-sip-tck-1.2.1111.jar
  • jain-sip-unit-test-1.2.1111.
  • log4j-1.2.17.jar

I added the libraries. The names of the files in the library sometimes start with javax.sip sometimes gov.nist.javax.

At the opening of the form I took the sip factor instance and entered the properties. Specifically, when I enter STACK_NAME as below, or as simplex javax.sip,

this.properties.put ("javax.sip.STACK_NAME", "Phone");
 this.properties.setProperty ("gov.nist.javax.sip.STACK_NAME", "Phone");

Error comparing to "javax.sip.PeerUnavailableException: The Peer SIP Stack: javax.sip.javax.sip.SipStackImpl could not be instantiated.

When I enter only gov.nist, it gives "Missing javax.sip.STACK_NAME property" error.

If I just leave javax.SipStackNmae, I get a "Can not asign request address: Connot bind" error when I enter ip port and transport information in Listining point.

I checked the ports for this error. I shut down applications that use the same port for port overlap. But it has not improved yet. This error is caused by the ip address where the server is located. 5060 port can not send connection request continuously.

     private void onOpen(java.awt.event.WindowEvent evt) {                        

    try {
        // Get the local IP address.
        this.ip = "185.224.184.100";
        // Create the SIP factory and set the path name.
        this.sipFactory = SipFactory.getInstance();
        this.sipFactory.setPathName("gov.nist");
        // Create and set the SIP stack properties.
        this.properties = new Properties();

        this.properties.put("javax.sip.STACK_NAME", "Mobicents-SIP-Servlets");
        this.properties.setProperty("javax.sip.TRACE_LEVEL", "32");
        //this.properties.setProperty("gov.nist.javax.sip.STACK_NAME", "Mobicents-SIP-Servlets");
        this.properties.setProperty("javax.sip.IP_ADDRESS", this.ip); 
        this.properties.setProperty("javax.sip.MAX_MESSAGE_SIZE", "1048576");
        this.properties.setProperty("javax.sip.DEBUG_LOG", "xDebug.txt");
        this.properties.setProperty("javax.sip.SERVER_LOG", "xLog.txt");

        // Drop the client connection after we are done with the transaction.
        this.properties.setProperty("javax.sip.CACHE_CLIENT_CONNECTIONS", "false");

        this.properties.setProperty("javax.sip.LOG_MESSAGE_CONTENT", "true");

        this.properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "off");
        this.properties.setProperty("javax.sip.DELIVER_UNSOLICITED_NOTIFY", "true");
        this.properties.setProperty("javax.sip.THREAD_POOL_SIZE", "64");
        this.properties.setProperty("javax.sip.REENTRANT_LISTENER", "true");
        this.properties.setProperty("javax.sip.MAX_FORK_TIME_SECONDS", "0 ");
        this.properties.setProperty("javax.sip.AUTOMATIC_DIALOG_ERROR_HANDLING", "false");

        sipStack = sipFactory.createSipStack(properties);
        System.out.println("sipStack = " + sipStack);

        // Create the SIP stack.
        this.sipStack = this.sipFactory.createSipStack(this.properties);
        // Create the SIP message factory.
        this.messageFactory = this.sipFactory.createMessageFactory();
        // Create the SIP header factory.
        this.headerFactory = this.sipFactory.createHeaderFactory();
        // Create the SIP address factory.
        this.addressFactory = this.sipFactory.createAddressFactory();
        // Create the SIP listening point and bind it to the local IP address, port and protocol.
        this.listeningPoint = this.sipStack.createListeningPoint(this.ip, this.port, this.protocol);
        // Create the SIP provider.
        this.sipProvider = this.sipStack.createSipProvider(this.listeningPoint);
        // Add our application as a SIP listener.
        this.sipProvider.addSipListener(this);
        // Create the contact address used for all SIP messages.
        this.contactAddress = this.addressFactory.createAddress("sip:" + this.ip + ":" + this.port);
        // Create the contact header used for all SIP messages.
        this.contactHeader = this.headerFactory.createContactHeader(contactAddress);

        // Display the local IP address and port in the text area.
        this.textArea.append("Local address: " + this.ip + ":" + this.port + "\n");
    } catch (ParseException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    } catch (TooManyListenersException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    } catch (InvalidArgumentException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    } catch (ObjectInUseException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    } catch (PeerUnavailableException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    } catch (TransportNotSupportedException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    }
}                       

private void onRegisterStateless(java.awt.event.ActionEvent evt) {                                     
    // A method called when you click on the "Reg (SL)" button.
    try {
        // Get the destination address from the text field.
        Address addressTo = this.addressFactory.createAddress(this.textField.getText());
        // Create the request URI for the SIP message.
        javax.sip.address.URI requestURI = addressTo.getURI();

        // Create the SIP message headers.
        // The "Via" headers.
        ArrayList viaHeaders = new ArrayList();
        ViaHeader viaHeader = this.headerFactory.createViaHeader(this.ip, this.port, "udp", null);
        viaHeaders.add(viaHeader);
        // The "Max-Forwards" header.
        MaxForwardsHeader maxForwardsHeader = this.headerFactory.createMaxForwardsHeader(70);
        // The "Call-Id" header.
        CallIdHeader callIdHeader = this.sipProvider.getNewCallId();
        // The "CSeq" header.
        // CSeqHeader cSeqHeader = this.headerFactory.createCSeqHeader(1L, "REGISTER");
        CSeqHeader cSeqHeader = this.headerFactory.createCSeqHeader(1L, Request.MESSAGE);

        // The "From" header.
        FromHeader fromHeader = this.headerFactory.createFromHeader(this.contactAddress, String.valueOf(this.tag));
        // The "To" header.
        ToHeader toHeader = this.headerFactory.createToHeader(addressTo, null);

        // Create the REGISTER request.
        Request request = this.messageFactory.createRequest(
                requestURI,
                "REGISTER",
                callIdHeader,
                cSeqHeader,
                fromHeader,
                toHeader,
                viaHeaders,
                maxForwardsHeader);
        // Add the "Contact" header to the request.
        request.addHeader(contactHeader);

        // Send the request statelessly through the SIP provider.
        this.sipProvider.sendRequest(request);

        // Display the message in the text area.
        this.textArea.append(
                "Request sent:\n" + request.toString() + "\n\n");
    } catch (ParseException e) {
        // If an error occurred, display the error.
        this.textArea.append("Request sent failed: " + e.getMessage() + "\n");
    } catch (InvalidArgumentException e) {
        // If an error occurred, display the error.
        this.textArea.append("Request sent failed: " + e.getMessage() + "\n");
    } catch (SipException ex) {
        JOptionPane.showMessageDialog(null, ex.getMessage());
    }
    // If an error occurred, display the error.

}     

What is the reason for this confrontation? How can I resolve it?

0

There are 0 best solutions below