How can I return error status information from a tJava component in Talend so that the on component error trigger can be used? I have custom code inside the tJava component that may throw exception. In such a situation, I would like to call tDie from tJava using the on component error trigger.
This turned out to be quite simple to achieve. Given the design:
The tJava component in the middle contained code to generate exception:
String a = null;
String b = "bar";
a.equalsIgnoreCase(b);
Running the job printed the exception and the message from tDie:
Exception in component tJava_1
java.lang.NullPointerException
at mrx_talend.test_0_1.test.tJava_1Process(test.java:374)
at mrx_talend.test_0_1.test.runJobInTOS(test.java:842)
at mrx_talend.test_0_1.test.main(test.java:699)
Exiting due to processing failure
Related
I'm using Spring Batch with partitioning.
Initially, I was getting DeadlockLoserDataAccessException and then I have configured our steps as faultTolerant, please see the following code -
Step masterCalculationStep = stepBuilderFactory.get("STEP_1")
.<Map<Long, List<CostCalculation>>, List<TempCostCalc>>chunk(1).reader(reader)
.processor(processor)
.writer(writer)
.faultTolerant()
.retryLimit(5)
.retry(DeadlockLoserDataAccessException.class)
.build();
but now we are getting another exception -
org.springframework.batch.core.step.skip.NonSkippableReadException:
Non-skippable exception during read
Don't know why this new exception and how to resolve it?
The RetryPolicy in a chunk oriented step is not applied to the reader. So if your reader might throw a transient exception, you need to add the retry logic around the reader yourself. This can be done for example with:
AOP by applying org.springframework.retry.interceptor.RetryOperationsInterceptor to your reader
or by using org.springframework.retry.support.RetryTemplate in a decorator of your reader that reties the read method when it throws a transient exception
Similar questions can be found here:
Spring batch retry mechanism for reader failure
Retry in case of a failed reading
Hope this helps.
I have 10000 lines of code outlining routes of my API implemented using the Slim Framework. However, I got an error message preg_match(): Compilation failed: two named subpatterns have the same name at offset 89. The problem is, I got the stack trace referring to this statement preg_match('/cost-centers...', '/overview/funds...', NULL) at the Slim Route.php. Now that my URLs are lengthy, I can't pinpoint which of the URLs have the same name.
Is there any way to have a more detailed stack trace instead of displaying these shortened format?
Thanks to mgansler for this tip.
I just used a custom error handler with PHP Exception::getTrace() function. I also turned the Slim's default debugging off to ensure that the custom error handler is invoked.
Code goes like this:
$app = new \Slim\Slim(array(
'debug' => false
));
$app->error(function (\Exception $e) use ($app) {
//enter manipulation of $e->getTrace()
//or just var_dump($e->getTrace()) but the format would be chaotic
});
I know there is a way to access reduced view results using the Couchbase java sdk. What I am currently unable to do is use spring-data to access the reduced view. Is this possible?
view:
View byIdGetDateStats = DefaultView.create("byIdGetDateStats",
"function (doc, meta) {"
+ "if(doc.docType == \"com.bd.idm.model.DayLog\"){"
+ " emit(doc.userid, doc.date)"
+" }}"
,"_stats"
);
When I attempt to use spring-data to access the view like this:
Query query = new Query();
query.setKey(ComplexKey.of(userid)).setReduce(true).setGroup(true);
ViewResult result = repo.findByIdGetDateStats(query);
Error Message
java.lang.IllegalStateException: Failed to execute CommandLineRunner
...
Caused by: java.lang.RuntimeException: Failed to access the view
...
Caused by: java.util.concurrent.ExecutionException: OperationException: SERVER: query_parse_error Reason: Invalid URL parameter 'group' or 'group_level' for non-reduce view.
....
Caused by: com.couchbase.client.protocol.views.ViewException: query_parse_error Reason: Invalid URL parameter 'group' or 'group_level' for non-reduce view.
....
No, Spring-Data-Couchbase 1.x will always set reduce to false.
If you want to use a reduced view and get the ViewResult, use the CouchbaseTemplate#queryView() method.
You can still do so in a repository by defining custom repository method (see this chapter of the doc, you should be able to call getCouchbaseOperations in your implementation).
I have a job that is built of the following components
Processing Step - activates an external processing that logs it's result in the DB and returns an internal id so I can take this id and process it further
Logging Step - built of a tasklet, that contains a chunk
The chunk is built of an item reader - that I plan will use #{stepExecutionContext['job.id']} as part of the sql written in the xml file so it will get the relevant logging info
I'm trying to work with the solution suggested here - 11.8 Passing Data to Future Steps but i get this error when i try to add a property on the step execution context or the job execution context
chunkContext.getStepContext().getStepExecutionContext().put("job.id", jobId);
And I get this error:
java.lang.UnsupportedOperationException: null
at java.util.Collections$UnmodifiableMap.put(Collections.java:1342)
at ...
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:395)
Did i miss something?
StepContext available from ChunkContext is a read-only object; use a StepExecutionListener and save the step execution context passed as parameter in method StepExecutionListener.afterStep(StepExecution stepExecution)
I always follow this path:
chunkContext
.getStepContext()
.getStepExecution()
.getJobExecution()
.getExecutionContext()
.put("", "");
I also had problems doing the put in StepExecution.
Maybe it loses data when it goes to the next step.
However, I leave the last sentence to the most expert.
chunkContext.getStepContext().getStepExecutionContext() retrun copy use chunkContext.getStepContext().getStepExecution().getExecutionContext()
What pattern can I use to display errors on an MVC 2 view that are not related to a single property?
For example, when I call a web service to process form data, the web service may return an error or throw an exception. I would like to display a user-friendly version of that error, but have no logical means to relate the error to any given property of the model.
UPDATE:
Trying to use this code as suggested, but no summary message is displayed:
MyPage.spark:
Html.ValidationSummary(false, "Oopps it didn't work.");
Controller:
ViewData.ModelState.AddModelError("_FORM", "My custom error message.");
// Also tried this: ViewData.ModelState.AddModelError(string.Empty, "My custom error message.");
return View();
UPDATE 2
What does this mean?
next to each field.
Instead of always displaying all
validation errors, the
Html.ValidationSummary helper method
has a new option to display only
model-level errors. This enables
model-level errors to be displayed in
the validation summary and
field-specific errors to be displayed
next to each field.
Source: http://www.asp.net/learn/whitepapers/what-is-new-in-aspnet-mvc#_TOC3_14
Specifically, how does one add a model level error (as opposed to a field-specific error) to the model?
UPDATE 3:
I noticed this morning that Html.ValidationSummary is not displaying any errors at all, not even property errors. Trying to sort out why.
Simply adding a custom error to the ModelState object in conjunction with the ValidationSummary() extension method should do the trick. I use something like "_FORM" for the key... just so it won't conflict with any fields.
As far as patterns go, I have it setup so that my Business Logic Layer (called via services from the controller) will throw a custom exception if anything expected goes wrong that I want to display on the view. This custom exception contains a Dictionary<string, string> property that has any errors that I should add to ModelState.
HTHs,
Charles