I am new bie to flex. We are using flex,java,blazeds to develop our application. So we are successfully connected to blazeds but it is showing one error when we are trying to execute the application.the error is:
(mx.rpc::Fault)#0
content = (null)
errorID = 0
faultCode = "Server.Processing"
faultDetail = (null)
faultString = "java.lang.NullPointerException : null"
message = "faultCode:Server.Processing
faultString:'java.lang.NullPointerException : null'
faultDetail:'null'"
name = "Error"
rootCause = (Object)#1
cause = (null)
localizedMessage = (null)
message = (null)
If anyone has idea about this issue.Please help me.I am trying to solve the issue.But i didnt get the perfect solution.
Thanks in Advance,
Rakhi
The Error you got in Flex says that there was an uncaught NullPointerException in your java code.
You should examine the processing code of the actual request (debug / encapsulate it in try-catch), to see where the NPE is thrown, and handle it, otherwise, instead of the response object, this exception is returned to the flex application.
You can also surround with try-catch the request/response processing code in your flex application -in case you don't want to deal with it on server side-, and show a popup/alert message about it.
But it would be nicer if you'd wrap that NullPointerException on server side to a custom Exception, so you could handle it more precisely.
I wrote an article about handling the Java errors in Flex, you can find it here. It aims to cover all the cases (webservices, amf, spring integration).
Related
I have an external service I'm calling that just returns 500's with the SAME exception each time no matter the issue.
For example(my api to their service):
Action: Fetch image that does not exist
IMGException: Status code: 500, ErrMsg: File not found
Action: Fetch image that does exist but there are server side issues
IMGException: Status code: 500, ErrMsg: Cannot grab img at this time
Action: Fetch image that does exist but is expired
IMGException: Status code: 500, ErrMsg: Img is expired
What would be the best way to handle this? I was catching them and giving them more descriptive messages to throw to my #ExceptionHandler for logging, etc. Should I just throw them and never catch them since I cannot dependably predict what the exception is caused from and therefore cannot correctly change the status code or message?
You can parse the ErrMsg and throw your own exceptions. But Since the response is from an external service, you can as well include the message from external service in the response to your API in a separate field like ExternalMessage.
This will help the users in case the response from external API changes and you end up throwing a different exception.
I recommend you to simply rethrow these exceptions with the information that the server sends to you and add any information you have. But do not add new information based on what you recieved (with if's, for example), because if they change something your code will just be deprecated.
Of course, never show crypt messages to your final user. In this case add some generic message with instructions about what they can do.
I use Java to index some documents with a BulkRequestinto Elasticsearch 1.4.2.
Some of these docs only need to be written when they are not already in the index, so I set the CREATE-opType like this:
indexRequestBuilder.opType(IndexRequest.OpType.CREATE)
Now the docs which were already in the index fail in the BulkResponse.
Error message bulkItemResponse.getFailureMessage():
DocumentAlreadyExistsException[...]
I want to ignore this class of exception but retry writing the docs for all other type of exceptions.
So how can I catch just the DocumentAlreadyExistsException?
I can get the Failure with bulkItemResponse.getFailure(), but I cannot find any information about the type of the Exception beside the error message.
I could look in the error-message for the exception name, but this may be rather fragile with new Elasticsearch versions:
if(bulkItemResponse.getFailureMessage().startsWith("DocumentAlreadyExistsException[")
Is there a better way?
This cant be possible. The bulk request is actaully executed on the server side and not client side. And hence all it can do is to sent the stacktrace back and not the Exception object.
I am using GWT. if any server side exception is generated, we are sending an email with error details(have used log4j SMTPAppender). Based on the line number, we can fix the issue..
My scenario is, if any exception is generated in the client package code, as of now, we are giving generic message saying "Some Exception has Occured". But is it possible to display error stack trace along with the exception cause and line number? my code is as below:
GWT.setUncaughtExceptionHandler(new
GWT.UncaughtExceptionHandler() {
public void onUncaughtException(Throwable e) {
Window.alert("Some Exception has Occured");
}
});
I dont think it is possible as client package is converted into Javascript in web mode. Please suggest me if there is any approach to display exception cause and line number where it has occured.
You can read this page
Basically, you have to use JUL to do your logging, and it's client logging : firebug, JS console, etc... You may do some smarter things with the RemoteLogging but i can't help you on that.
The main problem is that log4j is not supported. Maybe with a bridge between JUL and log4j you will be able to achieve everything you want
I would recommend using gwt-log:
Project Page
gwt-log has support for an 'UncaughtExceptionHandler' and a RemoteLogger to send messages/exception to the server.
in gwt-log, you can also turn on the "emulated stack", which is exactly what you want to do:
Wiki Page - Emulated Stack
please note however that this adds a LOT of code to the compiled JS-script
I'm implementing the Thrift Remote Procedure call framework in Java. I set up thrift and generated my skeleton code without a lot of issues, but now that I'm actually using the API methods, I get strange errors.
Here are the errors I get:
Exception in thread "main" org.apache.thrift.transport.TTransportException: Cannot write to null outputStream
at org.apache.thrift.transport.TIOStreamTransport.write(TIOStreamTransport.java:142)
at org.apache.thrift.protocol.TBinaryProtocol.writeI32(TBinaryProtocol.java:163)
at org.apache.thrift.protocol.TBinaryProtocol.writeMessageBegin(TBinaryProtocol.java:91)
at SimonSays$Client.send_registerClient(SimonSays.java:102)
at SimonSays$Client.registerClient(SimonSays.java:96)
at simon.main(testClass.java:16)
I don't think I'm not making any mistakes, but just to make sure, here's the code that's leading to the errors:
TProtocol prot = new TBinaryProtocol(new TSocket("http://thriftpuzzle.facebook.com",9030));
SimonSays.Client client = new SimonSays.Client(prot);
client.registerClient("userEmailAddress#gmail.com");
The error is said to be generated from the client.registerClient() call, but that is a call to the code generated by Thrift, which makes me feel that I'm doing something wrong in setting up the connection itself.
The part about making a TProtocol instance I included myself, and it's likely that that's where the problem lies.
I was hoping that someone would have more of an idea about what's going wrong that I do.
Please let me know if more information or clarification is needed.
Edit: I found the TProtocol instantiation statement from the Cassandra Wiki
You need to call the open() method on your TSocket instance in order for it to connect and obtain the input/output streams it needs.
Source: TSocket.java
I have a small issue, I had my SIP client working, and I changed the structure of the code. I kept the creation process of the SIP objects as it was before, but now it does not work.
I keep getting:
java.lang.NullPointerException at gov.nist.javax.sip.SipProviderImpl.getNewClientTransaction(SipProviderImpl.java:285)
and there is no reference to such error in the documentation... what does it mean?
here is the instantiation code for the sip:
sipFactory.setPathName(host);
sipFactory.resetFactory();
sipStack = sipFactory.createSipStack(getProperties());
String address = Inet4Address.getLocalHost().getHostAddress();
sipFactory.createHeaderFactory();
sipFactory.createAddressFactory();
sipFactory.createMessageFactory();
udpPoint = sipStack.createListeningPoint(address, SIPPort, SIPConstants.UDP);
udpSipProvider = sipStack.createSipProvider(udpPoint);
udpSipProvider.addSipListener(this);
tcpPoint = sipStack.createListeningPoint(address, SIPPort, SIPConstants.TCP);
tcpSipProvider = sipStack.createSipProvider(tcpPoint);
tcpSipProvider.addSipListener(this);
sipStack.start();
setSessionState(SipSessionState.Connected);
Any Help please??
Adam.
WWWWWWWWWWWOOOOOOOOOOOWWWWWWWWWWWWW
If anyone would had ever guessed this, I'll eat my LapTop....
in the first project I was using the Jain-Sip 1.2
and in the new one I use the 1.2.1
BIG issue that in the 1.2, as far as I can tell, request.getMethod() returns the method of the CSeq header in case I don't use the request.setMethod(method).
While in the 1.2.1, if not setting the request.setMethod(method), the request.getMethod() method returns null.
that was my error...
now if you read this please commend or something... I'm so frustrated, I was sitting on this bugger for 4 hours now. Damn.
Adam.