Error in code: Urgent, Please help, thanks alot
I'm getting two errors with the following code. The code is supposed to read in a text file with the format
11
blue casual
green athletic
red athletic
The first number represents the numbers of socks. The code is supposed to ouput the number of pairs, so if there were 2 red athletic , it would say
1 matching pair
1 pair of red athletic
If possible can someone run my code to see if they can get it to output that, I'm having a hard time doing it.
here is the code
import java.io.*;
public class Socks {
public static void main(String args[])
try
String socks[1000];
int pairs[500];
int numOfsocks;
int i;
int j;
FileReader fr = new FileReader("test.txt");
BufferedReader inFile = new BufferedReader(fr);
numOfsocks = Integer.parseInt(inFile.readLine());
int possiblePairs = numOfsocks/2;
for(i = 0; i < numOfsocks; i++)
socks[i] = inFile.readLine();
for(i = 0; i <= possiblePairs;i++)
for(j = i; j<=possiblePairs;j++)
if (socks.equalsIgnoreCase(socks[j]))
pairs[i] = i++;
for(i = 0; i <= possiblePairs;i++);
if(pairs[i] >= 2)
System.out.println(pairs[i]/2 + " pairs" + socks[i]);
inFile.close();
catch(IOException e){}
System.out.println("File Not Found or no File Specified");
--------------------Configuration: Socks - JDK version 1.3.1_04 <Default>--------------------
C:\Socks\Socks.java:13: ']' expected
String socks[1000];
^
C:\Socks\Socks.java:14: ']' expected
int pairs[500];
^
2 errors
consider the following
not for copying
but for studying working code
to help clarify ideas
import java.io.*;
list items and count of each item
in a list of socks
file has list of socks ...
4
red sock
green sock
blue sock
green sock
the first line is n = count of socks
if no socks match, there are n items
for example : 3 items in ...
3
red sock
blue sock
green sock
if all socks match there is one item
for example : 1 item in ...
3
red sock
red sock
red sock
if socks come in pairs, there are at most n/2 items
for example : 2 items in ...
4
red sock
green sock
red sock
green sock
program does not assume that socks come in pairs !!
public class Socks {
public static void main(String args[]) throws IOException
String[] socks = new String[1000];
int numOfsocks;
String[] item = new String[1000];
int[] count = new int[1000]; // initializes each count to zero
int totalcount = 0;
int i;
int j;
boolean ifound;
FileReader fr = new FileReader("test.txt");
BufferedReader inFile = new BufferedReader(fr);
numOfsocks = Integer.parseInt(inFile.readLine());
for (i = 0; i < numOfsocks; i++)
socks[ i ] = inFile.readLine();
inFile.close();
for (i = 0; i < numOfsocks; i++) {
ifound = false;
for (j = 0; j < totalcount; j++) {
if (socks[ i ].equalsIgnoreCase(item[j])) {
ifound = true;
count[j]++; // increase count for matched item
break; // exit "for j loop"
} // for j
// sock not found so add it to item list ...
if (ifound == false) {
item[totalcount] = socks[ i ];
count[totalcount] = 1;
totalcount++;
} // for i
for (i = 0; i < totalcount; i++)
System.out.println (item[ i ] + ", count = " + count[ i ]);
} // class
Similar Messages
-
Hi.my itunes appear this error ERROE CODE:1009 please help me
hi.my itunes appear this error ERROE CODE:1009 please help me
Read my post. I don't know if you're having the same problem but I hope this helps. http://discussions.apple.com/thread.jspa?threadID=1351705&tstart=0
Message was edited by: Happyfish -
Logical error in code, please help, thanks alot.
I have this file Socks.java which reads in a file containing information about a sock drawer. The file is of the format:
11
red athletic
green casual
blue athletic
blue athletic
red athletic
so when the program runs, it is supposed to output the socks that are pairs: so it would output
1 pair red athletic
1 pair blue athletic
my code compiles and runs fine and i am testing it with println statements, but I am not getting the desired ouput. Can someone look over it and see if they spot what is wrong. Right now in the code I am seeing what the value of socks[i] and socks[j] is by printing them out as you will notice. If anyone can help, I appreciate it. Thanks so much for all your wonderful help
Here is the code:
import java.io.*;
public class Socks {
public static void main(String args[])
try
String socks[] = new String[1000];
int pairs[] = new int[500];
int numOfsocks;
int i;
int j;
FileReader fr = new FileReader("test.txt");
BufferedReader inFile = new BufferedReader(fr);
numOfsocks = Integer.parseInt(inFile.readLine());
int possiblePairs = numOfsocks/2;
//System.out.println(numOfsocks);
//System.out.println(possiblePairs);
for(i = 0; i < numOfsocks; i++)
socks[i] = inFile.readLine();
//for(i = 0; i < numOfsocks; i++)
//System.out.println(socks);
for(i = 0; i <= possiblePairs;i++)
for(j = i; j <= possiblePairs;j++)
System.out.println(socks[i]);
System.out.println(socks[j]);
//if(pairs[i] >= 2)
//System.out.println(pairs[i]/2 + " pairs" + socks[i]);
inFile.close();
catch(IOException e){}
System.out.println("File Not Found or no File Specified");Try the following quickly revised version of your code.
import java.io.*;
public class Socks {
public static void main(String args[])
try
String socks[] = new String[1000];
int pairs[] = new int[500];
int numOfsocks;
int i;
int j;
FileReader fr = new FileReader("test.txt");
BufferedReader inFile = new BufferedReader(fr);
numOfsocks = Integer.parseInt(inFile.readLine());
for(i = 0; i < numOfsocks; i++)
socks[i] = inFile.readLine();
for(i = 0; i < numOfsocks; i++)
if (socks[i] != null)
pairs[i]++;
for(j = i + 1; j < numOfsocks; j++)
if (socks.equals(socks[j]))
pairs[i]++;
socks[j] = null;
System.out.println(pairs[i]/2 + " pairs " + socks[i]);
inFile.close();
catch(IOException e){
e.printStackTrace(); -
Error FRM-41056, Urgent, Please help.
Hi All,
I am doing validation in post-change trigger of a item. When i am chaning any thing in the item it is fine, but when i am query it from key_block at that time the error message "FRM-41056, Can find the Block: Invalid Id" populating. If i am commented that validation code the form is working fine without validation but there is no error message.
Can any body help why it is happing and solution for this? Please suggest , it is urgent.
Thanks
RadhaPrevious code
====================
begin
G$_CHECK_QUERY_MODE;
g$_sel_spriden_pidm_name(:fpbpohd_block.DISPLAY_VEND_CODE, 'DISPLAY_VEND_NAME', 'Y', :HOLD_VEND_PIDM);
:GLOBAL.QUERY_MODE := '0';
EXCEPTION
WHEN FORM_TRIGGER_FAILURE THEN
:GLOBAL.QUERY_MODE := '0';
RAISE FORM_TRIGGER_FAILURE;
END;
New Code
================
DECLARE
cursor pti_cursor is
select ftvvend_disc_code, ftvvend_atyp_code
from ftvvend
where ftvvend_eff_date <= sysdate
and (ftvvend_term_date > sysdate
or ftvvend_term_date is null)
and ftvvend_pidm = :hold_vend_pidm;
TEMP_FTVVEND_DISC_CODE varchar2(30);
TEMP_FTVVEND_ATYP_CODE varchar2(30);
BEGIN
G$_CHECK_QUERY_MODE;
g$_sel_spriden_pidm_name(:fpbpohd_block.DISPLAY_VEND_CODE, 'DISPLAY_VEND_NAME', 'Y', :HOLD_VEND_PIDM);
OPEN PTI_CURSOR;
FETCH PTI_CURSOR INTO TEMP_FTVVEND_DISC_CODE, TEMP_FTVVEND_ATYP_CODE;
IF PTI_CURSOR%NOTFOUND THEN
MESSAGE('Vendor is Invalid');
RAISE FORM_TRIGGER_FAILURE;
end if;
CLOSE PTI_CURSOR;
:GLOBAL.QUERY_MODE := '0';
EXCEPTION
WHEN FORM_TRIGGER_FAILURE THEN
:GLOBAL.QUERY_MODE := '0';
RAISE FORM_TRIGGER_FAILURE;
END; -
Error in code..please help
Hi,
I'm writing a SIP messaging klient and i am having problem with connecting the client to my SIP-server (OpenSER)
javax.sip.InvalidArgumentException: 300:[email protected]: 300:[email protected]
at gov.nist.javax.sip.SipStackImpl.createListeningPoint(SipStackImpl.java:645)
at sipTrade.createProvider(sip.java:274)
at sipTrade.main(sip.java:299)
Caused by: java.net.UnknownHostException: 300:[email protected]: 300:[email protected]
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at gov.nist.javax.sip.SipStackImpl.createListeningPoint(SipStackImpl.java:625)
... 2 more
import java.io.*;
import javax.sip.*;
import javax.sip.address.*;
import javax.sip.header.*;
import javax.sip.message.*;
import java.util.*;
public class sip implements SipListener {
private static AddressFactory addressFactory;
private static MessageFactory messageFactory;
private static HeaderFactory headerFactory;
private static SipStack sipStack;
private int port;
protected SipProvider udpProvider;
protected Dialog dialog;
protected int notifyCount = 0;
protected final String serverIP = "300:[email protected]";
class MyEventSource implements Runnable {
private sipTrade st;
private EventHeader eventHeader;
public MyEventSource(sipTrade notifier, EventHeader eventHeader ) {
this.st = notifier;
this.eventHeader = eventHeader;
public void run() {
try {
for (int i = 0; i < 100; i++) {
Thread.sleep(100);
Request request = this.st.dialog.createRequest(Request.NOTIFY);
SubscriptionStateHeader subscriptionState = headerFactory.createSubscriptionStateHeader(SubscriptionStateHeader.ACTIVE);
request.addHeader(subscriptionState);
request.addHeader(eventHeader);
// Lets mark our Contact
((SipURI)dialog.getLocalParty().getURI()).setParameter("id","not2");
ClientTransaction ct = udpProvider.getNewClientTransaction(request);
System.out.println("NOTIFY Branch ID "+((ViaHeader)request.getHeader(ViaHeader.NAME)).getParameter("branch"));
this.st.dialog.sendRequest(ct);
System.out.println("Dialog " + dialog);
System.out.println("Dialog state after active NOTIFY: " + dialog.getState());
synchronized (sipTrade.this) {
notifyCount ++;
} catch (Throwable e) {
e.printStackTrace();
private static void usage() {
System.exit(0);
public void processRequest(RequestEvent requestEvent) {
Request request = requestEvent.getRequest();
ServerTransaction serverTransactionId = requestEvent.getServerTransaction();
System.out.println("\n\nRequest " + request.getMethod()+" received at " + sipStack.getStackName()+" with server transaction id " + serverTransactionId+" and dialog id "+requestEvent.getDialog());
if (request.getMethod().equals(Request.SUBSCRIBE)) {
processSubscribe(requestEvent, serverTransactionId);
* Process the invite request.
public void processSubscribe(RequestEvent requestEvent,
ServerTransaction serverTransaction) {
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
try {
System.out.println("notifier: got an Subscribe sending OK");
System.out.println("notifier: " + request);
System.out.println("notifier : dialog = " + requestEvent.getDialog());
EventHeader eventHeader = (EventHeader) request.getHeader(EventHeader.NAME);
if ( eventHeader == null) {
System.out.println("Cannot find event header.... dropping request.");
return;
// Always create a ServerTransaction, best as early as possible in the code
Response response = null;
ServerTransaction st = requestEvent.getServerTransaction();
if (st == null) {
st = sipProvider.getNewServerTransaction(request);
// Check if it is an initial SUBSCRIBE or a refresh / unsubscribe
boolean isInitial = requestEvent.getDialog() == null;
if ( isInitial ) {
// need random tags to test forking
String toTag = Integer.toHexString( (int) (Math.random() * Integer.MAX_VALUE) );
response = messageFactory.createResponse(202, request);
ToHeader toHeader = (ToHeader) response.getHeader(ToHeader.NAME);
// Sanity check: to header should not ahve a tag. Else the dialog
// should have matched
if (toHeader.getTag()!=null) {
System.err.println( "####ERROR: To-tag!=null but no dialog match! My dialog=" + dialog.getState() );
toHeader.setTag(toTag); // Application is supposed to set.
this.dialog = st.getDialog();
// subscribe dialogs do not terminate on bye.
this.dialog.terminateOnBye(false);
if (dialog != null) {
System.out.println("Dialog " + dialog);
System.out.println("Dialog state " + dialog.getState());
} else {
response = messageFactory.createResponse(200, request);
// Both 2xx response need a Contact
Address address = addressFactory.createAddress("xTrade <sip:127.0.0.1>");
((SipURI)address.getURI()).setPort( udpProvider.getListeningPoint("udp").getPort() );
ContactHeader contactHeader = headerFactory.createContactHeader(address);
response.addHeader(contactHeader);
// Expires header is mandatory in 2xx responses to SUBSCRIBE
ExpiresHeader expires = (ExpiresHeader) request.getHeader( ExpiresHeader.NAME );
if (expires==null) {
expires = headerFactory.createExpiresHeader(30); // rather short
response.addHeader( expires );
st.sendResponse(response);
* NOTIFY requests MUST contain a "Subscription-State" header with a
* value of "active", "pending", or "terminated". The "active" value
* indicates that the subscription has been accepted and has been
* authorized (in most cases; see section 5.2.). The "pending" value
* indicates that the subscription has been received, but that
* policy information is insufficient to accept or deny the
* subscription at this time. The "terminated" value indicates that
* the subscription is not active.
Request notifyRequest = dialog.createRequest( "NOTIFY" );
// Mark the contact header, to check that the remote contact is updated
((SipURI)contactHeader.getAddress().getURI()).setParameter("id","not");
// Initial state is pending, second time we assume terminated (Expires==0)
SubscriptionStateHeader sstate = headerFactory.createSubscriptionStateHeader(
isInitial ? SubscriptionStateHeader.PENDING : SubscriptionStateHeader.TERMINATED );
// Need a reason for terminated
if ( sstate.getState().equalsIgnoreCase("terminated") ) {
sstate.setReasonCode( "deactivated" );
notifyRequest.addHeader(sstate);
notifyRequest.setHeader(eventHeader);
notifyRequest.setHeader(contactHeader);
// notifyRequest.setHeader(routeHeader);
ClientTransaction ct = udpProvider.getNewClientTransaction(notifyRequest);
// Let the other side know that the tx is pending acceptance
dialog.sendRequest(ct);
System.out.println("NOTIFY Branch ID " +
((ViaHeader)request.getHeader(ViaHeader.NAME)).getParameter("branch"));
System.out.println("Dialog " + dialog);
System.out.println("Dialog state after pending NOTIFY: " + dialog.getState());
if (isInitial) {
Thread myEventSource = new Thread(new MyEventSource(this,eventHeader));
myEventSource.start();
} catch (Throwable ex) {
ex.printStackTrace();
// System.exit(0);
public synchronized void processResponse(ResponseEvent responseReceivedEvent) {
Response response = (Response) responseReceivedEvent.getResponse();
Transaction tid = responseReceivedEvent.getClientTransaction();
if ( response.getStatusCode() != 200 ) {
this.notifyCount --;
} else {
System.out.println("Notify Count = " + this.notifyCount);
public void processTimeout(javax.sip.TimeoutEvent timeoutEvent) {
Transaction transaction;
if (timeoutEvent.isServerTransaction()) {
transaction = timeoutEvent.getServerTransaction();
} else {
transaction = timeoutEvent.getClientTransaction();
System.out.println("state = " + transaction.getState());
System.out.println("dialog = " + transaction.getDialog());
System.out.println("dialogState = "
+ transaction.getDialog().getState());
System.out.println("Transaction Time out");
private static void initFactories ( int port ) throws Exception {
SipFactory sipFactory = SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
Properties properties = new Properties();
properties.setProperty("javax.sip.STACK_NAME", "notifier" + port );
// You need 16 for logging traces. 32 for debug + traces.
// Your code will limp at 32 but it is best for debugging.
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
properties.setProperty("gov.nist.javax.sip.DEBUG_LOG",
"notifierdebug_"+port+".txt");
properties.setProperty("gov.nist.javax.sip.SERVER_LOG",
"notifierlog_"+port+".txt");
try {
// Create SipStack object
sipStack = sipFactory.createSipStack(properties);
System.out.println("sipStack = " + sipStack);
} catch (PeerUnavailableException e) {
// 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();
} catch (Exception ex) {
ex.printStackTrace();
System.exit(0);
public void createProvider() {
try {
ListeningPoint lp = sipStack.createListeningPoint(this.serverIP, this.port, "udp");
this.udpProvider = sipStack.createSipProvider(lp);
System.out.println("udp provider " + udpProvider);
} catch (Exception ex) {
System.out.println((ex.getMessage()));
ex.printStackTrace();
usage();
public sipTrade( int port ) {
this.port = port;
public sipTrade(){
public static void main(String args[]) throws Exception {
int port = args.length > 0 ? Integer.parseInt(args[0]) : 5060;
initFactories( port );
sipTrade notifier = new sipTrade( port );
notifier.createProvider( );
notifier.udpProvider.addSipListener(notifier);
//sipTrade st = new sipTrade();
//st.Send2xTrade("198202050897", "testdata");
//st.getXTmsg(0);
public void processIOException(IOExceptionEvent exceptionEvent) {
public void processTransactionTerminated(
TransactionTerminatedEvent transactionTerminatedEvent) {
public void processDialogTerminated(
DialogTerminatedEvent dialogTerminatedEvent) {
// TODO Auto-generated method stub
* Xtrade connection - DATA IN
public void Send2xTrade(String data, String info) {
try{
IServer is = ServerFactory.createObject(ip);
is.logOn(clientName_in, SessionType.LogOnRxTx);
is.sendMsg(contract_in,MsgPriority.Def, data.getBytes(), info);
is.logOff();
catch (Exception e){
e.printStackTrace();
System.err.println(e.getMessage());
public void getXTmsg(int xtMsgAck){
IMsg msg; // A single xTrade message
MsgInfo msgInfo = null; // Message information
byte[] theData;
try {
IServer is = ServerFactory.createObject(ip);
is.logOn(clientName_out, SessionType.LogOnRxTx);
msg = is.createNextRxMsg(contract_out);
FileOutputStream myStream = new FileOutputStream("rx" + msg.getHandle() + ".msg"); // Create the stream
msg.getData(myStream);
myStream.close();
if(msgInfo.getAcknowledge() == false){
msg.setReceived();
else if(msgInfo.getAcknowledge() == true && xtMsgAck == 0){
msg.setReceived();
msg.setAck();
else if(msgInfo.getAcknowledge() == true && xtMsgAck == 1){
msg.setReceived();
msg.setNack();
is.logOff();
}catch (XTException e){
catch(Exception e){
}Made som more fixes:
sipStack = gov.nist.javax.sip.SipStackImpl@e24e2a
sipStack = gov.nist.javax.sip.SipStackImpl@e24e2a
SipProviders: java.util.LinkedList$ListItr@1a73d3c
AddressFactory: class gov.nist.javax.sip.address.AddressFactoryImpl
InvalidArgumentException Cannot assign requested address: Cannot bindjavax.sip.InvalidArgumentException: Cannot assign requested address: Cannot bind
at gov.nist.javax.sip.SipStackImpl.createListeningPoint(SipStackImpl.java:645)
at sipClient.createProvider(sipClient.java:267)
at sipClient.main(sipClient.java:302)
Caused by: java.io.IOException: Cannot assign requested address: Cannot bind
at gov.nist.javax.sip.stack.UDPMessageProcessor.<init>(UDPMessageProcessor.java:135)
at gov.nist.javax.sip.stack.SIPTransactionStack.createMessageProcessor(SIPTransactionStack.java:1652)
at gov.nist.javax.sip.SipStackImpl.createListeningPoint(SipStackImpl.java:626)
... 2 more
Exception in thread "main" java.lang.NullPointerException
at sipClient.main(sipClient.java:303)
import java.io.*;
import javax.sip.*;
import javax.sip.address.*;
import javax.sip.header.*;
import javax.sip.message.*;
import java.util.*;
public class sipClient implements SipListener {
private static AddressFactory addressFactory;
private static MessageFactory messageFactory;
private static HeaderFactory headerFactory;
private static Address address;
private static SipStack sipStack;
private int port;
protected SipProvider udpProvider;
protected Dialog dialog;
protected int notifyCount = 0;
public static final int PORT_5060 = 5070;
protected final String serverIP = "192.168.1.99";
class MyEventSource implements Runnable {
private sipClient st;
private EventHeader eventHeader;
public MyEventSource(sipClient notifier, EventHeader eventHeader ) {
this.st = notifier;
this.eventHeader = eventHeader;
public void run() {
try {
for (int i = 0; i < 100; i++) {
Thread.sleep(100);
Request request = this.st.dialog.createRequest(Request.NOTIFY);
SubscriptionStateHeader subscriptionState = headerFactory.createSubscriptionStateHeader(SubscriptionStateHeader.ACTIVE);
request.addHeader(subscriptionState);
request.addHeader(eventHeader);
// Lets mark our Contact
((SipURI)dialog.getLocalParty().getURI()).setParameter("id","not2");
ClientTransaction ct = udpProvider.getNewClientTransaction(request);
System.out.println("NOTIFY Branch ID "+((ViaHeader)request.getHeader(ViaHeader.NAME)).getParameter("branch"));
this.st.dialog.sendRequest(ct);
System.out.println("Dialog " + dialog);
System.out.println("Dialog state after active NOTIFY: " + dialog.getState());
synchronized (sipClient.this) {
notifyCount ++;
} catch (Throwable e) {
e.printStackTrace();
private static void usage() {
System.exit(0);
public void processRequest(RequestEvent requestEvent) {
Request request = requestEvent.getRequest();
ServerTransaction serverTransactionId = requestEvent.getServerTransaction();
System.out.println("\n\nRequest " + request.getMethod()+" received at " + sipStack.getStackName()+" with server transaction id " + serverTransactionId+" and dialog id "+requestEvent.getDialog());
if (request.getMethod().equals(Request.SUBSCRIBE)) {
processSubscribe(requestEvent, serverTransactionId);
* Process the invite request.
public void processSubscribe(RequestEvent requestEvent,
ServerTransaction serverTransaction) {
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
try {
System.out.println("notifier: got an Subscribe sending OK");
System.out.println("notifier: " + request);
System.out.println("notifier : dialog = " + requestEvent.getDialog());
EventHeader eventHeader = (EventHeader) request.getHeader(EventHeader.NAME);
if ( eventHeader == null) {
System.out.println("Cannot find event header.... dropping request.");
return;
// Always create a ServerTransaction, best as early as possible in the code
Response response = null;
ServerTransaction st = requestEvent.getServerTransaction();
if (st == null) {
st = sipProvider.getNewServerTransaction(request);
// Check if it is an initial SUBSCRIBE or a refresh / unsubscribe
boolean isInitial = requestEvent.getDialog() == null;
if ( isInitial ) {
// need random tags to test forking
String toTag = Integer.toHexString( (int) (Math.random() * Integer.MAX_VALUE) );
response = messageFactory.createResponse(202, request);
ToHeader toHeader = (ToHeader) response.getHeader(ToHeader.NAME);
// Sanity check: to header should not ahve a tag. Else the dialog
// should have matched
if (toHeader.getTag()!=null) {
System.err.println( "####ERROR: To-tag!=null but no dialog match! My dialog=" + dialog.getState() );
toHeader.setTag(toTag); // Application is supposed to set.
this.dialog = st.getDialog();
// subscribe dialogs do not terminate on bye.
this.dialog.terminateOnBye(false);
if (dialog != null) {
System.out.println("Dialog " + dialog);
System.out.println("Dialog state " + dialog.getState());
} else {
response = messageFactory.createResponse(200, request);
// Both 2xx response need a Contact
address = addressFactory.createAddress("xTrade <sip:192.168.1.99>");
((SipURI)address.getURI()).setPort( udpProvider.getListeningPoint("udp").getPort() );
ContactHeader contactHeader = headerFactory.createContactHeader(address);
response.addHeader(contactHeader);
// Expires header is mandatory in 2xx responses to SUBSCRIBE
ExpiresHeader expires = (ExpiresHeader) request.getHeader( ExpiresHeader.NAME );
if (expires==null) {
expires = headerFactory.createExpiresHeader(30); // rather short
response.addHeader( expires );
st.sendResponse(response);
* NOTIFY requests MUST contain a "Subscription-State" header with a
* value of "active", "pending", or "terminated". The "active" value
* indicates that the subscription has been accepted and has been
* authorized (in most cases; see section 5.2.). The "pending" value
* indicates that the subscription has been received, but that
* policy information is insufficient to accept or deny the
* subscription at this time. The "terminated" value indicates that
* the subscription is not active.
Request notifyRequest = dialog.createRequest( "NOTIFY" );
// Mark the contact header, to check that the remote contact is updated
((SipURI)contactHeader.getAddress().getURI()).setParameter("id","not");
// Initial state is pending, second time we assume terminated (Expires==0)
SubscriptionStateHeader sstate = headerFactory.createSubscriptionStateHeader(
isInitial ? SubscriptionStateHeader.PENDING : SubscriptionStateHeader.TERMINATED );
// Need a reason for terminated
if ( sstate.getState().equalsIgnoreCase("terminated") ) {
sstate.setReasonCode( "deactivated" );
notifyRequest.addHeader(sstate);
notifyRequest.setHeader(eventHeader);
notifyRequest.setHeader(contactHeader);
// notifyRequest.setHeader(routeHeader);
ClientTransaction ct = udpProvider.getNewClientTransaction(notifyRequest);
// Let the other side know that the tx is pending acceptance
dialog.sendRequest(ct);
System.out.println("NOTIFY Branch ID " +
((ViaHeader)request.getHeader(ViaHeader.NAME)).getParameter("branch"));
System.out.println("Dialog " + dialog);
System.out.println("Dialog state after pending NOTIFY: " + dialog.getState());
if (isInitial) {
Thread myEventSource = new Thread(new MyEventSource(this,eventHeader));
myEventSource.start();
} catch (Throwable ex) {
ex.printStackTrace();
// System.exit(0);
public synchronized void processResponse(ResponseEvent responseReceivedEvent) {
Response response = (Response) responseReceivedEvent.getResponse();
Transaction tid = responseReceivedEvent.getClientTransaction();
if ( response.getStatusCode() != 200 ) {
this.notifyCount --;
} else {
System.out.println("Notify Count = " + this.notifyCount);
public void processTimeout(javax.sip.TimeoutEvent timeoutEvent) {
Transaction transaction;
if (timeoutEvent.isServerTransaction()) {
transaction = timeoutEvent.getServerTransaction();
} else {
transaction = timeoutEvent.getClientTransaction();
System.out.println("state = " + transaction.getState());
System.out.println("dialog = " + transaction.getDialog());
System.out.println("dialogState = "
+ transaction.getDialog().getState());
System.out.println("Transaction Time out");
private static void initFactories ( int port ) throws Exception {
SipFactory sipFactory = SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
Properties properties = new Properties();
properties.setProperty("javax.sip.STACK_NAME", "notifier" + port );
// You need 16 for logging traces. 32 for debug + traces.
// Your code will limp at 32 but it is best for debugging.
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
properties.setProperty("gov.nist.javax.sip.DEBUG_LOG","Xtradedebug_"+port+".txt");
properties.setProperty("gov.nist.javax.sip.SERVER_LOG","Xtradelog_"+port+".txt");
properties.setProperty("javax.sip.OUTBOUND_PROXY","192.168.1.99:5070/UDP");
properties.setProperty("javax.sip.USE_ROUTER_FOR_ALL_URIS", "true");
properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT","ON");
try {
// Create SipStack object
sipStack = sipFactory.createSipStack(properties);
System.out.println("sipStack = " + sipStack);
} catch (PeerUnavailableException e) {
// 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();
} catch (Exception ex) {
ex.printStackTrace();
System.exit(0);
public void createProvider() {
try {
System.out.println("sipStack = " + sipStack);
System.out.println("SipProviders: "+sipStack.getSipProviders().toString());
System.out.println("AddressFactory: "+addressFactory.getClass());
ListeningPoint lp = sipStack.createListeningPoint(this.serverIP, 5070, ListeningPoint.UDP);
this.udpProvider = sipStack.createSipProvider(lp);
System.out.println("udp provider " + udpProvider);
}catch(SipException e){
System.out.print("SipException "+e.getMessage());
e.printStackTrace();
/*catch(TransportNotSupportedException e){
System.out.print("TransportNotSupportedException "+e.getMessage());
catch (InvalidArgumentException e){
System.out.print("InvalidArgumentException "+e.getMessage());
e.printStackTrace();
catch (Exception ex) {
System.err.println((ex.getMessage()));
ex.printStackTrace();
usage();
public sipClient( int port ) {
this.port = port;
public sipClient(){
public static void main(String args[]) throws Exception {
int port = args.length > 0 ? Integer.parseInt(args[0]) : 5070;
initFactories( port );
sipClient st = new sipClient( port );
st.createProvider();
st.udpProvider.addSipListener(st);
public void processIOException(IOExceptionEvent exceptionEvent) {
public void processTransactionTerminated(
TransactionTerminatedEvent transactionTerminatedEvent) {
public void processDialogTerminated(
DialogTerminatedEvent dialogTerminatedEvent) {
// TODO Auto-generated method stub
} -
Tired to restore my iPod, but I received this error code: 0xE8000065
Please help
Thanks alliPhone, iPad, iPod touch: Unknown error containing '0xE' when connecting
Unknown Error containing "0xE" when restoring
To resolve this issue, follow the steps in iPhone, iPad, iPod touch: Unknown error containing '0xE' when connecting. If you have a Windows computer with an Intel® 5 series/3400 series chipset, you may need updates for your chipset drivers. See iTunes for Windows: Issues syncing iOS devices with P55 and related Intel Chipsets for more information. -
my ipod generation 5 will not come out of recovery mode. i was simply updating my software and this happened. it will not let me restore it comes up with and error. please help, thanks.
Hey erinoneill24,
Thanks for using Apple Support Communities.
Sounds like you can't update your device. You don't mention an error that it gives you. Take a look at both of these articles to troubleshoot.
iPod displays "Use iTunes to restore" message
http://support.apple.com/kb/ts1441?viewlocale=it_it
If you can't update or restore your iOS device
http://support.apple.com/kb/HT1808?viewlocale=de_DE_1
If you started your device in recovery mode by mistake, restart it to exit recovery mode. Or you can just wait—after 15 minutes the device will exit recovery mode by itself.
Have a nice day,
Mario -
Photoshop CS6 could not update successfully. Error codes Adobe Photoshop 13.0.1.3 Installation failed. Error Code: U44M1P7 Extension Manager 6.0.8 Update Installation failed. Error Code: U44M1P7 Please help me figure out how to call customer service. I would prefer to talk to someone directly.
Are you using any disk cleaner or optimization tools like CleanMymac or Mackeeper?
Regards,
Ashutosh -
Cannot restore my brand new iphone 4s ,got stuck in DFU mode and itunes shows error code (-1) please help?
repeatedly tried from diffierent computers and the same error code pops up (error -1)That's a hardware problem which will require a trip to the Apple store for evaluation, unless your phone has been jailbroken, then it's a corrupt hosts file (and we can't help you with that here as it is against the forum's terms of use).
-
I cannot restore my Iphone 4, I keep getting the error code 1611, please help and the Iphone keeps displaying the "Plug-In Itunes Symbol!??
http://tinyurl.com/nyj36v
-
Hello, I have downloaded the new update to my iPhone 4 but I can not instal it , gives me a error signs would you please help me thank you. Nasser
Please identify the error.
-
I receive this message ,repeatedly,when I try to update an App through App store:Error code 1009.Please help,what should I do?
The App Store is not available in Iran.
-
Trying to download ios 3 getting error code 8288 please help
Have a first generation ipod touch, trying to download ios 3 to computer getting error code 8288, please help.
I finally solved this on my own. I installed iTunes 9.2 on my Mac. You can get it from here:
http://support.apple.com/kb/dl1056
Then I went to the iOS 3 purchase page here:
http://support.apple.com/kb/HT2052
and clicked the Purchasing link. It opens up iTunes. I connected my iPod touch G1 and did a check for system update. Miraculously, it found it this time and downloaded the update.
No guarantee that this'll work for you, but I'm finally able to use my iPod touch again and put on some useful apps. -
I am from South Africa and the itune store only allows the purchase of some music , whenever i try to buy Jesus Culture- Everything . an error message comes up "only availble in US " , PLEASE HELP .Thank you
I had the same issue this morning downloading a pre-order of Alanis, Flavors of Entanglement . I noticed that the only thing that had changed fro me was that I had some song credits for purchasing ticketmaster tickets over the past few weeks. When I went ahead and spent my remaining credits... it downloaded with no prompting or trouble. Maybe the credits issues hangs it up?
-
Urgent please help, this program should work
Urgent please help.
I need to solve or I will be in big trouble.
This program works at my home computer which is not networked.
The hard disk was put onto another computer at another location whihc is networked. Here my program worked on Monday 14 october but since for the last two days it is not working without me changing any code. Why do I receive this error message???
Error: 500
Location: /myJSPs/jsp/portal-project2/processviewfiles_dir.jsp
Internal Servlet Error:
javax.servlet.ServletException
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at jsp.portal_0002dproject2.processviewfiles_dir_1._jspService(processviewfiles_dir_1.java:162)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Root cause:
java.lang.NullPointerException
at jsp.portal_0002dproject2.processviewfiles_dir_1._jspService(processviewfiles_dir_1.java:132)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)foolishmatt,
The code is quit large.
to understand the program I think all the code needs to be examined.
I would need to send to you in an email.
Here is my e-mail
[email protected]
if you contact me than I can send the code to you.
Thank you in advance.
Maybe you are looking for
-
HI All , Is it possible to Add or change the existing payment methods available in WCEM ? Regards, Naval Bhatt.
-
Custom install of Design Premium
I have CS4 Design Premium installed and it runs perfectly. However I only have need for one or two of the programs and it was suggested on another Adobe forum that it may be possible to custom install Design. I did not notice that option on the origi
-
Error in modifying Object Value in Triggers defined on Object Tables
Hi, While practising with Triggers, the following error was encountered. Could anyone suggest what is the reason and solution for the problem. An Object Type and an object Table are created. create or replace type typPerson is object (id number, firs
-
Disabling Secondary Popup When Accessing Office 2003 Documents Through KM
Hi, we have the old problem with "Disabling Secondary Popup When Accessing Office 2003 Documents Through KM" which was topic of a weblog by John Mittendof already. For us it was solved when using Windows-integrated authentication without changing the
-
Make a clip play in reverse?
I can't find it on the website...I have this SUPER funny fall of this person...why we all laugh at that?....WELL I want to have the person fall, and then all of a sudden he is played in reverse, and then fall again, etc, back and forth.... I know how