I am getting "com.sun.jdi.InvocationException occurred invoking method" error when I debug in eclipse and is in ognlRuntime.
The error occured when I am passing a value from jsp to the action class.
This is the code in jsp for passing the value
<s:textfield name="partReplace.part.number" cssStyle="width:50px;" value ="%{partReplace.part.number}"/></td>
and when I enter vlue in that textfield it is not setting in the action class. I debuuged and found the "com.sun.jdi.InvocationException occurred invoking method" error in ognlRuntime and it is not taking the value..
Your problem seems to be the same of this question;
if so, the guilty should be an incorrect override of the toString() method of your class, invoked by the Eclipse Debugger.
Correct your custom toString() method, or block him from throwing exceptions (a big try-catch inside) or remove it completely, and retry.
P.S: this is the first result on Google searching your Exception... and is on SO too :|
Related
I need to get the Context name that causes the syntax error in the source code using the antlr4. Is there a way to do that.?
In your error listener (when the function syntaxError is called) you can use the passed in recognizer (which is actually your parser) to get the current parse rule context, by calling Parser.getRuleContext().
Am calling a popup dialog, this throws an error.
This code previously worked, but i recently uploaded a new build and my new build now produces an error message on the 15/07/2019
public Command showPopupDialog(Component c). this is the method in the Dialog class am calling.
Getting the following error message
java.lang.NullPointerException
at com.codename1.ui.plaf.Border.paintBorderBackground(Border.java:1435)
[EDT] 0:0:0,19 - Exception: java.lang.NullPointerException - null
at com.codename1.ui.plaf.Border.paintBorderBackground(Border.java:1267)
at com.codename1.ui.Component.paintBackgroundImpl(Component.java:2661)
at com.codename1.ui.Component.paintComponentBackground(Component.java:2625)
at com.codename1.ui.Container.paintComponentBackground(Container.java:2546)
at com.codename1.ui.Component.internalPaintImpl(Component.java:2239)
at com.codename1.ui.Component.paintInternalImpl(Component.java:2228)
at com.codename1.ui.Component.paintInternal(Component.java:2203)
at com.codename1.ui.Container.paint(Container.java:1639)
at com.codename1.ui.Form.paint(Form.java:4180)
at com.codename1.ui.Component.internalPaintImpl(Component.java:2255)
at com.codename1.ui.Form.internalPaintImpl(Form.java:4190)
at com.codename1.ui.Component.paintInternalImpl(Component.java:2228)
at com.codename1.ui.Component.paintInternal(Component.java:2203)
at com.codename1.ui.Component.paintInternal(Component.java:2171)
[EDT] 0:0:0,66 - Exception: java.lang.NullPointerException - null
at com.codename1.ui.Component.paintComponent(Component.java:2468)
at com.codename1.ui.animations.CommonTransitions.paint(CommonTransitions.java:1139)
at com.codename1.ui.animations.CommonTransitions.initTransition(CommonTransitions.java:469)
at com.codename1.ui.Display.initTransition(Display.java:1576)
at com.codename1.ui.Display.setCurrent(Display.java:1535)
at com.codename1.ui.Form.showModal(Form.java:2303)
at com.codename1.ui.Dialog.showModal(Dialog.java:1138)
at com.codename1.ui.Dialog.show(Dialog.java:582)
at com.codename1.ui.Dialog.showPopupDialog(Dialog.java:1287)
at com.codename1.ui.Dialog.showPopupDialog(Dialog.java:1154)
Either you're passing a parameter that's null, or you are trying to call a method on an object that is null.
So the simplest way of finding out which is null, is doing this:
System.out.println("myObject = "+myObject);
for every object that you're using near the nullpointer exception until you find something that's null.
This is a regression due to the fix for this issue. We fixed it and it will be available in the next update.
I'm guessing you have a style for PopupDialog in your theme. I suggest removing it as a workaround.
I am overriding the addArticle and updateArticle methods of JournalArticleServiceImpl using a Hook. I am checking for all articles with a particular ddmStructureKey and that the current article has a unique value in a particular field.
I am throwing DuplicateEntryException exception when I find non-uniqueness. Within the curresponding catch method, I gave return null;. But it threw a NullPointerException. Then I tried to throw SystemException like follows.
try {
// logic
} catch (DuplicateEntryException e) {
LOG.error("Value already present", e);
throw new SystemException("Value already present", e);
}
But the result for the end users was as shown below. Even though in the logs, it displayed the actual error, it is not possible for users to understand what exactly happened in the background from this message.
I do not know how to display a custom error message to the end users from a Hook. Also to return to the same page to edit the same article.
Display error messages in Liferay:
You may use session messages, like <liferay-ui:error> tag.
For example in the jsp page:
<%# taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
...
<liferay-ui:error key="err1" message="Third message" translateMessage="false"/>
or with exception, like in edit_article.jsp:
<liferay-ui:error exception="<%= ArticleContentSizeException.class %>" message="you-have-exceeded-the-maximum-web-content-size-allowed" />
You can define your own exception class and your own message-key and the value for the key in Language.properties.
And in the render method:
SessionErrors.add(renderRequest, "err1");
or when catching an exception (e) use this:
SessionErrors.add(renderRequest, e.getClass());
A complete example on github - portlet, github - hook
As the UI layer seems to not expect any exception from these methods, this might call for changes in the UI- or Action-layer as well. When you do that, you might even get well along without service changes (because you can check upfront).
A hacky idea might be to not return null, but the duplicated value - simulating a successful update but returning the already existing article. Note that this is hacky, I'm not sure if it works always. If it breaks, please let me know how it breaks.
I've build a method which takes strings as input parameter. In my index.jsp page, I retrieve a GET-variable from the URL using request.getParameter(). Now, I want to call the aforementioned method on this string, but I get a compiler error saying:
The method <method name>(String) is undefined for the type __2F_<webapp name>_2F_src_2F_main_2F_webapp_2F_index_2E_jsp".
Does anyone know why I get this error and how I can get rid of it. Any help is greatly appreciated!
My code is rather lengthy, but I think this is relevant code:
categorie = request.getParameter("categorie");
if (categorie.equals("")) {
categorie = "Category;";
}
ArrayList<String> categorieen = queryCategories(categorie);
You are calling ArrayList<String> categorieen = queryCategories(categorie); and you did not define queryCategories method. Since the JSP page is compiled into a big servlet class, it tries to locate queryCategories method as member of that class and it could not find it.
Very little information. Where is your app deployed? From what I gather, it seems you either haven't restarted the deployed app or have not replaced the changed class file and haven't set some sort of "development mode" on wherein you don't require a restart for a Jsp modification.
Just replace the .jsp and JSP_NAME.class file.
I am trying to retrieve count of voicemail .For this I am trying to call getMessageWaitingIndicator method of PhoneBase.java.
My Code is as given below
Class<?> class2=Class.forName("com.android.internal.telephony.PhoneBase");
Method method=class2.getMethod("getMessageWaitingIndicator");
Boolean returnValue=(Boolean) method.invoke(class2);
But Everytime I am getting an exception as mentioned below :
java.lang.IllegalArgumentException: expected receiver of type com.android.internal.telephony.PhoneBase,
but got java.lang.class<com.android.internal.telephony.PhoneBase>
I don't understand it. How can I fix this issue?
The instruction:
method.invoke (stringValue);
needs the object in which the method will be invoked.
method = class2.getMethod('myFunction',String.class);
method.invoke(someInstanceOfMyActivity, stringValue);
Documentation:
http://docs.oracle.com/javase/6/docs/api/java/lang/reflect/Method.html
Edit.
You can also look at the answer to the very close question here:
Android Reflection Method Error