Google Calendar API CalendarQuickstart.java throwing an IllegalArgumentException something about web or installed, - google-calendar-api

When I run CalendarQuickstart.java as a Java Application I get an IllegalArgumentException Stack Trace. It appears to be a Security Issue. Something to do with web or installed?
I'm not sure how to fix the problem.
Here is the Stack Trace:
Exception in thread "main" java.lang.IllegalArgumentException at com.google.common.base.Preconditions.checkArgument(Preconditions.java:121) at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:37) at com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.getDetails(GoogleClientSecrets.java:82) at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.(GoogleAuthorizationCodeFlow.java:197) at googlecalapi.CalendarQuickstart.getCredentials(CalendarQuickstart.java:71) at googlecalapi.CalendarQuickstart.main(CalendarQuickstart.java:83)

Related

Mule Error : AsyncHttpClient has been closed while invoking the POST API

I have a mule application hosted on Cloudhub which invokes the same API say "example.com" in Parallel using Scatter Gather and HTTP Request component.
The application is hosted on Cloudhub runtime 4.1.5. Everything looks working fine but we get intermittent exception message as:
HTTP POST on resource 'https://example.com:443/<path>/<res>' failed: AsyncHttpClient has been closed..
The part of stack trace is:
Root Exception stack trace:
java.io.IOException: AsyncHttpClient has been closed.
at com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider.execute(GrizzlyAsyncHttpProvider.java:121)
at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:505)
at org.mule.service.http.impl.service.client.GrizzlyHttpClient.sendAsync(GrizzlyHttpClient.java:364)
at com.mulesoft.service.http.impl.service.client.EEGrizzlyHttpClient.sendAsync(EEGrizzlyHttpClient.java:141)
at org.mule.extension.http.internal.request.HttpRequesterConnectionManager$ShareableHttpClient.sendAsync(HttpRequesterConnectionManager.java:104)
at org.mule.extension.http.internal.request.client.HttpExtensionClient.send(HttpExtensionClient.java:72)
at org.mule.extension.http.internal.request.HttpRequester.doRequestWithRetry(HttpRequester.java:124)
at org.mule.extension.http.internal.request.HttpRequester.doRequest(HttpRequester.java:103)
at org.mule.extension.http.internal.request.HttpRequestOperations.request(HttpRequestOperations.java:131)
at sun.reflect.GeneratedMethodAccessor205.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:216)
Earlier this was an issue in Mule runtime 3.7.3 which they have corrected in later version of 3.x.x runtimes. Not sure if they have considered this correction in mule 4.x.x.

Handling Fatal Errors with the Twig Exception Controller

I am working on a Symfony project and I am trying to create user-friendly error pages for the production environment. To do this, I have overridden the twig.exception_controller parameter. That process is described in the Symfony Documentation. In overriding the exception controller, I have been able to create custom error pages for instances were no routes exist, or an uncaught exception in thrown. I have not been able to get this to work with fatal errors, and that is what my question is about.
Is it possible to catch/handle fatal errors in Symfony? I am not attempting to continue running the application (as the answerer of this question suggests) when a fatal error occurs. I would simply like to show an error page, aside from the standard one which has the function-call stack trace.
I attempted to set the shutdown function using register_shutdown_function, but that did not prevent the default error page (with stack trace) from displaying.
Thanks!
you can put your proccesses that might fail into a try block
try {
// assert this fails because you have some buggy code here
$foos=$fooService->getFoosByDateTime();
}catch(\Exception $e){
//you can catch the exception
$exceptionMessage= $e->getMessage();
$this->redirect("your_custom_route_to_error_page",{"error":$exceptionMessage});
}
You could enable catching Fatal errors and converting them into Exceptions, shown in Debug Component.
// If I remember correct Symfony Fullstack already does this
http://symfony.com/doc/current/components/debug/introduction.html
Then you could write a own Exception Handler, which catches and handles the exception in a user friendly way.

DotNetOpenAuth.Messaging.ProtocolException occurred

I created an asp.net MVC 4 Internet application and enabled Google authentication.
after successful login, always 'IsSuccessful' property value is false in OAuthWebSecurity.VerifyAuthentication method.
it is working fine when I run the same solution in an another machine.
I also turned off my firewall and tried, no luck.
I traced and found that some exception occurred in OAuthWebSecurity.VerifyAuthentication method.
Here is the exception detail:
DotNetOpenAuth.Messaging.ProtocolException occurred
HResult=-2146233088
Message=Web request to 'https://www.google.com/accounts/o8/ud' failed.
Source=DotNetOpenAuth.Core
Inner Exception:
The request was aborted: Could not create SSL/TLS secure channel.
I would really appreciate any help.

How to stop the entire java webapp when the servlet fails to initialize

I want my web application to fail on startup if any of my servlet fails to initialize.
I would expect if I throw an exception form the Servlet.init() method it would cause the entire app to fail, but apparently it doesn't. The web container (Tomcat 7 in my case) just fails to load that particular servlet, but the application is reported to be successfully deployed anyway.
It behaves as expected if an exception thrown from e.g. ServletContextListener.contextInitialized() method, but why the exception thrown from the Servlet.init() doesn't have this effect?
Is there any way to stop the application in case of a Servlet initialization error?
Try this following steps:
Keep your servlet in load-on-startup list such that your servlet
is initialized on application start.
In Servlet.init() method, set an attribute in ServletContext saying the servlet is initialzied. ex, myServletInited
Implement ServletContextListener.contextInitialzied() method. Check if myServletInited is present. If is does not present throw an exception which fails the application.

Throwing Exception with inner SecurityException only displays inner exception in ASP.NET MVC

If I add the following line to an ASP.NET MVC action method
throw new Exception("outer", new SecurityException("inner"));
the error that is actually displayed on the yellow screen of death is the inner SecurityException with absolutely no mention of the outer exception.
SecurityException
Description: The application attempted to perform an operation not
allowed by the security policy. To grant this application the
required permission please contact your system administrator or change
the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: inner
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[SecurityException: inner]
Is this expected behavior?
It doesn't seem to matter what type the outer exception is. Even if it is another SecurityException, the message is never displayed. The default SecurityException error message is so vague that I want to catch it and add some more specific information. This works fine if I do not include the original SecurityException as the innerException but ideally I would like to do this.
This behaviour originates in the ASP.NET "core", not in ASP.NET MVC. Unfortunately, the error formatter classes are internal, and the consuming types do not provide any extension points that would allow one to tweak the behaviour without replacing the error reporting mechanism. The workaround is to replace the default "yellow screen of death" page by a custom error page/view in which one exposes the information that one prefers.
This is exactly what one should usually be doing for production. In your case, it just means that you would have an alternate version for debug instead of using the ASP.NET-provided default.
in general you should never throw Exception class/object directly but only derived ones, for example:
throw new SecurityException("user should not be allowed to access this method...");
in a situation like this what are you missing in the log or in the page?
if you use an application global exception handler and you log from there with either Log4Net or NLog you should be able to access all exception chain from outer to inner and so on depending on how you configure and use the logging framework. The Yellow page of IIS / ASP.NET might not be complete but should show the stack trace anyway.
if you want to throw your own exception from a catch block you wrap the actual exception coming from the catch in this way:
throw new SecurityException("user should not be allowed...", exc);
Edit: tried what you suggested and got the following logged in a text file by Log4Net:
System.Security.SecurityException: more explicit exception --->
System.Security.SecurityException: original exception at
EDICheckerApp.Program.boom() in
C:\DEV_RPP\Program.cs:line 45
--- End of inner exception stack trace --- at EDICheckerApp.Program.boom() in
C:\DEV_RPP\Program.cs:line 49
at EDICheckerApp.Program.Main(String[] args) in
C:\DEV_RPP\Program.cs:line 27

Resources