Skip to main content

error sending message to sip server

2 replies [Last post]
johnnyblaze69
Offline
Joined: 2008-04-02

can anyone help, im getting the following error when i try to send a message to my sip server:

Exception in thread "Thread-4" java.lang.NoSuchMethodError: javax.sip.RequestEvent.(Ljava/lang/Object;Ljavax/sip/ServerTransaction;Ljavax/sip/message/Request;)V
at gov.nist.javax.sip.NistSipMessageHandlerImpl.processRequest(NistSipMessageHandlerImpl.java:451)
at gov.nist.javax.sip.stack.SIPServerTransaction.processRequest(SIPServerTransaction.java:557)
at gov.nist.javax.sip.stack.UDPMessageChannel.run(UDPMessageChannel.java:422)
at java.lang.Thread.run(Thread.java:619)

im only sending a string so it should be fairly basic, has anyone come across a similar problem?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
eduardomartins
Offline
Joined: 2005-10-10

code you are using please?

johnnyblaze69
Offline
Joined: 2008-04-02

here is the server code i am using:

import javax.sip.*;
import javax.sip.address.*;
import javax.sip.header.*;
import javax.sip.message.*;
import javax.sip.SipStack;

import javax.swing.*;
import java.util.*;
import java.io.*;
import java.net.*;

public class SipServer implements SipListener
{
private static AddressFactory addressFactory;
private static MessageFactory messageFactory;
private static HeaderFactory headerFactory;
private static SipStack sipStack;

protected ServerTransaction inviteTid;

public void processRequest(RequestEvent requestEvent)
{
Request request = requestEvent.getRequest();
ServerTransaction serverTransactionId = requestEvent.getServerTransaction();

if (request.getMethod().equals(Request.INVITE))
{
processInvite(requestEvent, serverTransactionId);
}
else if (request.getMethod().equals(Request.ACK))
{
processAck(requestEvent, serverTransactionId);
}
else if (request.getMethod().equals(Request.BYE))
{
processBye(requestEvent,serverTransactionId);
}
}

//process ack request.
public void processAck(RequestEvent requestEvent, ServerTransaction serverTransaction)
{
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
try
{
System.out.println("ACK Received -- sending bye ");
Dialog dialog = inviteTid.getDialog();
Request byeRequest = dialog.createRequest(Request.BYE);
ClientTransaction tr = sipProvider.getNewClientTransaction(byeRequest);
dialog.sendRequest(tr);
}
catch (Exception ex)
{
ex.printStackTrace();
System.exit(0);
}
}

//process invite request.
public void processInvite(RequestEvent requestEvent, ServerTransaction serverTransaction)
{
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();

try
{
System.out.println("Invite Received -- sending OK");
System.out.println("server: " + request );

Response response = messageFactory.createResponse(200,request);
ToHeader toHeader = (ToHeader)response.getHeader(ToHeader.NAME);
toHeader.setTag("4321"); // Application is supposed to set.

Address address = addressFactory.createAddress("");
ContactHeader contactHeader = headerFactory.createContactHeader(address);

response.addHeader(contactHeader);
ServerTransaction st = sipProvider.getNewServerTransaction(request);
System.out.println("got a server tranasaction " + st);
byte[] content = request.getRawContent();
System.out.println("Content = " + new String(content));
//insert db code here
ContentTypeHeader contentTypeHeader = headerFactory.createContentTypeHeader("application", "sdp");
response.setContent(content,contentTypeHeader);

Dialog dialog = st.getDialog();

if (dialog != null)
System.out.println("Dialog state " + dialog.getState());

st.sendResponse(response);
this.inviteTid = st;
}
catch (Exception ex)
{
ex.printStackTrace();
System.exit(0);
}
}

//Process the bye request.
public void processBye(RequestEvent requestEvent, ServerTransaction serverTransactionId )
{
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();

try
{
System.out.println("BYE Received -- sending OK.");
Response response = messageFactory.createResponse(200,request,null,null);
serverTransactionId.sendResponse(response);
}
catch (Exception ex)
{
ex.printStackTrace();
System.exit(0);
}
}

public void processResponse(ResponseEvent responseReceivedEvent)
{
System.out.println("Got a response");
Response response = (Response)responseReceivedEvent.getResponse();
Transaction tid = responseReceivedEvent.getClientTransaction();

System.out.println("Response received with client transaction id " + tid + ":\n" + response);

try
{
if (response.getStatusCode() == Response.OK && ((CSeqHeader)response.getHeader(CSeqHeader.NAME)).getMethod().equals(Request.INVITE))
{
if (tid != this.inviteTid)
{
new Exception().printStackTrace();
System.exit(0);
}

Dialog dialog = tid.getDialog();
// Save the tags for the dialog here.
Request request = tid.getRequest();
dialog.sendAck(request);
}
}
catch (SipException ex)
{
ex.printStackTrace();
System.exit(0);
}
}

public void processTimeout(TimeoutEvent timeoutEvent)
{
System.out.println("Transaction Timed out");
}

public static void main(String args[])
{
SipFactory sipFactory = null;
sipStack = null;
sipFactory = SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
Properties properties = new Properties();
properties.setProperty("javax.sip.IP_ADDRESS","127.0.0.1");
properties.setProperty("javax.sip.RETRANSMISSION_FILTER", "true");
properties.setProperty("javax.sip.STACK_NAME", "server");
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "serverdebug.txt");
properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "serverlog.txt");

try
{
// Create SipStack object
sipStack = sipFactory.createSipStack(properties);
}
catch(PeerUnavailableException e)
{
// could not find gov.nist.jain.protocol.ip.sip.SipStackImpl in the classpath
System.out.println("could not find gov.nist.jain.protocol.ip.sip.SipStackImpl in the classpath");
e.printStackTrace();
System.err.println(e.getMessage());

if (e.getCause() != null) e.getCause().printStackTrace();
System.exit(0);
}

try
{
headerFactory = sipFactory.createHeaderFactory();
addressFactory = sipFactory.createAddressFactory();
messageFactory = sipFactory.createMessageFactory();
ListeningPoint lp = sipStack.createListeningPoint (5060,"udp");

SipServer listener = new SipServer();

SipProvider sipProvider = sipStack.createSipProvider(lp);
sipProvider.addSipListener(listener);

}
catch (Exception ex)
{
System.out.println(ex.getMessage());
ex.printStackTrace();
}
}

/* public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent)
{

}

public void processTransactionTerminated(TransactionTerminatedEvent transactionTerminatedEvent)
{

}

public void processIOException(IOExceptionEvent exceptionEvent)
{

}*/
}

Message was edited by: johnnyblaze69