Swagger + Jersey + Grizzly - rest

I have been trying to generate REST API doc using Swagger.
Followed the link but couldn't make it work. Got below error's
12:54:39.859 [main] INFO org.reflections.Reflections - Reflections took 63 ms to scan 1 urls, producing 73 keys and 122 values
12:54:39.906 [main] DEBUG i.s.jaxrs.ext.SwaggerExtensions - adding extension io.swagger.jersey.SwaggerJersey2Jaxrs#18be6e8
12:54:39.906 [main] DEBUG io.swagger.jaxrs.Reader - picking up response class from method public rest.beans.UserBean rest.frontend.UserResource.opAllocateUser(rest.beans.UserBean,javax.ws.rs.core.Request)
12:54:39.921 [main] DEBUG i.s.c.ModelConverterContextImpl - resolveProperty class rest.beans.UserBean
12:54:39.921 [main] DEBUG io.swagger.jackson.ModelResolver - resolveProperty [simple type, class rest.beans.UserBean]
12:54:39.921 [main] DEBUG i.s.c.ModelConverterContextImpl - resolve [simple type, class rest.beans.UserBean]
12:54:39.921 [main] DEBUG i.s.c.ModelConverterContextImpl - trying extension io.swagger.jackson.ModelResolver#5ecce3
12:54:39.921 [main] DEBUG io.swagger.jackson.ModelResolver - Can't check class [simple type, class rest.beans.UserBean], rest.beans.UserBean
12:54:39.937 [main] DEBUG i.s.c.ModelConverterContextImpl - defineModel UserBean io.swagger.models.ModelImpl#c2b00fee
12:54:39.937 [main] DEBUG i.s.c.ModelConverterContextImpl - resolveProperty [simple type, class java.lang.String]
12:54:39.937 [main] DEBUG io.swagger.jackson.ModelResolver - Can't check class [simple type, class java.lang.String], java.lang.String
12:54:39.952 [main] DEBUG io.swagger.jackson.ModelResolver - resolveProperty [simple type, class java.lang.String]
12:54:39.952 [main] DEBUG i.s.c.ModelConverterContextImpl - resolveProperty [simple type, class java.lang.String]
12:54:39.952 [main] DEBUG io.swagger.jackson.ModelResolver - Can't check class [simple type, class java.lang.String], java.lang.String
12:54:39.952 [main] DEBUG io.swagger.jackson.ModelResolver - resolveProperty [simple type, class java.lang.String]
12:54:39.952 [main] DEBUG io.swagger.converter.ModelConverters - ModelConverters readAll from class rest.beans.UserBean
12:54:39.952 [main] DEBUG i.s.c.ModelConverterContextImpl - resolve class rest.beans.UserBean
12:54:39.952 [main] DEBUG i.s.c.ModelConverterContextImpl - trying extension io.swagger.jackson.ModelResolver#5ecce3
12:54:39.952 [main] DEBUG i.s.c.ModelConverterContextImpl - defineModel UserBean io.swagger.models.ModelImpl#c2b00fee
12:54:39.952 [main] DEBUG i.s.c.ModelConverterContextImpl - resolveProperty [simple type, class java.lang.String]
12:54:39.952 [main] DEBUG io.swagger.jackson.ModelResolver - Can't check class [simple type, class java.lang.String], java.lang.String
12:54:39.952 [main] DEBUG io.swagger.jackson.ModelResolver - resolveProperty [simple type, class java.lang.String]
12:54:39.952 [main] DEBUG i.s.c.ModelConverterContextImpl - resolveProperty [simple type, class java.lang.String]
12:54:39.952 [main] DEBUG io.swagger.jackson.ModelResolver - Can't check class [simple type, class java.lang.String], java.lang.String
12:54:39.952 [main] DEBUG io.swagger.jackson.ModelResolver - resolveProperty [simple type, class java.lang.String]
12:54:39.952 [main] DEBUG io.swagger.jaxrs.Reader - getParameters for [simple type, class rest.beans.UserBean]
12:54:39.952 [main] DEBUG io.swagger.jaxrs.Reader - trying extension io.swagger.jersey.SwaggerJersey2Jaxrs#18be6e8
Next searched and found link closest to my issue. Again followed it but still getting the above error. I can't see swagger.json getting generated.
Versions info
Jersey : 2.22.1
Jackson : 2.6.3
Swagger : 1.5.6
Grizzly : 2.3.23
Am I missing some configuration which is needed to make it work? Or Do I need more libraries?
Thanks

Statement : Generate Swagger UI for the listing of all the REST APIs through Grizzly and Jersey Application.
1. Add following dependency in pom.xml –
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>1.5.9</version>
</dependency>
2. Bundle Swagger UI and docs folder through you main application class using the below code –
package com.main;
import java.io.IOException;
import java.net.URI;
import org.glassfish.grizzly.http.server.CLStaticHttpHandler;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.grizzly.http.server.ServerConfiguration;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import io.swagger.jaxrs.config.BeanConfig;
public class MainApp {
// Base URI the Grizzly HTTP server will listen on
public static final URI BASE_URI = URI.create(“http://0.0.0.0:8080”);
public static HttpServer getLookupServer() {
String resources = “com.main”;
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion(“1.0.1”);
beanConfig.setSchemes(new String[] { “http” });
beanConfig.setBasePath(“”);
beanConfig.setResourcePackage(resources);
beanConfig.setScan(true);
final ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.packages(resources);
resourceConfig.register(io.swagger.jaxrs.listing.ApiListingResource.class);
resourceConfig.register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
resourceConfig.register(JacksonFeature.class);
resourceConfig.register(JacksonJsonProvider.class);
return GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig);
}
public static void main(String[] args) throws IOException {
final HttpServer server = getLookupServer();
server.start();
ClassLoader loader = MainApp.class.getClassLoader();
CLStaticHttpHandler docsHandler = new CLStaticHttpHandler(loader, “swagger-ui/”);
docsHandler.setFileCacheEnabled(false);
ServerConfiguration cfg = server.getServerConfiguration();
cfg.addHttpHandler(docsHandler, “/docs/”);
}
}
3. Take the latest code of swagger-ui. Copy all the content of the dist folder and create a folder named swagger-ui inside src/main/resources and paste all the copied contents. Now change the url in index.file which is inside the copied folder like below –
url: http://0.0.0.0:8080/swagger.json
4. Lastly, annotate your controller with #Api and #ApiOperation.
Hope it works. Now to run your Grizzly Jersey Application, go to browser and type localhost:8080/docs/. You will see Swagger UI having all the details of your REST APIs.
Happy coding and sharing as well. 🙂 You can find the [git](https://guptakumartanuj.wordpress.com/2017/07/24/generate-swagger-ui-through-grizzly-and-jersey-application/) repo for the above implementation.

Related

Pi4J v2 SPI w/ GPIO Pin

I'm trying to use Pi4J to talk to an SPI device where the CS pin is a GPIO pin (GPIO 5) and not one of the mapped CS pins. I don't see how to configure it this way in any of the examples or javadocs. I think it would be somewhere on my SpiConfig line.
// Initialize Pi4J with an auto context
// An auto context includes AUTO-DETECT BINDINGS enabled
// which will load all detected Pi4J extension libraries
// (Platforms and Providers) in the class path
var pi4j = Pi4J.newAutoContext();
// create SPI config
SpiConfig config = Spi.newConfigBuilder(pi4j).id("thermocouple-1")
.name("Thermocouple 1").bus(SpiBus.BUS_1)
.chipSelect(SpiChipSelect.CS_0).build();
// get a SPI I/O provider from the Pi4J context
SpiProvider spiProvider = pi4j.provider("pigpio-spi");
// use try-with-resources to auto-close SPI when complete
try (Spi spi = spiProvider.create(config)) {
byte data[] = new byte[]{0, 0, 0, 0};
It looks like this is possible with v1 of the library, but it's not the same in v2.
I ended up posting on the pi4j project on GitHub and through those conversations worked out what I needed. Here is a cross post from there.
Well looking at the DAC8552 example was the key. Here is a working
version that asks the device for it's ID (register 0xD0) and gives the
correct answer for BME280 (0x60). Thanks for the assist. Here is the
working code (needs to be cleaned up, but it's a basic start).
package com.pi4j.example.spi;
import com.pi4j.Pi4J;
import com.pi4j.context.Context;
import com.pi4j.io.gpio.digital.DigitalOutput;
import com.pi4j.io.gpio.digital.DigitalState;
import com.pi4j.io.spi.Spi;
import com.pi4j.io.spi.SpiBus;
import com.pi4j.io.spi.SpiChipSelect;
import com.pi4j.io.spi.SpiMode;
import com.pi4j.util.Console;
import com.pi4j.util.StringUtil;
public class BmeTest {
private static final SpiBus spiBus = SpiBus.BUS_0;
public static void main(String[] args) throws Exception {
final var console = new Console();
// print program title/header
console.title("<-- The Pi4J Project -->",
"Basic SPI Communications Example");
Context pi4j = Pi4J.newAutoContext();
var spiConfig = Spi.newConfigBuilder(pi4j)
.id("SPI" + spiBus + "_BME280")
.name("BME280")
.bus(spiBus)
.chipSelect(SpiChipSelect.CS_0) // not used
.mode(SpiMode.MODE_0)
.provider("pigpio-spi")
.build();
// required all configs
var outputConfig = DigitalOutput.newConfigBuilder(pi4j)
.id("CS_GPIO5")
.name("CS GPIO5")
.address(5)
.shutdown(DigitalState.HIGH)
.initial(DigitalState.HIGH)
.provider("pigpio-digital-output");
DigitalOutput csGpio = null;
try {
csGpio = pi4j.create(outputConfig);
} catch (Exception e) {
e.printStackTrace();
console.println("create DigOut DRDY failed");
System.exit(202);
}
// use try-with-resources to auto-close SPI when complete
try (var spi = pi4j.create(spiConfig)) {
byte data[] = new byte[] { (byte) (0x80 | 0xD0), (byte) 0x00 };
csGpio.high();
csGpio.low();
spi.transfer(data, data);
csGpio.high();
// take a breath to allow time for the SPI
// data to get updated in the SPI device
Thread.sleep(100);
// read data back from the SPI channel
console.println("--------------------------------------");
console.println("SPI [READ] :");
console.println(" [BYTES] 0x" + StringUtil.toHexString(data));
console.println(" [STRING] " + new String(data));
console.println("--------------------------------------");
}
// shutdown Pi4J
console.println("ATTEMPTING TO SHUTDOWN/TERMINATE THIS PROGRAM");
pi4j.shutdown();
}
}
With the following output:
[main] INFO com.pi4j.util.Console - ************************************************************
[main] INFO com.pi4j.util.Console - ************************************************************
[main] INFO com.pi4j.util.Console -
[main] INFO com.pi4j.util.Console - <-- The Pi4J Project -->
[main] INFO com.pi4j.util.Console - Basic SPI Communications Example
[main] INFO com.pi4j.util.Console -
[main] INFO com.pi4j.util.Console - ************************************************************
[main] INFO com.pi4j.util.Console - ************************************************************
[main] INFO com.pi4j.util.Console -
[main] INFO com.pi4j.Pi4J - New auto context
[main] INFO com.pi4j.Pi4J - New context builder
[main] INFO com.pi4j.platform.impl.DefaultRuntimePlatforms - adding platform to managed platform map [id=raspberrypi; name=RaspberryPi Platform; priority=5; class=com.pi4j.plugin.raspberrypi.platform.RaspberryPiPlatform]
[main] INFO com.pi4j.util.Console - --------------------------------------
[main] INFO com.pi4j.util.Console - SPI [READ] :
[main] INFO com.pi4j.util.Console - [BYTES] 0xFF 60
[main] INFO com.pi4j.util.Console - [STRING] �`
[main] INFO com.pi4j.util.Console - --------------------------------------
[main] INFO com.pi4j.util.Console - ATTEMPTING TO SHUTDOWN/TERMINATE THIS PROGRAM

Spring Boot actuator default endpoints not starting: /info, /metrics/, /health

I'm running a Spring Boot 1.5.9-RELEASE app. I used Pivotal's maven archetype which includes both spring boot & spring actuator and also all of the necessary dependencies. I've also posted the output of the start-up logs with org.springframework logging turned up to INFO level. Why aren't these default endpoints which according to spring docs are supposed to be starting not starting? I'd really appreciate your input. I've also posted my application.properties file. when i hit the endpoint in postman i get the following response:
{
"timestamp": 1515490133441,
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/info"
}
application.properties:
server.port=7299
security.user.password=password
num.to.output=1000
occurrence.of.garbage=9
endpoints.shutdown.enabled=true
endpoints.info.sensitive=false
output of start-up logs:
10:31:54,332 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
10:31:54,332 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
10:31:54,332 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/Users/zenith/Documents/workspace/wsjoiner-service/target/classes/logback.xml]
10:31:54,382 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
10:31:54,383 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
10:31:54,388 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
10:31:54,424 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead.
10:31:54,424 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
10:31:54,424 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
10:31:54,424 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
10:31:54,426 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [ROLLING_FILE]
10:31:54,430 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy#1073502961 - No compression will be used
10:31:54,431 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy#1073502961 - Will use the pattern logs/WSJoinerServiceApp.%d{dd-MM-yyyy}.log for the active file
10:31:54,434 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'dd-MM-yyyy' from file name pattern 'logs/WSJoinerServiceApp.%d{dd-MM-yyyy}.log'.
10:31:54,434 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
10:31:54,436 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Jan 09 10:29:37 CET 2018
10:31:54,437 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
10:31:54,439 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ROLLING_FILE] - Active log file name: logs/WSJoinerServiceApp.log
10:31:54,439 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ROLLING_FILE] - File property is set to [logs/WSJoinerServiceApp.log]
10:31:54,440 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework] to INFO
10:31:54,440 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.blairtech.wsjoiner] to INFO
10:31:54,440 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.blairtech.wsjoiner] to false
10:31:54,440 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[com.blairtech.wsjoiner]
10:31:54,441 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [ROLLING_FILE] to Logger[com.blairtech.wsjoiner]
10:31:54,441 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to WARN
10:31:54,441 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
10:31:54,441 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [ROLLING_FILE] to Logger[ROOT]
10:31:54,441 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
10:31:54,441 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator#5e5792a0 - Registering current configuration as safe fallback point
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.9.RELEASE)
2018-01-09 10:31:54 [main] INFO c.b.wsjoiner.WSJoinerServiceApp - Starting WSJoinerServiceApp on z-macdaddy.local with PID 24339 (/Users/zenith/Documents/workspace/wsjoiner-service/target/classes started by zenith in /Users/zenith/Documents/workspace/wsjoiner-service)
2018-01-09 10:31:54 [main] INFO c.b.wsjoiner.WSJoinerServiceApp - No active profile set, falling back to default profiles: default
2018-01-09 10:31:54 [main] INFO o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#7fc2413d: startup date [Tue Jan 09 10:31:54 CET 2018]; root of context hierarchy
2018-01-09 10:31:54 [main] INFO o.s.b.f.s.DefaultListableBeanFactory - Overriding bean definition for bean 'jsonResponseGenerator' with a different definition: replacing [Generic bean: class [com.blairtech.wsjoiner.response.JsonResponseGenerator]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [/Users/zenith/Documents/workspace/wsjoiner-io/target/classes/com/blairtech/wsjoiner/response/JsonResponseGenerator.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=WSJoinerIOConfig; factoryMethodName=jsonResponseGenerator; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/blairtech/wsjoiner/WSJoinerIOConfig.class]]
2018-01-09 10:31:54 [main] INFO o.s.b.f.s.DefaultListableBeanFactory - Overriding bean definition for bean 'xmlResponseGenerator' with a different definition: replacing [Generic bean: class [com.blairtech.wsjoiner.response.XmlResponseGenerator]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [/Users/zenith/Documents/workspace/wsjoiner-io/target/classes/com/blairtech/wsjoiner/response/XmlResponseGenerator.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=WSJoinerIOConfig; factoryMethodName=xmlResponseGenerator; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/blairtech/wsjoiner/WSJoinerIOConfig.class]]
2018-01-09 10:31:55 [main] INFO o.s.b.c.e.t.TomcatEmbeddedServletContainer - Tomcat initialized with port(s): 7299 (http)
2018-01-09 10:31:55 [localhost-startStop-1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 870 ms
2018-01-09 10:31:55 [localhost-startStop-1] INFO o.s.b.w.s.FilterRegistrationBean - Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-09 10:31:55 [localhost-startStop-1] INFO o.s.b.w.s.FilterRegistrationBean - Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-01-09 10:31:55 [localhost-startStop-1] INFO o.s.b.w.s.FilterRegistrationBean - Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-01-09 10:31:55 [localhost-startStop-1] INFO o.s.b.w.s.FilterRegistrationBean - Mapping filter: 'requestContextFilter' to: [/*]
2018-01-09 10:31:55 [localhost-startStop-1] INFO o.s.b.w.s.DelegatingFilterProxyRegistrationBean - Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-01-09 10:31:55 [localhost-startStop-1] INFO o.s.b.w.s.ServletRegistrationBean - Mapping servlet: 'dispatcherServlet' to [/]
2018-01-09 10:31:56 [main] INFO o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#7fc2413d: startup date [Tue Jan 09 10:31:54 CET 2018]; root of context hierarchy
2018-01-09 10:31:56 [main] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/sink/a],methods=[POST],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<com.blairtech.wsjoiner.messages.WSSinkResponseMessage> com.blairtech.wsjoiner.controller.WSJoinerSinkController.postRequest(com.blairtech.wsjoiner.messages.WSSinkInputMessage)
2018-01-09 10:31:56 [main] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/source/a],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<java.lang.String> com.blairtech.wsjoiner.controller.WSJoinerSourceController.jsonRequest()
2018-01-09 10:31:56 [main] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/source/b],methods=[GET],produces=[application/xml]}" onto public org.springframework.http.ResponseEntity<java.lang.String> com.blairtech.wsjoiner.controller.WSJoinerSourceController.xmlRequest()
2018-01-09 10:31:56 [main] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-01-09 10:31:56 [main] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-01-09 10:31:56 [main] INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-09 10:31:56 [main] INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-09 10:31:56 [main] INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-09 10:31:56 [main] INFO o.s.s.web.DefaultSecurityFilterChain - Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/css/**'], Ant [pattern='/js/**'], Ant [pattern='/images/**'], Ant [pattern='/webjars/**'], Ant [pattern='/**/favicon.ico'], Ant [pattern='/error']]], []
2018-01-09 10:31:56 [main] INFO o.s.s.web.DefaultSecurityFilterChain - Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/**']]], [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#6d171ce0, org.springframework.security.web.context.SecurityContextPersistenceFilter#5bb7643d, org.springframework.security.web.header.HeaderWriterFilter#2c306a57, org.springframework.security.web.authentication.logout.LogoutFilter#7a2e0858, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#6edcd0d8, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#4074023c, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#5b12012e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#22bd2039, org.springframework.security.web.session.SessionManagementFilter#38eb2fb0, org.springframework.security.web.access.ExceptionTranslationFilter#723ed581, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#9a2ec9b]
2018-01-09 10:31:56 [main] INFO o.s.j.e.a.AnnotationMBeanExporter - Registering beans for JMX exposure on startup
2018-01-09 10:31:56 [main] INFO o.s.b.c.e.t.TomcatEmbeddedServletContainer - Tomcat started on port(s): 7299 (http)
2018-01-09 10:31:56 [main] INFO c.b.wsjoiner.WSJoinerServiceApp - Started
WSJoinerServiceApp in 2.011 seconds (JVM running for 2.74)
If you create a project with Spring Boot 1.5.9 and the dependencies Web and Actuator at http://start.spring.io/ and afterwards use your application.properties, the endpoint http://localhost:7299/info is available and returns
{}
Therefore, I suggest that you create such a project at http://start.spring.io/ and compare it to your setup or that you directly start from the generated project.
The actuator endpoints are also listed in the logs and this part is missing from your logs:
2018-01-10 08:46:36.840 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/shutdown || /shutdown.json],methods=[POST],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.ShutdownMvcEndpoint.invoke()
2018-01-10 08:46:36.841 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.846 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/loggers/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.get(java.lang.String)
2018-01-10 08:46:36.846 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/loggers/{name:.*}],methods=[POST],consumes=[application/vnd.spring-boot.actuator.v1+json || application/json],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.set(java.lang.String,java.util.Map<java.lang.String, java.lang.String>)
2018-01-10 08:46:36.846 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/loggers || /loggers.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.847 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/health || /health.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(javax.servlet.http.HttpServletRequest,java.security.Principal)
2018-01-10 08:46:36.848 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2018-01-10 08:46:36.850 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env || /env.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.854 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.856 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2018-01-10 08:46:36.856 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.862 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/auditevents || /auditevents.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public org.springframework.http.ResponseEntity<?> org.springframework.boot.actuate.endpoint.mvc.AuditEventsMvcEndpoint.findByPrincipalAndAfterAndType(java.lang.String,java.util.Date,java.lang.String)
2018-01-10 08:46:36.863 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.865 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException
2018-01-10 08:46:36.866 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.868 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.869 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/info || /info.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.870 INFO 17243 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()

My execution halts while implemented the Data Driven Approach

I have included few lines of code for data driven, where I will fetch the details from a Excel sheet and it will pass to the script in Run Time. Here my script won't execute and it hangs after returning the message in Eclipse Console:
Returning cached instance of singleton bean 'todoClient1'
Below attached the Code and package com.consol.citrus.integration.Demo.
import java.util.Hashtable;
import org.apache.log4j.helpers.SyslogWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.ImportResource;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.testng.SkipException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import com.consol.citrus.TestCaseMetaInfo.Status;
import com.consol.citrus.annotations.CitrusTest;
import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;
import com.consol.citrus.http.client.HttpClient;
import com.consol.citrus.message.MessageType;
public class UnSuccessFullLogin extends TestNGCitrusTestDesigner {
#Autowired (required=true)
#Qualifier("todoClient1")
private HttpClient todoClient1;
public Xls_Reader xls=new Xls_Reader(Constants.DATA_XLS_PATH);
String testCaseName="UnSuccessFullLogin";
public String actualResult="";
#CitrusTest
#Test(dataProvider="getData")
public void TestPost(Hashtable<String, String> data) {
echo("i am entered");
variable("Uname", "admin2");
variable("Pwd", "admin");
if(!DataUtil.isTestExecutable(xls, testCaseName) || data.get(Constants.RUNMODE_COL).equals("N")){
throw new SkipException("Skipping the test as Rnumode is N");
}
http()
.client(todoClient1)
.send()
.post("/rest/api/user/login")
.contentType("application/json")
// .payload("{ \"userName\": \"${uN}\", \"password\": \"${pwd}\"}");
.payload("{ \"userName\": \"${Uname}\", \"password\": \"${Pwd}\"}");
http()
.client(todoClient1)
.receive()
.response(HttpStatus.ACCEPTED)
.validate("$.statusCode", "400");
}
#DataProvider
public Object[][] getData()
{
return DataUtil.getData(xls, testCaseName);
}
}
Log Here:
17:37:56,650 DEBUG tListableBeanFactory| Creating shared instance of singleton bean 'todoClient'
17:37:56,650 DEBUG tListableBeanFactory| Creating instance of bean 'todoClient'
17:37:56,651 DEBUG tListableBeanFactory| Returning cached instance of singleton bean 'todoClientConfiguration'
17:37:56,675 DEBUG tListableBeanFactory| Eagerly caching bean 'todoClient' to allow for resolving potential circular references
17:37:56,690 DEBUG tListableBeanFactory| Finished creating instance of bean 'todoClient'
17:37:56,690 DEBUG tListableBeanFactory| Creating shared instance of singleton bean 'todoClient1Configuration'
17:37:56,690 DEBUG tListableBeanFactory| Creating instance of bean 'todoClient1Configuration'
17:37:56,691 DEBUG tListableBeanFactory| Eagerly caching bean 'todoClient1Configuration' to allow for resolving potential circular references
17:37:56,697 DEBUG tListableBeanFactory| Finished creating instance of bean 'todoClient1Configuration'
17:37:56,697 DEBUG tListableBeanFactory| Creating shared instance of singleton bean 'todoClient1'
17:37:56,697 DEBUG tListableBeanFactory| Creating instance of bean 'todoClient1'
17:37:56,697 DEBUG tListableBeanFactory| Returning cached instance of singleton bean 'todoClient1Configuration'
17:37:56,699 DEBUG tListableBeanFactory| Eagerly caching bean 'todoClient1' to allow for resolving potential circular references
17:37:56,699 DEBUG tListableBeanFactory| Finished creating instance of bean 'todoClient1'
17:37:56,699 DEBUG tListableBeanFactory| Returning cached instance of singleton bean 'globalVariables'
17:37:56,699 DEBUG tListableBeanFactory| Returning cached instance of singleton bean 'com.consol.citrus.report.MessageTracingTestListener#1'
17:37:56,700 DEBUG tListableBeanFactory| Returning cached instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory'
17:37:56,851 DEBUG icApplicationContext| Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor#655a5d9c]
17:37:56,852 DEBUG tListableBeanFactory| Returning cached instance of singleton bean 'lifecycleProcessor'
17:37:56,856 DEBUG rcesPropertyResolver| Could not find key 'spring.liveBeansView.mbeanDomain' in any property source
17:37:56,866 DEBUG ontextLoaderDelegate| Storing ApplicationContext in cache under key [[MergedContextConfiguration#7bd7d6d6 testClass = UnSuccessFullLogin, locations = '{}', classes = '{class com.consol.citrus.config.CitrusSpringConfig}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]]
17:37:56,866 DEBUG context.cache| Spring test ApplicationContext cache statistics: [DefaultContextCache#1a6f2363 size = 1, maxSize = 32, parentContextCount = 0, hitCount = 0, missCount = 1]
17:37:56,939 DEBUG on.InjectionMetadata| Processing injected element of bean 'com.consol.citrus.integration.Demo.UnSuccessFullLogin': AutowiredFieldElement for private com.consol.citrus.http.client.HttpClient com.consol.citrus.integration.Demo.UnSuccessFullLogin.todoClient1
17:37:56,942 DEBUG tListableBeanFactory| Returning cached instance of singleton bean 'todoClient1'
17:37:56,942 DEBUG ionBeanPostProcessor| Autowiring by type from bean name 'com.consol.citrus.integration.Demo.UnSuccessFullLogin' to bean named 'todoClient1'
17:37:56,947 DEBUG tListableBeanFactory| Returning cached instance of singleton bean 'testSuiteListeners'
17:37:56,947 DEBUG tListableBeanFactory| Returning cached instance of singleton bean 'testContextFactory'
5876 [main] INFO com.consol.citrus.Citrus -
5876 [main] INFO com.consol.citrus.Citrus - ------------------------------------------------------------------------
5876 [main] INFO com.consol.citrus.Citrus - .__ __
5876 [main] INFO com.consol.citrus.Citrus - ____ |__|/ |________ __ __ ______
5876 [main] INFO com.consol.citrus.Citrus - _/ ___\| \ __\_ __ \ | \/ ___/
5876 [main] INFO com.consol.citrus.Citrus - \ \___| || | | | \/ | /\___ \
5876 [main] INFO com.consol.citrus.Citrus - \___ >__||__| |__| |____//____ >
5876 [main] INFO com.consol.citrus.Citrus - \/ \/
5876 [main] INFO com.consol.citrus.Citrus -
5876 [main] INFO com.consol.citrus.Citrus - C I T R U S T E S T S 2.7.2
5876 [main] INFO com.consol.citrus.Citrus -
5876 [main] INFO com.consol.citrus.Citrus - ------------------------------------------------------------------------
5876 [main] INFO com.consol.citrus.Citrus -
5876 [main] INFO com.consol.citrus.Citrus -
5876 [main] INFO com.consol.citrus.Citrus - BEFORE TEST SUITE: SUCCESS
5876 [main] INFO com.consol.citrus.Citrus - ------------------------------------------------------------------------
5876 [main] INFO com.consol.citrus.Citrus -
17:37:56,974 DEBUG estExecutionListener| Before test class: context [DefaultTestContext#740fb309 testClass = UnSuccessFullLogin, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration#7bd7d6d6 testClass = UnSuccessFullLogin, locations = '{}', classes = '{class com.consol.citrus.config.CitrusSpringConfig}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]], class annotated with #DirtiesContext [false] with mode [null].
17:37:56,975 DEBUG estExecutionListener| Performing dependency injection for test context [[DefaultTestContext#740fb309 testClass = UnSuccessFullLogin, testInstance = com.consol.citrus.integration.Demo.UnSuccessFullLogin#5524cca1, testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration#7bd7d6d6 testClass = UnSuccessFullLogin, locations = '{}', classes = '{class com.consol.citrus.config.CitrusSpringConfig}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]]].
17:37:56,975 DEBUG ontextLoaderDelegate| Retrieved ApplicationContext from cache with key [[MergedContextConfiguration#7bd7d6d6 testClass = UnSuccessFullLogin, locations = '{}', classes = '{class com.consol.citrus.config.CitrusSpringConfig}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]]
17:37:56,975 DEBUG context.cache| Spring test ApplicationContext cache statistics: [DefaultContextCache#1a6f2363 size = 1, maxSize = 32, parentContextCount = 0, hitCount = 1, missCount = 1]
17:37:56,976 DEBUG on.InjectionMetadata| Processing injected element of bean 'com.consol.citrus.integration.Demo.UnSuccessFullLogin': AutowiredFieldElement for private com.consol.citrus.http.client.HttpClient com.consol.citrus.integration.Demo.UnSuccessFullLogin.todoClient1
17:37:56,976 DEBUG tListableBeanFactory| Returning cached instance of singleton bean 'todoClient1'
Please see the following working sample how to use TestNG data provider with Citrus:
public class DataProviderJavaIT extends TestNGCitrusTestDesigner {
#CitrusTest
#CitrusParameters( {"message", "delay"} )
#Test(dataProvider = "sampleDataProvider")
public void dataProvider(String message, Long sleep) {
echo(message);
sleep(sleep);
echo("${message}");
echo("${delay}");
}
#DataProvider
public Object[][] sampleDataProvider() {
return new Object[][] {
{ "Hello World!", 300L },
{ "Hallo Welt!", 1000L },
{ "Hallo Citrus!", 500L },
};
}
}
According to the sample you are missing the #CitrusParameters annotation that translates data provider arguments to Citrus test variables.

FactType.getFields return no fields drools KIE

I have created a fact type( CustomerFact ) with two fact fields(age and bonus) . A sample rule is also created using workbench. Now, I want to inject some test values and check whether the rules are getting fired. I used Eclipse IDE.
I am able to retrieve package name and the rule created in workbench in my java code. However, I am enable to get any fact fields. GetFields always returns an empty list whereas it should have returned 2 fields. Is there any alternative to this? I just want to set the field of the fact type and see whether the rules are getting fired. Any help is highly appreciated.
package org.demo.cityproject;
/**
* This class was automatically generated by the data modeler tool.
*/
public class CustomerFact implements java.io.Serializable
{
static final long serialVersionUID = 1L;
#org.kie.api.definition.type.Key
private int age;
#org.kie.api.definition.type.Key
private int bonus;
public CustomerFact()
{
}
public int getAge()
{
return this.age;
}
public void setAge(int age)
{
this.age = age;
}
public int getBonus()
{
return this.bonus;
}
public void setBonus(int bonus)
{
this.bonus = bonus;
}
public CustomerFact(int age, int bonus)
{
this.age = age;
this.bonus = bonus;
}
#Override
public boolean equals(Object o)
{
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
org.demo.cityproject.CustomerFact that = (org.demo.cityproject.CustomerFact) o;
if (age != that.age)
return false;
if (bonus != that.bonus)
return false;
return true;
}
#Override
public int hashCode()
{
int result = 17;
result = 31 * result + age;
result = 31 * result + bonus;
return result;
}
}
Test Code
public static void main(String[] args)
{
String url = "http://localhost:8080/kie-drools-wb-distribution-wars-6.2.0.Final-jboss-as7/maven2/Project1/org/demo/CityProject/1.0/CityProject-1.0.jar";
ReleaseIdImpl releaseId = new ReleaseIdImpl("org.demo", "CityProject", "LATEST");
KieServices kieServices = KieServices.Factory.get();
kieServices.getResources().newUrlResource(url);
KieContainer kieContainer = kieServices.newKieContainer(releaseId);
KieScanner kieScanner = kieServices.newKieScanner(kieContainer);
kieScanner.scanNow();
Scanner scanner = new Scanner(System.in);
System.out.println("kieContainer.getKieBaseNames() "+kieContainer.getKieBaseNames());
KieSession newKieSession =kieContainer.newKieSession("session1");
KieBase lKieBase=newKieSession.getKieBase();
System.out.println("lPackage "+lKieBase.getKiePackages());
KiePackage lPackage=lKieBase.getKiePackage("org.demo.cityproject");
System.out.println("lPackage FactTypes: "+lPackage.getFactTypes());
for(FactType lFact:lPackage.getFactTypes())
{
System.out.println("lFacts: "+lFact.getName());
System.out.println("lFacts Fields: "+lFact.getFields());
}
}
Console o/p in eclipse
22:58:28.998 [main] DEBUG o.d.c.k.b.impl.KieRepositoryImpl - KieModule Lookup. ReleaseId org.demo:CityProject:LATEST was not in cache, checking maven repository
22:58:37.430 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\USER\.m2\repository
22:58:37.743 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\USER\.m2\repository
22:58:39.455 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\USER\.m2\repository
22:58:39.503 [main] DEBUG o.e.a.i.i.DefaultUpdateCheckManager - Skipped remote request for org.demo:CityProject/maven-metadata.xml, locally installed metadata up-to-date.
22:58:39.503 [main] DEBUG o.e.a.i.i.DefaultUpdateCheckManager - Skipped remote request for org.demo:CityProject/maven-metadata.xml, locally installed metadata up-to-date.
22:58:39.503 [main] DEBUG o.e.a.i.i.DefaultUpdateCheckManager - Skipped remote request for org.demo:CityProject/maven-metadata.xml, locally installed metadata up-to-date.
22:58:41.744 [main] DEBUG o.e.a.i.i.DefaultDependencyCollector - Dependency collection stats: {ConflictMarker.analyzeTime=0, ConflictMarker.markTime=0, ConflictMarker.nodeCount=1, ConflictIdSorter.graphTime=0, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=1, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=0, ConflictResolver.conflictItemCount=1, DefaultDependencyCollector.collectTime=32, DefaultDependencyCollector.transformTime=15}
22:58:42.230 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\USER\.m2\repository
22:58:42.230 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\USER\.m2\repository
22:58:42.246 [main] DEBUG o.e.a.i.i.DefaultDependencyCollector - Dependency collection stats: {ConflictMarker.analyzeTime=0, ConflictMarker.markTime=0, ConflictMarker.nodeCount=1, ConflictIdSorter.graphTime=0, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=0, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=0, ConflictResolver.conflictItemCount=0, DefaultDependencyCollector.collectTime=0, DefaultDependencyCollector.transformTime=0}
22:58:47.596 [main] INFO o.d.c.k.b.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=org.demo:CityProject:1.0,file=C:\Users\USER\.m2\repository\org\demo\CityProject\1.0\CityProject-1.0.jar]
22:58:47.957 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\USER\.m2\repository
22:58:47.957 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\USER\.m2\repository
22:58:47.957 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\USER\.m2\repository
22:58:48.426 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\USER\.m2\repository
22:58:48.442 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\USER\.m2\repository
22:58:48.457 [main] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\USER\.m2\repository
22:58:48.457 [main] DEBUG o.e.a.i.i.DefaultUpdateCheckManager - Skipped remote request for org.demo:CityProject/maven-metadata.xml, locally installed metadata up-to-date.
22:58:48.457 [main] DEBUG o.e.a.i.i.DefaultUpdateCheckManager - Skipped remote request for org.demo:CityProject/maven-metadata.xml, locally installed metadata up-to-date.
22:58:48.457 [main] DEBUG o.e.a.i.i.DefaultUpdateCheckManager - Skipped remote request for org.demo:CityProject/maven-metadata.xml, locally installed metadata up-to-date.
kieContainer.getKieBaseNames() [KnowledgeBaseALL]
22:58:50.532 [main] DEBUG o.drools.core.impl.KnowledgeBaseImpl - Starting Engine in PHREAK mode
lPackage [[Package name=org.demo.cityproject]]
lPackage FactTypes: [ClassDefinition{className='org.demo.cityproject.CustomerFact', superClass='java.lang.Object', interfaces=[java.io.Serializable], definedClass=class org.demo.cityproject.CustomerFact, traitable=null, abstract=false, fields={}, annotations=null}]
lFacts: org.demo.cityproject.CustomerFact
**lFacts Fields: []**
As you can see in the output fact field is empty.
The - rather disappointing - situation is that there are two or even three kinds of FactTypes:
Fact types defined by a declare statement in a DRL file
Fact types resulting from Java classes and imported explicitly or implicitly
JDK types used as fact types
Method getFactTypes does not return #3. Method getFields returns an empty list for #2.
Finally I found an answer. Such fields can be invoked by reflection.
Here is how the rules get triggered
for(FactType lFct:lusedpackage.getFactTypes())
{
// System.out.println("Customer class "+lFct.getFactClass());
**Constructor constructor=lFct.getFactClass().getConstructor(String.class,java.math.BigInteger.class);**
**Object s1=constructor.newInstance(lcity,lcustomerID);**
//System.out.println("constructor "+constructor);
//System.out.println("Object "+s1);
**Method lCustID=lFct.getFactClass().getMethod("getCustomerID");**
System.out.println("*************************************************************");
System.out.println("Customer value before firing the rule: "+ lCustID.invoke(s1));
**Method setCity = lFct.getFactClass().getMethod("getCity");**
System.out.println("City value before firing the rule: "+ setCity.invoke(s1));
//System.out.println("method "+lCustID);
System.out.println("*************************************************************");
newKieSession.insert(s1);
newKieSession.fireAllRules();
System.out.println("Customer value after firing the rule: "+ **lCustID.invoke(s1)**);
System.out.println("City value after firing the rule: "+ setCity.invoke(s1));
System.out.println("*************************************************************");
}

Almost identical Spring Rest request return different responses, how to understand Spring trace?

I have two almost identical controllers connecting to two different JPA Spring data repositories. The JPA request work correctly, been tested.
I have other request on the same server that works perfectly. Why two different requests that are almost identical don't response with a correct response?
How I can find tips from Spring trace about this problem? I get a Status not found for a request:
type Status report
message /hospital/EditWard/HOSP1/
description The requested resource is not available.
In the console I see this trace:
2015-03-06 11:45:16,686 DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'dispatcher' processing GET request for [/hospital/EditWard/HOSP1/]
2015-03-06 11:45:16,686 DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'dispatcher' processing GET request for [/hospital/EditWard/HOSP1/]
2015-03-06 11:45:16,687 DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Looking up handler method for path /EditWard/HOSP1/
2015-03-06 11:45:16,687 DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Looking up handler method for path /EditWard/HOSP1/
2015-03-06 11:45:16,689 DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Did not find handler method for [/EditWard/HOSP1/]
2015-03-06 11:45:16,689 DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Did not find handler method for [/EditWard/HOSP1/]
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Matching patterns for request [/EditWard/HOSP1/] are [/**]
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Matching patterns for request [/EditWard/HOSP1/] are [/**]
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - URI Template variables for request [/EditWard/HOSP1/] are {}
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - URI Template variables for request [/EditWard/HOSP1/] are {}
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapping [/EditWard/HOSP1/] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#23c3853d] and 1 interceptor
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapping [/EditWard/HOSP1/] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#23c3853d] and 1 interceptor
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Last-Modified value for [/hospital/EditWard/HOSP1/] is: -1
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Last-Modified value for [/hospital/EditWard/HOSP1/] is: -1
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
2015-03-06 11:45:16,690 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
This is my controller:
package com.freschelegacy.controller;
import java.util.Date;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.freschelegacy.model.Ward;
import com.freschelegacy.model.WardId;
import com.freschelegacy.service.WardService;
import com.freschelegacy.service.data.EditWardDTO;
import com.freschelegacy.service.ServiceException;
import com.freschelegacy.repository.WardRepository;
#RestController()
public class EditWardController {
#Autowired
private WardRepository wardRepository;
#Autowired
private WardService wardService;
private final Logger logger = LoggerFactory.getLogger(EditWardController.class);
#Transactional(readOnly=true)
#RequestMapping(value = "/EditWard", method=RequestMethod.GET, produces = "application/json;charset=utf-8")
public Page<EditWardDTO> getEditWard(#PathVariable String hospitalCode, #RequestParam(value= "page", required = false, defaultValue = "0" ) int page,
#RequestParam(value = "size", required = false, defaultValue = "10" ) int size){
Pageable pageable = new PageRequest(page, size);
Page<EditWardDTO> pageEditWard = wardRepository.editWard(hospitalCode, pageable);
return pageEditWard;
}
}
I have added this /{hospitalCode) to the value of the #Request mapping. Now it works.
#RequestMapping(value ="/EditWard/{hospitalCode}", method=RequestMethod.GET, produces = "application/json;charset=utf-8")