user404
user404

Reputation: 2028

Google oauth client exception on wildfly

I tried to integrate google calendar API with my project. Tested in local environment and it seems work fine. But when I deploy my .ear file on wildfly, it gives me the following error:

Stacktrace :

 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1) 2021-02-08
 11:26:06.187 ERROR o.s.a.i.SimpleAsyncUncaughtExceptionHandler -
 Unexpected exception occurred invoking async method: public void
 com.xyz.soa.serviceImpl.email.CalendarServiceImpl.createGoogleCalendarEvent(com.xyz.soa.model.EmailInfo)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)
 java.lang.NoClassDefFoundError: com/sun/net/httpserver/HttpHandler
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver$Builder.build(LocalServerReceiver.java:248)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 com.xyz.soa.serviceImpl.email.CalendarServiceImpl.getCredentials(CalendarServiceImpl.java:82)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 com.xyz.soa.serviceImpl.email.CalendarServiceImpl.getCalendar(CalendarServiceImpl.java:89)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 com.xyz.soa.serviceImpl.email.CalendarServiceImpl.createGoogleCalendarEvent(CalendarServiceImpl.java:103)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2021-02-08
 11:26:06,187 INFO  [stdout] ("async-thread-"1)     at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 java.lang.reflect.Method.invoke(Method.java:498) 2021-02-08
 11:26:06,187 INFO  [stdout] ("async-thread-"1)     at
 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 java.util.concurrent.FutureTask.run(FutureTask.java:266) 2021-02-08
 11:26:06,187 INFO  [stdout] ("async-thread-"1)     at
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 java.lang.Thread.run(Thread.java:745) 2021-02-08 11:26:06,187 INFO 
 [stdout] ("async-thread-"1) Caused by:
 java.lang.ClassNotFoundException: com.sun.net.httpserver.HttpHandler
 from [Module "deployment.project-api.war" from Service Module Loader]
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
 2021-02-08 11:26:06,187 INFO  [stdout] ("async-thread-"1)  at
 org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
 2021-02-08 11:26:06,188 INFO  [stdout] ("async-thread-"1)  ... 16
 common frames omitted

Google calendar lib that I have added :

 compile group: 'com.google.api-client', name: 'google-api-client', version: '1.31.0'
compile group: 'com.google.oauth-client', name: 'google-oauth-client-jetty', version: '1.31.0'
 compile group: 'com.google.apis', name: 'google-api-services-calendar', version: 'v3-rev411-1.25.0'

From the error I understand that, LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build(); this line is causing problem which is from google-oauth-client(note that, it works on local env.). So I checked my .ear package and found these libraries shown in the image. Note that, I found two jar files for oauth client! google oauth client lib
Please suggest how do I get rid of this ?

Upvotes: 1

Views: 356

Answers (1)

Maverick
Maverick

Reputation: 156

You are getting NoClassDefFoundError for com.sun.net.httpserver.HTTPHandler. Are you sure you have this in your packaged set of libraries?

Upvotes: 1

Related Questions