Java find root cause exception

Unable to find root cause of error (GWT-Umbrella Exception)

Solution: Hi usually that kind of error is due to the Execution ACL that is wrongly set on your web service (assuming that your http service is actually a SOAP web service). With webMethods Designer 9.2, Open your web service descriptor In the properties, click on «Permissions» Set «Execution ACL» to «Anynomous» If what you’re exposing is actually a REST web service then the process is pretty much the same.

Unable to find root cause of error (GWT-Umbrella Exception)

I’m building a login application.I’m getting Umbrella Exception everytime, after clicking the Button . unable to find the root cause. Im providing the code and the error list. Please provide me with the fix. Using GWT-RPC

package com.login.vinayak.client; import com.google.gwt.core.client.EntryPoint; public class VinLog implements EntryPoint < private GreetingServiceAsync GreetingService = (GreetingServiceAsync) GWT.create(GreetingService.class); public void onModuleLoad() < GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() < public void onUncaughtException(Throwable e) < Window.alert("uncaught: " +e.getMessage()); Window.alert("uncaught: " + e.getMessage()); String s = buildStackTrace(e, "RuntimeExceotion:\n"); Window.alert(s); e.printStackTrace(); System.out.println(e.getCause()); >>); RootPanel rootPanel = RootPanel.get(); SimplePanel simplePanel = new SimplePanel(); rootPanel.add(simplePanel, 0, 0); simplePanel.setSize("450px", "19px"); Label lblLoginForm = new Label("LOGIN"); lblLoginForm.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); simplePanel.setWidget(lblLoginForm); lblLoginForm.setSize("544px", "41px"); Label lblUserName = new Label("User Name"); rootPanel.add(lblUserName, 10, 124); Label lblPassword = new Label("Password"); rootPanel.add(lblPassword, 10, 183); final TextBox textBox = new TextBox(); textBox.setAlignment(TextAlignment.CENTER); rootPanel.add(textBox, 112, 114); textBox.setSize("139px", "18px"); final PasswordTextBox passwordTextBox = new PasswordTextBox(); rootPanel.add(passwordTextBox, 112, 173); passwordTextBox.setSize("139px", "18px"); Button btnClickToEnter = new Button("Click to Enter"); btnClickToEnter.addClickHandler(new ClickHandler() < public void onClick(ClickEvent event) < String j=textBox.getText(); String k=passwordTextBox.getText(); GreetingService.loginuser(j, k, new AsyncCallback() < public void onFailure(Throwable caught) < Window.alert("welcome"); >public void onSuccess(String result) < Window.alert("try again"); >>); > >); rootPanel.add(btnClickToEnter, 10, 229); final ListBox comboBox = new ListBox(); comboBox.addChangeHandler(new ChangeHandler() < public void onChange(ChangeEvent event) < Object ob=comboBox.getElement(); if(ob=="Guest") < Window.alert("Username and Passowrd is: Guest007"); >> >); comboBox.addItem("User"); comboBox.addItem("Admin"); comboBox.addItem("Guest"); rootPanel.add(comboBox, 10, 51); comboBox.setSize("85px", "22px"); Image image = new Image("home.gif"); rootPanel.add(image, 310, 98); image.setSize("182px", "155px"); > protected String buildStackTrace(Throwable t, String log) < if (t != null) < log += t.getClass().toString(); log += t.getMessage(); StackTraceElement[] stackTrace = t.getStackTrace(); if (stackTrace != null) < StringBuffer trace = new StringBuffer(); for (int i = 0; i < stackTrace.length; i++) < trace.append(stackTrace[i].getClassName() + "." + stackTrace[i].getMethodName() + "(" + stackTrace[i].getFileName() + ":" + stackTrace[i].getLineNumber()); >log += trace.toString(); > Throwable cause = t.getCause(); if (cause != null && cause != t) < log += buildStackTrace(cause, "CausedBy:\n"); >> return log; > > 
package com.login.vinayak.client; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @SuppressWarnings("unused") public interface GreetingService extends RemoteService
package com.login.vinayak.client; import com.google.gwt.user.client.rpc.AsyncCallback; public interface GreetingServiceAsync < public void loginuser(String username, String password, AsyncCallbackcallback); > 

SERVER SIDE ==> GreetingServiceImpl.java

package com.login.vinayak.server; import com.login.vinayak.client.GreetingService; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import java.sql.DriverManager; import java.sql.ResultSet; import com.google.gwt.dev.generator.ast.Statement; public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService < private static final long serialVersionUID = 1L; public String loginuser(String username,String password) < try < java.sql.Connection con = null; Class.forName("org.hsqldb.jdbcDriver"); con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/", "SA", ""); Statement st=(Statement) con.createStatement(); ResultSet rs=((java.sql.Statement) st).executeQuery("select username,password from lgfrm"); String user=rs.getString(1); String pass=rs.getString(2); boolean b1=username.equals(user); boolean b2= password.equals(pass); if(b1==b2==true) < return "success"; >> catch (Exception ae) <> return "Success"; > > 
>  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" > "http://java.sun.com/dtd/web-app_2_3.dtd"> > >  > GreetingServiceImpl > com.login.vinayak.server.GreetingServiceImpl > > GreetingServiceImpl > /Login   > VinLog.html  > > 

com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129) at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129) at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116) at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177) at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351) at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307) at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213) at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)

Caused by: com.google.gwt.user.client.rpc.ServiceDefTarget$NoServiceEntryPointSpecifiedException: Service implementation URL not specified at com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.doPrepareRequestBuilderImpl(RemoteServiceProxy.java:430) at com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.doInvoke(RemoteServiceProxy.java:368) at com.google.gwt.user.client.rpc.impl.RemoteServiceProxy$ServiceHelper.finish(RemoteServiceProxy.java:74) at com.login.vinayak.client.GreetingService_Proxy.loginuser(GreetingService_Proxy.java:34) at com.login.vinayak.client.VinLog$2.onClick(VinLog.java:82) at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:54) at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1) at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1) at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40) at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193) at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88) at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)

KINDLY PROVIDE ME WITH THE FIX. TY

Читайте также:  Database locking in java

. And there you have it: Service implementation URL not specified.

You need to somehow tell GWT where on the backend the RPC call should go. You may do that with the annotation @RemoteServiceRelativePath on the service interface or programmatically on the ServiceDefTarget instance (which is effectively your async service instance).

Spring Boot: Handle Raised Exception from Database, How can I loop through Exception getCause() to find root cause with detail message. Related. 983. How to configure port for a Spring Boot application. 343. Running code after Spring Boot starts. 473. How can I log SQL statements in Spring Boot? 0. spring-mvc and hibernate integration with mysql database. 0. …

WebMethods getting the root cause for a ServiceException

I get the following exception when calling the http service:

com.wm.app.b2b.server.ServiceException Message: com.wm.net.NetException: [ISC.0064.9314] Authorization Required: Unauthorized 

So far, so good. But I would like to get that information programatically — not the human readable translation. I seem to have no chance to get the status code 401 or something that is a 100% proof that the problem is a 401.

Writing a wrapper that tries to get the «root cause» (getCause. ) does not work. There is no other «cause».

All I have are parsable strings. Any idea?

I found a way to get it done — using a deprecated method.

. try < output = Service.doInvoke( "my.package.authentication", "checkAuthentication", input ); >catch( final ServiceException **** ) < // if this is deprecated: how to we have to handle this in future? final Throwable wrappedEx = ****.getWrappedException(); // return early if(null == wrappedEx || !NetException.class.isInstance(wrappedEx) ) < throw ****; >// process the net exception final NetException nEx = (NetException)wrappedEx; final String responseBody = convertStreamToString(nEx.getResponseInputStream()); // process the returned body wrapped by the net exception final Gson gson = new Gson(); final ErrorData errorData = gson.fromJson(responseBody, ErrorData.class); // check if the problem is an invalid token tokenIsInvalid = errorData.code.equals(INVALID_TOKEN_EXCEPTION__CODE_STRING); > catch( Exception e ) < // wrap the exception in a service exception and throw it throw new ServiceException(e); >. 

A better solution would simply check the HTTP-Status-Code — but a 401 is gone forever if recieved by the http-service. 😐

Читайте также:  Чем node js лучше php

Hi usually that kind of error is due to the Execution ACL that is wrongly set on your web service (assuming that your http service is actually a SOAP web service).

  1. Open your web service descriptor
  2. In the properties, click on «Permissions»
  3. Set «Execution ACL» to «Anynomous»

If what you’re exposing is actually a REST web service then the process is pretty much the same. The «Permission» property will be in your flow service’s properties.

Java Exception toString() inclusive causes, You can create a custom exception and override the getMessage () function. here is a sample where I am collecting Stacktraces: @Override public String getMessage () < for (StackTraceElement element : this.getStackTrace () ) < result.append ( element ); result.append ( NEW_LINE ); >return result.toString (); >

Getting Root Error Messages from Throwable

I’m working on my error handling on a web project that I’m doing and I ran into a case in which the error I was displaying to the user wasn’t particularly helpful. I had been using this to get the error message in order to display to my user:

That generally works well and normally gives the user a better message than an **** stack trace that they don’t know what to do with. However, in one case, Hibernate was throwing an exception and the error message being displayed was:

could not insert [some.class.name.Here]

which is very unhelpful. The actual cause of the error was buried in the stack trace:

Only dates between January 1, 1753 and December 31, 9999 are accepted.

Given the first error message, I would have no idea what went wrong. Given the second, I would at least know to take a look at the date I entered. To solve this, I did this:

catch (Throwable t) < . ExceptionUtils.getExceptionMessageWithCauses(t); . >. public class ExceptionUtils < public static String getExceptionMessageWithCauses(Throwable t) < if ( t.getCause() == null ) < return t.getMessage(); >else < return t.getMessage() + "; caused by: " + getExceptionMessageWithCauses(t.getCause()); >> > 

My first concern is that I may get into some sort of infinite loop should two Throwable classes reference one another. Or, similarly, the root cause is so deep that even displaying the more friendly error message from the Throwables results in something no better than a stack trace. So, two questions:

  1. Is it «safe» to do something like this, or can people think of cases where this will blow up in my face?
  2. Is there a better way to handle exceptions aside from checking for every possible error condition one by one?

Well, you’d normally validate user input on the web layer, thus you’d know what the wrong input was. If you get an SQLException from hibernate or the database driver, you normally can’t automatically and beautifully get the real cause.

What we do is catch all exceptions that might mean anything to a user (they are normally checked exceptions), all other exceptions (normally RuntimeExceptions) are just handled with a «An internal error occured» message.

A general exception we have is a ValidationException that is thrown by our validation framework and carries all data needed to generate a nice message (normally translatable).

Sometimes it might be necessary to iterate through the causes in order to get an exception you display. For example, we have exceptions that are thrown by our persistence layer but they are passed through the EJB layer and thus get wrapped in EJBExceptions . Thus we iterate through the causes until we find one of our exceptions and display a nice message or else display the ‘internal error’ one.

Note that normally a user shouldn’t ever be confronted with the default error messages, since most don’t know what that means («Huh, what is a NullPointerException. «)

Java — Best way to check whether a certain exception, If you are using Apache Commons Lang, then you can use the following: (1) When the cause should be exactly of the specified type if (ExceptionUtils.indexOfThrowable (exception, ExpectedException.class) != -1) < // exception is or has a cause of type ExpectedException.class >

Источник

Оцените статью