Building a separate Web Client and Rest Service in Spring Boot. Making two separate apps. Trying to make an AJAX call from the client on http://localhost:8081/
and hit the rest service on http://localhost:8080/someURL/invokeMethod
which should invoke the rest service controller method and make a LOGGER.info()
out to the console. When I launch the page at http://localhost:8081/
the AJAX on the client should make a call to the service however I am unable to get a log out to the console from the controller getLogOut()
method on the rest service controller.
Rest Service Controller
package com.demo.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/someURL")
public class ServiceController {
private static final Logger LOGGER = LoggerFactory.getLogger(SearchController.class.getName());
@GetMapping("/invokeMethod")
public void getLogOut() {
LOGGER.info("/n/n/n/n/n***************LOGGER IN getLogOut************");
}
}
Web Client index.html :
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$.ajax({
url: "http://localhost:8080/someURL/invokeMethod"
});
});
</script>
</head>
<body>
<h1>Load Page to make ajax call</h1>
</body>
</html>
Web Client Controller :
package com.demo.Web.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping
public class WebController {
private static final Logger LOGGER = LoggerFactory.getLogger(WebController.class.getName());
@GetMapping("/")
public String viewPage() {
LOGGER.info("\n\n\n**********In Index**********");
return "index";
}
}
Not getting errors from the console. Just simply getting from console :
0:0:0:0:0:0:0:1 - - [06/Oct/2019:21:21:28 -0500] "GET /someURL/invokeMethod HTTP/1.1" 200 722
Not sure what above from console is trying tell me.
Stacktrace (should be complete)
[INFO]~2019-10-07-09.53.05.313CDT~~~~~~ c.e.h.RestServiceApplication Starting RestServiceApplication on 5CG9107HK6 with PID 162992
[INFO]~2019-10-07-09.53.05.317CDT~~~~~~ c.e.h.RestServiceApplication No active profile set, falling back to default profiles: default
[INFO]~2019-10-07-09.53.05.543CDT~~~~~~ o.s.b.d.e.DevToolsPropertyDefaultsPostProcessor Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
[INFO]~2019-10-07-09.53.05.544CDT~~~~~~ o.s.b.d.e.DevToolsPropertyDefaultsPostProcessor For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
[INFO]~2019-10-07-09.53.06.685CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$6e19173b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.692CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.694CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@cb177' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.701CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$92edb9ed] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.706CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'org.springframework.security.config.annotation.method.configuration.Jsr250MetadataSourceConfiguration' of type [org.springframework.security.config.annotation.method.configuration.Jsr250MetadataSourceConfiguration$$EnhancerBySpringCGLIB$$b842d203] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.707CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'jsr250MethodSecurityMetadataSource' of type [org.springframework.security.access.annotation.Jsr250MethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.06.708CDT~~~~~~ o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO]~2019-10-07-09.53.07.074CDT~~~~~~ o.s.b.w.e.t.TomcatWebServer Tomcat initialized with port(s): 8080 (http)
[INFO]~2019-10-07-09.53.07.092CDT~~~~~~ o.a.c.h.Http11NioProtocol Initializing ProtocolHandler ["http-nio-8080"]
[INFO]~2019-10-07-09.53.07.104CDT~~~~~~ o.a.c.c.StandardService Starting service [Tomcat]
[INFO]~2019-10-07-09.53.07.105CDT~~~~~~ o.a.c.core.StandardEngine Starting Servlet engine: [Apache Tomcat/9.0.26]
[INFO]~2019-10-07-09.53.07.225CDT~~~~~~ o.a.c.c.C.[.[.[/] Initializing Spring embedded WebApplicationContext
[INFO]~2019-10-07-09.53.07.225CDT~~~~~~ o.s.w.c.ContextLoader Root WebApplicationContext: initialization completed in 1681 ms
[INFO]~2019-10-07-09.53.07.962CDT~~~~~~ n.r.s.b.l.a.LogbackAccessContext Configured the Logback-access: context=[default], config=[classpath:logback-access.xml]
[INFO]~2019-10-07-09.53.08.093CDT~~~~~~ o.s.s.c.ThreadPoolTaskExecutor Initializing ExecutorService 'applicationTaskExecutor'
[INFO]~2019-10-07-09.53.08.334CDT~~~~~~ o.s.s.w.DefaultSecurityFilterChain Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@1c48ba2, org.springframework.security.web.context.SecurityContextPersistenceFilter@c57134, org.springframework.security.web.header.HeaderWriterFilter@1248239, org.springframework.security.web.csrf.CsrfFilter@183a2cf, org.springframework.security.web.authentication.logout.LogoutFilter@159fde7, com.edwardjones.framework.security.spring.wam.WamAuthenticationFilter@146ee78, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@261552, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@e0f96e, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@300ae4, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@44ff58, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@1de5909, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@15d7b9c, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@df7a4d, org.springframework.security.web.session.SessionManagementFilter@348fee, org.springframework.security.web.access.ExceptionTranslationFilter@13719ad, org.springframework.security.web.access.ExceptionTranslationFilter@b78775, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@1f01a41]
[INFO]~2019-10-07-09.53.08.807CDT~~~~~~ o.s.s.c.ThreadPoolTaskScheduler Initializing ExecutorService 'taskScheduler'
[INFO]~2019-10-07-09.53.08.836CDT~~~~~~ o.s.b.d.a.OptionalLiveReloadServer LiveReload server is running on port 35729
[INFO]~2019-10-07-09.53.08.843CDT~~~~~~ o.s.b.a.e.w.EndpointLinksResolver Exposing 2 endpoint(s) beneath base path '/actuator'
[INFO]~2019-10-07-09.53.08.889CDT~~~~~~ o.a.c.h.Http11NioProtocol Starting ProtocolHandler ["http-nio-8080"]
[INFO]~2019-10-07-09.53.08.996CDT~~~~~~ o.s.b.w.e.t.TomcatWebServer Tomcat started on port(s): 8080 (http) with context path ''
[INFO]~2019-10-07-09.53.09.001CDT~~~~~~ c.e.h.RestServiceApplication Started RestServiceApplication in 3.959 seconds (JVM running for 4.804)
[INFO]~2019-10-07-09.53.39.001CDT~~~~~~ o.a.c.c.C.[.[.[/] Initializing Spring DispatcherServlet 'dispatcherServlet'
[INFO]~2019-10-07-09.53.39.001CDT~~~~~~ o.s.w.s.DispatcherServlet Initializing Servlet 'dispatcherServlet'
[INFO]~2019-10-07-09.53.39.008CDT~~~~~~ o.s.w.s.DispatcherServlet Completed initialization in 7 ms
0:0:0:0:0:0:0:1 - - [07/Oct/2019:09:53:39 -0500] "GET /someURL/invokeMethod HTTP/1.1" 200 722