I have created a AIF- document service in AX 2009. I am doing a picking list registration update in AX. I have my code in try and catch in AX.
MY ISSUE:
when I test the service in AX through a test job, I can able to catch the exception in the catch code. But, when I consume the service through C#, I can't able to catch the exception. In other words, the code is not coming to the catch part.
I don't know why I can't catch exception when I am consuming the service.
Any suggestions would be helpful..
Thanks in Advance!
Related
I'm having some troubles trying to catch an error on OSB when I put a message on queue and JMS Server is down, I have a proxy service calling a business service that have a jms configured.
My proxy service already have Transaction Required and Same Transaction For Response enabled.
The error on Admin log:
Destination unreachable; nested exception is:
java.net.ConnectException: Connection refused: connect; No available
router to destination
But the exception don't catch on ErrorHandler :(
I found the error, the problem is that I was using Publish instead of Routing, after I changed everything worked.
Yes that correct , Publish thread is like fire and forget(completely asynchronous) while a Route or ServiceCallout will latch on to the exception in ErrorHandler
Publish is fire-and-forget, by default with no wait for an answer. This comes from the fact, that default QualityOfService=BestEffort for publish action. You can change that, by using RoutingOptions block, and setting QualityOfService=ExactlyOnce. OSB will then wait for action to execute, hence will be also able to catch potential errors.
When I make a change in the database (add, delete, rename a column) and don't update my EF mappings, I get an exception while in debug mode
System.Data.Entity.Core.EntityCommandExecutionException
but I don't see this exception caught in the Global DispatcherUnhandledException even if I catch and throw it from the code where the exception is occuring. What is the reason? Basically I want to validate my EF mappings when my application loads and if there is any mismatch in mapping I want to show user a friendly message that Client Application needs to be updated.
An option would be to create a command interceptor. This concept was introduced in Entity Framework 6.0.
You create the interceptor by implementing the IDbCommandInterceptor interface and then register it either through code or configuration.
http://www.tutorialspoint.com/entity_framework/entity_framework_command_interception.htm
http://www.entityframeworktutorial.net/entityframework6/database-command-interception.aspx
https://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/connection-resiliency-and-command-interception-with-the-entity-framework-in-an-asp-net-mvc-application
While detaching an object from the datastore in a deployed app on Google App Engine, I'm getting an "failed to detach" exception that I can't reproduce on my development box. The detach operation is server-side, so the only information I have on it is the log of the exception in the app's log files. However, the stacktrace is elided: for example, the deepest internal exception ends with "... 36 more".
How do I adjust the verbosity of the app's logging to include the full, non-elided stacktrace?
What you can do is to add the Throwable as a parameter when logging an exception. ie:
Logger log = Logger.getLogger(YourClass.class.getName());
.....
}catch (final Throwable e){
log.log(Level.SEVERE, e.toString(), e);
}
This will print a nice stack trace on GAE's logs.
This way you don't have to change the global log level.
There are few things that you can possibly tweak:
1) In war\WEB-INF\logging.properties file. Change the .level value to a level lower e.g. DEBUG.
2) In your Java code, look at encapsulating the problem code within a try/catch so that you have control of the same.
3) In the catch block, look at logging the exception data via ex.printStackTrace(), where ex is the exception object.
I have a production issue with a GAE application. The problem seems to be related only to some users.
Is there a possibility to connect the local debugger to the prod version ? I'd like to avoid to have to copy the prod data to the dev server.
Thanks !
This situation has improved as of a few days ago with the intoduction of Google Cloud Debugger
Earlier this week at Google Cloud Platform Live, we launched the beta release of Cloud Debugger which makes it easier to troubleshoot applications in production. Now you can simply pick a line of code, set a watchpoint and the debugger will return local variables and a full stack trace from the next request that executes that line on any replica of your service. There is zero setup time, no complex configurations and no performance impact noticeable to your users.
Here's the blog post
Here's the info
Not possible, you can only debug using the logs.
I managed to solve the issue. The problem was that one program was throwing an exception and I did not catch it properly. The code was
catch (Exception e) {
e.printStackTrace();
}
On the development platform the exception was thrown at the console. The problem in production is that it does not appear in the GAE console. This has two very bad outcomes :
--> 1) The end user does not know that the transaction did not end successfully
--> 2) The administrator has no clue that a problem has occurred and no way to debug
==>
I have therefore replaced the code by
catch (Exception e) {
final Logger log = Logger.getLogger(InternalServiceImpl.class.getName());
log.severe("Problem while updating XXX record : " + e.getLocalizedMessage());
updatedRecord.setRPCResult(DB_PROBLEM); // This is specific to my application to notify the end user
}
I did modify the code relaunched the application and found out that the problem was a resource contention in a transaction.
Was really a stupid beginner mistake.
I have mocked out HttpServletRequest, a service in my test:
request = createNiceMock(HttpServletRequest.class);
service = createStrictMock(DataProviderService.class);
I am verifying behaviour that my controller handles exception thrown by service, by setting expectaion:
expect(service.getData(someObject)).andThrow(new MyException());
replay(endPoint);
I verify the same as:
ModelAndView mav = controller.provideDefaultScreen(request);
verify(service);
My controller invokes service and in case of exception, sets exception details in request
request.setAttribute("exceptionMessage", e.getMessage());
This line is throwing out an error:
java.lang.IllegalStateException: missing behavior definition for the preceding method call:
HttpServletRequest.getAttribute("someAttributeCheckedEarlier")
Usage is: expect(a.foo()).andXXX()
I am least bothered about what my controller does to request, I am only concerned that it should eat up the exception thrown by service. Correspondingly, I've created request as nick mock. Why do I still get this error?
Unless you have cut it from your snippets of code, you don't seem to have called replay on the NiceMock. This will move it out of the "record" mode and make it usable.
Apart from the above answer, have you considered using Spring Mock? It has nice support for mocking and provides a host of classes that would not required using easymock atleast for supporting out of web container testing.
This framework can be used independent of Spring and your application doesn't need to use Spring Framework. Here is a nice article too...
Hope that helps.