Eclipse Display View is throwing error - java

all. Amy requirement is checking one exception condition(whether the message is alright or not). For that, I have thrown exception keeping my code in debug mode.
I have written following expression, right click after selecting the expression, execute.
throw new NullPointerException();
Eclipse is showing
Evaluation failed. Reason(s):
Syntax error, insert ";" to complete BlockStatements
Can any one help me please?

Wrap in curly brackets and press Ctrl+U. Should work in neon.
{throw new NullPointerException();}

Related

A Maven plugin fails and to open an issue, I would like to explain inside how the NullPointerException encountered can appear

While compiling an opensource project, I encounter a problem with a Maven plugin that fails.
And I would like to open an issue about its problem. To be helpful to those who will search to solve it, I would like to explain how it might happen.
Execution default of goal pl.project13.maven:git-commit-id-plugin:4.0.3:revision failed. (pl.project13.maven:git-commit-id-plugin:4.0.3:revision:default:initialize)
org.apache.maven.plugin.PluginExecutionException: Execution default of goal pl.project13.maven:git-commit-id-plugin:4.0.3:revision failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:148)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:332)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.lambda$8(MavenImpl.java:1380)
at [...]
Caused by: java.lang.NullPointerException
at pl.project13.maven.git.GitCommitIdMojo.execute(GitCommitIdMojo.java:441)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
... 30 more
For that, I've red the involved line that causes the NullPointerException on its Git repository.
The content of the line 441 of GitCommitIdMojo.java is :
List<MavenProject> sortedProjects =
Optional.ofNullable(session.getProjectDependencyGraph())
.map(graph -> graph.getSortedProjects())
.orElseGet(() -> {
log.warn("Maven's dependency graph is null. Assuming project is the only one executed.");
return Collections.singletonList(session.getCurrentProject());
});
But I'm not so experienced with Optional and other inline functions. And I wonder from where the NullPointerException is really coming. I have no way to test it in Live, so I can only guess.
I've checked on the source file : session is a required attribute. It shouldn't be null.
I believe that the Optional.ofNullable(...) protects the content inside parenthesis and that the NullPointerException isn't coming from here.
But when entering the .orElseGet(...) part of the expression, it might fail on Collections.singletonList(session.getCurrentProject()) where session.getCurrentProject() would return null.
Am I right?
What other parts of this statement could lead to a NullPointerException under what conditions?
You're not looking at the right version of the code. The maven-error refers to 4.0.3 of git-commit-id-plugin, but the code you're displaying comes from the master branch, which is at 4.0.4-SNAPSHOT.
This is line 441 in version 4.0.3:
List sortedProjects = session.getProjectDependencyGraph().getSortedProjects();
The NullPointer can come from any of the three parts.

Jade engine in express.js does not warn or throw error for missing commas

I'm using jade as view engine in my node/express app, and it works just fine, even more too fine :) It does not throw error or warning if a comma is missing between tag attributes. For example:
div.main(data-ng-controller="ctrl" data-ng-form="form")
or
script(type="text/javascript" src="script.js" charset="utf-8")
compiles without errors, however the jade syntax docs says to use commas or new lines to separate tag attributes, so these should be the correct lines:
div.main(data-ng-controller="ctrl", data-ng-form="form")
script(type="text/javascript", src="script.js", charset="utf-8")
And the problem is that I use the same jade templates also in a java project, and the java-jade compiler throws bad syntax exception because the missing attribute separators.
In my opinion the node-jade compiler has a bug or something, and the java-jade compiler works in the righ way: as it should. The inconvenience is if I miss a comma during developing my pages in node environment, I won't notice the error until building my java project.
Is it possible to set up the node-jade compiler to throw errors or warnings for missing commas, or am I using it wrong?
The express setup is like this:
app.set('views', 'path/to/views');
app.set('view engine', 'jade');
Thanks guys!

How to handle errors and exceptions in Talend

I am new in talend. I am trying to catch run time errors and exceptions and display meaningful message to the end user, but i am failed to do this. I saw many tutorials they use different pallets. If in one tutorial tLogCatcher is used whereas in other file it is using tAssertCatcher. I tried with both but could not do. With that i am confuse that where i have to write xpath to replace the error or exception with my own message.Can anybody help me that how to catch errors and exceptions and show meaningful messages.Thanks
You can use the tLogCatcher component to catch any errors or warnings thrown by your Talend job. To output these you can then link this to either a tLogRow component to throw them to the console (and run logs) or out to any output that Talend can connect to such as a flat file, database or even send them in an email with a tSendMail component.
If you wish to change the wording of the messages being thrown and then blindly passed on by the tLogCatcher then you could use a tMap or a tReplace or other similar component to look for your input string (the original error message) and replace it for a message of your choosing before outputting it to either the logs or some other target.

Exception breakpoint occurred at EventDispatchThread.java

we are getting this error at the end of running application. I search in google buti don't know what cause this error and what this means. What to do and how to solve it?
i even don't know what raise this exception...
Exception breakpoint occurred at line 145 of EventDispatchThread.java.
java.lang.NullPointerException:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at oracle.jbo.uicli.jui.JUTableBinding$JUTableModel$2.run(JUTableBinding.java:1209)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Don't know what kind of searches you have performed on Google. I would suggest looking up each error (or rather each class where error occurs). Starting from the beginning as subsequent errors may be a due to error propagation. Two searches for EventDispatchThread and JUTableBinding.java may provide some insight at what went wrong.
http://www.docjar.org/docs/api/java/awt/EventDispatchThread.html
It seems that this class deals with AWT components ("takes events off the EventQueue and dispatches them to the appropriate AWT components")
For the JUTableBinding.java there are quite a few pages that say about NullPointerException
https://forums.oracle.com/forums/thread.jspa?threadID=515213
https://forums.oracle.com/forums/thread.jspa?threadID=2343921
https://kr.forums.oracle.com/forums/thread.jspa?threadID=503593
Some of them say that the problem may be with jdk version (seems 1.6 and above throw errors). I would assume that may be the case. Try to recompile using earlier versions of jdk and check whether error is still there. If it is not this then we will investigate further.
"I've looked into the code and found out that JUTableBinding.JUTableModel calls
mScrollUnit = control.getScrollableUnitIncrement(null,
SwingConstants.VERTICAL, 0);
(Line 947)
This was okay in Java 5, since JTable's getScrollableUnitIncrement just returned the row height."
"I changed the line to:
mScrollUnit = control.getScrollableUnitIncrement(
control.getVisibleRect(), SwingConstants.VERTICAL, 0);
and everything works fine on Java 6..."
Hope it helps.

NetBeans and stop/break on all Exceptions?

I'm using NetBeans as my IDE for developing Android.
However, when I get an exception, Netbeans does not break on the exception as I expect it to.
I have checked the box "Stop on uncaught exceptions" that can be found in Options --> Java Debugger --> Stop on uncaught exceptions but that doesn't help.
Furthermore, where can I see the actual exception message? I don't see anything. I have no clue where and when an exception occurs, just that it does occur.
I've read some on the netbeans.org site about a bug in 6.9.1 that was fixed, but it doesn't seem to be fixed in 7.0 that I have.
The debugging window doesn't say anything useful at all, gives some form of stack trace that is pointless as it doesn't specify any of my own code.
I switched from Eclipse because that IDE sucks, NetBeans is much leaner, but the debugging needs to be fixed to be useful.
I have this problem when I use netbeans too. To get the exception message, I use try-and-catch. In the catch() statement, call a function that contains some code and put a breakpoint on it. Then when the exception is given your breakpoint in the catch statement will be called and you can read the information (error message, stack, etc.) from the Exception obect.
try
{
// Doing something here
}
catch (Exception e1)
{
// This is called when an exception occurs
doSomething(); /// Put breakpoint here
}
UPDATE:
I am not sure if this will work for android but you could try entering a "New Breakpoint". When entering a new breakpoint to break on an exception, you need to know the
exact package/class exception name. For example, if you want to catch a
NullPointerException, then you go to Debug >> New Breakpoint to create a New Breakpoint and enter
java.lang.NullPointerException into the Exception Class Name field in the
Breakpoint Properties dialog. Choose whether to break on caught, uncaught or both, exceptions and it will hit a breakpoint if that type of exception ever occurs in the class/project.
I had such behavior where I had my source file that generated the exception NOT in "default package". When I moved everything to "default package" it started working fine and stop on exception automatically.
This answer actually also answers this question:
https://stackoverflow.com/a/2671390/415551
To quote user Finbarr:
Go to debug > New Breakpoint (alternatively CTRL+SHIFT+F8). Change the
breakpoint type to Exception in the top right hand drop down menu.
Type java.lang.NullPointerException in the Exception class field.
Choose whether to break on caught, uncaught or both.
Debug your code and watch the glorious auto breakpoint when the
Exception is thrown.
Simply change java.lang.NullPointerException to java.lang.Exception to break on any error.

Categories