maven surefire report plugin not running the test cases - maven

I have configured surefire report plugin to my Spring+Maven based project to generate test report(s) and the surefire report plugin able to identify my test class but not running the test cases present in it.
Dependency used in pom.xml
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18.1</version>
</plugin>
</plugins>
</reporting>
While building the project it genertes the result as bellow
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.thales.idct.controller.LopaReConfigControllerTest
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator#1829ae5e
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.225 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
Even the same things is present in *.html report as well.
Bellow is my test case code
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(loader=AnnotationConfigWebContextLoader.class)
#WebAppConfiguration
public class LopaReConfigControllerTest {
public static final MediaType APPLICATION_JSON_UTF8 = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
// Application dependency
private MockMvc mvc;
private LopaReConfigRepositoryImpl lopaImpl;
/*#Spy
#InjectMocks
LopaReConfigService lopaReConfigService = new LopaReConfigService();*/
#Mock
LopaReConfigService lopaReConfigService;
#Mock
CommonUtil commonUtil;
#Mock
ProcessLopaReconfigFile processLopaReconfigFile;
#Mock
DBImportRepository dbImportRepository;
#InjectMocks
MockHttpSession session;
#Autowired
WebApplicationContext context;
#InjectMocks
LopaReConfigController lopaReConfigController;
#Mock
UserSessionPool sessionPool;
// Building and Injecting mocked dependency(s) to controller
#Before
public void setup() {
// Process mock annotations
MockitoAnnotations.initMocks(this);
this.mvc = MockMvcBuilders.standaloneSetup(lopaReConfigController).build();
lopaImpl = new LopaReConfigRepositoryImpl();
}
#Test
public void test_getSeatLayoutDisplay() throws Exception {
// Construct JSON data to pass as parameter
BASeatkitDataFeeder seatKitDataFeeder = new BASeatkitDataFeeder();
Gson gson = new Gson();
CommonUtil util = new CommonUtil();
StringBuffer filePathBuff = new StringBuffer();
String jsonStub = "";
String columnXMl = "";
filePathBuff.append(util.getLopaReConfigPath("RAJESH-300ER", "RAJESH-300ER-B777-v300B"));
filePathBuff.append(LoadPropertyFiles.getInstance().getProperty("INPUT"));
//seatKitDataFeeder.setFilepath(XmlFilePath);
seatKitDataFeeder.setMode("");
seatKitDataFeeder.setFilename("");
seatKitDataFeeder.setBuildVersion("Base");
seatKitDataFeeder.setCarrierName("RAJESH-300ER");
seatKitDataFeeder.setDbId("1558");
seatKitDataFeeder.setDbName("RAJESH-300ER-B777-v300B");
seatKitDataFeeder.setSessionId(session.getId());
seatKitDataFeeder.setFilepath(filePathBuff.toString());
String seatKitXmlFilePath = filePathBuff.append(LoadPropertyFiles.getInstance().getProperty("XMLS")).toString();
columnXMl = filePathBuff.append(Constants.COLUMN_XML_FILENAME).toString();
BASeatKitInfo BAinfo = lopaImpl.getBASeatKit(seatKitXmlFilePath);
KitLayout kitLayout = lopaImpl.getBAColumnSeatKit(seatKitXmlFilePath+Constants.SEATKIT_COLUMN_XML_FILENAME,columnXMl);
// Mock the service results and feed
when(commonUtil.getLopaReConfigPath("RAJESH-300ER", "RAJESH-300ER-B777-v300B")).thenReturn(filePathBuff.toString());
when(lopaReConfigService.getBASeatKit(Mockito.anyString())).thenReturn(BAinfo);
when(lopaReConfigService.getBAColumnSeatKit(Mockito.anyString(),Mockito.anyString())).thenReturn(kitLayout);
// Construct JSON Object
jsonStub = gson.toJson(seatKitDataFeeder);
// Test method logic
mvc.perform(post("/getSeatLayoutDisplay")
.contentType(MediaType.APPLICATION_JSON).content(jsonStub))
.andExpect(status().isOk()) // After hitting specific URL/URI check the status code fall under 200 series
.andExpect(content().contentType(APPLICATION_JSON_UTF8)); // Check the return statement is JSON
//.andExpect(jsonPath("$.fieldErrors", hasSize(1)));
// Verify that the getBASeatKit() method of the lopaReConfigService is called only once during execution.
verify(lopaReConfigService, times(0)).getBASeatKit(seatKitXmlFilePath);
verify(lopaReConfigService, times(0)).getBAColumnSeatKit(seatKitDataFeeder.getFilepath(),columnXMl);
}
#Test
public void testGetBAColumnSeatKit() throws Exception{
BAColumnSeatkitDataFeeder seatKitDataFeeder = new BAColumnSeatkitDataFeeder();
Gson gson = new Gson();
CommonUtil util = new CommonUtil();
StringBuffer filePathBuff = new StringBuffer();
String jsonStub = "";
String columnXMl = "";
String centerXmlFilePath = "";
LopaReConfigController cntrl = PowerMockito.spy(lopaReConfigController);
seatKitDataFeeder.setMode("");
seatKitDataFeeder.setFileName("");
seatKitDataFeeder.setBuildVersion("Base");
seatKitDataFeeder.setCarrierName("BRITISH");
seatKitDataFeeder.setDbId("1514");
seatKitDataFeeder.setDbName("BRITISH-B787-PI-2-8");
seatKitDataFeeder.setSessionId(session.getId());
seatKitDataFeeder.setFilePath(filePathBuff.toString());
when(processLopaReconfigFile.getImportStatus(Integer.parseInt(seatKitDataFeeder.getDbId()))).thenReturn(Constants.SUCCESS);
filePathBuff = new StringBuffer(util.getLopaReConfigPath(seatKitDataFeeder.getCarrierName(),seatKitDataFeeder.getDbName()));
filePathBuff.append(LoadPropertyFiles.getInstance().getProperty("INPUT"));
String seatKitXmlFilePath = filePathBuff.append(LoadPropertyFiles.getInstance().getProperty("XMLS")).toString();
StringBuffer columnXmlFileBuf = new StringBuffer(filePathBuff);
columnXmlFileBuf.append(Constants.COLUMN_XML_FILENAME);
String leftXmlFilePath = filePathBuff.append(Constants.COLUMN_SEATKIT).toString();
String columnXmlFilePath = columnXmlFileBuf.toString();
if("Base".equalsIgnoreCase(seatKitDataFeeder.getBuildVersion())){
centerXmlFilePath = leftXmlFilePath;
} else {
centerXmlFilePath=lopaImpl.getLopaFilePath(seatKitDataFeeder.getBuildVersion(),seatKitDataFeeder.getDbId());
}
BASeatKitInfo seatKitInfo = lopaImpl.getBASeatKit(seatKitXmlFilePath);
KitLayout columnSeatKitLeft = lopaImpl.getBAColumnSeatKit(leftXmlFilePath,columnXmlFilePath);
KitLayout columnSeatKitCenter = lopaImpl.getBAColumnSeatKit(centerXmlFilePath,columnXmlFilePath);
Map<String,String> powerMap = lopaImpl.getPowerUnitInfo(seatKitXmlFilePath);
List<LayoutDesignVersionEntity> listLDVE = dbImportRepository.getLayoutDesignVersionList(Integer.parseInt(seatKitDataFeeder.getDbId()));
User user = new User();
user.setAirlineName("BRITISH-B787-PI-2-8");
user.setGroupName("FFF");
user.setLastLoginTime("12:12:12 10:09:09.656");
user.setPassword("FFF");
user.setUserName("FFF");
UserSessionPool.getInstance().addUser(user);
// when(commonUtil.getLopaReConfigPath(Mockito.anyString(),Mockito.anyString())).thenReturn(filePathBuff.toString());
//when(commonUtil.getLopaReConfigPath("RAJESH-300ER", "RAJESH-300ER-B777-v300B")).thenReturn(filePathBuff.toString());
when(commonUtil.getLopaReConfigPath("RAJESH-300ER", "RAJESH-300ER-B777-v300B")).thenReturn(filePathBuff.toString());
when(lopaReConfigService.getBASeatKit(seatKitXmlFilePath)).thenReturn(seatKitInfo);
when(lopaReConfigService.getBAColumnSeatKit(leftXmlFilePath,columnXmlFilePath)).thenReturn(columnSeatKitLeft);
when(lopaReConfigService.getBAColumnSeatKit(centerXmlFilePath,columnXmlFilePath)).thenReturn(columnSeatKitCenter);
when(lopaReConfigService.getPowerUnitInfo(seatKitXmlFilePath)).thenReturn(powerMap);
when(dbImportRepository.getLayoutDesignVersionList(Integer.parseInt(seatKitDataFeeder.getDbId()))).thenReturn(listLDVE);
jsonStub = gson.toJson(seatKitDataFeeder);
System.out.println(jsonStub);
PowerMockito.doNothing().when(cntrl,"isValidUser",seatKitDataFeeder.getSessionId());
mvc.perform(post("/getSeatKitAndLopaInfo")
.contentType(MediaType.APPLICATION_JSON).content(jsonStub))
.andExpect(status().isOk());//.andExpect(jsonPath("airline", "B787-8").exists());// After hitting specific URL/URI check the status code fall under 200 series
//.andExpect(content().contentType(APPLICATION_JSON_UTF8));// Check the return statement is JSON
verify(lopaReConfigService, times(0)).getBASeatKit(seatKitXmlFilePath);
}
}
How can I run test cases present in my test class..?
Is there any better test case reporting tool..?
My POM.xml file is as bellow
<build>
<finalName>${pom.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.jopendocument/jOpenDocument -->
<dependency>
<groupId>org.jopendocument</groupId>
<artifactId>jOpenDocument</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.0-GA</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0-alpha4</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.8</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.10-FINAL</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<!-- http://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- Unit testing dependency API's -->
<!--Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- this is included in junit, make sure junit it version 4.11 -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.3.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>0.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path-assert</artifactId>
<version>0.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>
<!-- <version>${powermock.version}</version> -->
<version>1.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.5.1</version>
<scope>test</scope>
</dependency>
</dependencies>

Please delete the maven-surefire-report-plugin from reporting tag place the bellow plugin inside the build tag
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<properties>
<property>
<name>junit</name>
<value>true</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>

Related

Autowire JPA Repository with Hazelcast Map Store

I am using Spring-Boot, Spring-Data/JPA with Hazelcast client/server topology. I've been trying to use a MapStore as a Write-Behind buffer for my database through HazelcastRepository. My goal is to use a JpaRepository inside my MapStore to store sessions.
My current problem is that repository is not getting #Autowired, it always returns null.
Found this post about a similar situation, but it's not working because hazelcastClientInstance.getConfig().getManagedContext() is returning null.
Hazelcast configuration:
#Configuration
#EnableHazelcastRepositories(basePackages = {"com.xpto.database"})
#EnableJpaRepositories(basePackages = {"com.xpto.database"})
#ComponentScan(basePackages = {"com.xpto"})
public class HazelcastConfiguration {
#Bean
public SpringManagedContext managedContext() {
return new SpringManagedContext();
}
#Bean
HazelcastInstance hazelcastClientInstance(){
// Real all configuration from hazelcast-client file
ClientConfig clientConfig = null;
try {
clientConfig = new XmlClientConfigBuilder("hazelcast-client-config.xml").build().
setManagedContext(managedContext());
} catch (IOException e) {
e.printStackTrace();
}
return HazelcastClient.newHazelcastClient(clientConfig);
}
}
MapStore:
#SpringAware
public class SessionMapStore implements MapStore<String, Session>, MapLoaderLifecycleSupport {
private static final Logger LOGGER = LoggerFactory.getLogger(SessionMapStore.class);
#Autowired
private SessionsHCRepository sessionsHCRepository;
#Override
public void init(HazelcastInstance hazelcastClientInstance, Properties properties, String mapName) {
hazelcastClientInstance.getConfig().getManagedContext().initialize(this);
}
#Override
public void destroy() {
}
Repository:
#Repository
public interface SessionsHCRepository extends HazelcastRepository<SessionDB, String> {
}
pom file:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.10.0</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.11.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>javax.xml.rpc</groupId>
<artifactId>javax.xml.rpc-api</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-all</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>spring-data-hazelcast</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
</dependencies>

Integrate kie-server into spring boot application

I want to integrate all the kie-server autoconfiguration (especially JBPM) in my spring boot application.
I added these gradle dependencies in a separate module of my project
dependencies {
compile group: 'org.kie', name: 'kie-server-spring-boot-starter', version: '7.29.0.Final'
compile group: 'xerces', name: 'xercesImpl', version: '2.12.0'
}
then I added the configuration properties suggested by this link
https://github.com/kiegroup/droolsjbpm-integration/blob/master/kie-spring-boot/kie-spring-boot-samples/jbpm-spring-boot-sample-basic/src/main/resources/application-postgres.properties
then I tryed to start the application, but I got this error:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in org.jbpm.springboot.datasources.JBPMDataSourceAutoConfiguration required a bean of type 'org.springframework.boot.jdbc.XADataSourceWrapper' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.boot.jdbc.XADataSourceWrapper' in your configuration.
The JBPMDataSourceAutoConfiguration class is linked below
https://github.com/kiegroup/droolsjbpm-integration/blob/master/kie-spring-boot/kie-spring-boot-autoconfiguration/jbpm-spring-boot-data-sources/src/main/java/org/jbpm/springboot/datasources/JBPMDataSourceAutoConfiguration.java
How can I correctly configure an embedded integration of jbpm/drools/kie in my existing spring boot project?
----------UPDATE-------------
After setting the property spring.jta.enabled = true, the exception changed in
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in org.jbpm.springboot.datasources.JBPMDataSourceAutoConfiguration required a bean of type 'org.springframework.boot.jdbc.XADataSourceWrapper' that could not be found.
The following candidates were found but could not be injected:
- Bean method 'xaDataSourceWrapper' in 'NarayanaConfiguration.GenericJdbcConfiguration' not loaded because #ConditionalOnProperty (narayana.dbcp.enabled=false) found different value in property 'narayana.dbcp.enabled'
- Bean method 'xaDataSourceWrapper' in 'NarayanaConfiguration.GenericJdbcConfiguration' not loaded because Ancestor me.snowdrop.boot.narayana.autoconfigure.NarayanaConfiguration did not match
- Bean method 'xaDataSourceWrapper' in 'NarayanaConfiguration.PooledJdbcConfiguration' not loaded because Ancestor me.snowdrop.boot.narayana.autoconfigure.NarayanaConfiguration did not match
- Bean method 'xaDataSourceWrapper' in 'AtomikosJtaConfiguration' not loaded because #ConditionalOnClass did not find required class 'com.atomikos.icatch.jta.UserTransactionManager'
- Bean method 'xaDataSourceWrapper' in 'BitronixJtaConfiguration' not loaded because #ConditionalOnClass did not find required class 'bitronix.tm.jndi.BitronixContext'
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.boot.jdbc.XADataSourceWrapper' in your configuration.
Spring boot uses an embedded tomcat.
It took me a lot of time to make jbpm engine work as a spring boot application with an embedded tomcat, a lot of configs and hacks, especially for the controller 's password which can't be loaded from JKS
So, you need to declare JNDI lookup resources manually.
import org.apache.catalina.Context;
import org.apache.catalina.startup.Tomcat;
import org.apache.tomcat.util.descriptor.web.ContextResource;
import org.kie.server.services.api.KieServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.jndi.JndiObjectFactoryBean;
import javax.naming.NamingException;
import javax.sql.DataSource;
#SpringBootApplication
public class KieServerApplication {
private static final Logger log = LoggerFactory.getLogger(KieServerApplication.class);
public static void main(String[] args) throws NamingException {
log.info("Starting things");
SpringApplication.run(KieServerApplication.class, args);
}
#Autowired
private Environment env;
#Bean
public TomcatServletWebServerFactory tomcatFactory() {
return new TomcatServletWebServerFactory() {
#Override
protected TomcatWebServer getTomcatWebServer(
Tomcat tomcat) {
tomcat.enableNaming();
return super.getTomcatWebServer(tomcat);
}
#Override
protected void postProcessContext(Context context) {
final ContextResource jbpmProjectDs = new ContextResource();
jbpmProjectDs.setName("jdbc/jbpmProjectDs");
jbpmProjectDs.setType(DataSource.class.getName());
jbpmProjectDs.setProperty("driverClassName", "com.mysql.cj.jdbc.Driver");
jbpmProjectDs.setProperty("url",env.getProperty("spring.mamodb.datasource.url"));
marjoryDs.setProperty("username", env.getProperty("spring.mamodb.datasource.username"));
jbpmProjectDs.setProperty("password", env.getProperty("spring.mamodb.datasource.password"));
context.getNamingResources().addResource(jbpmProjectDs);
final ContextResource narayanaTransactionManager = new ContextResource();
narayanaTransactionManager.setName("TransactionManager");
narayanaTransactionManager.setType(javax.transaction.TransactionManager.class.getName());
narayanaTransactionManager.setProperty("factory","org.jboss.narayana.tomcat.jta.TransactionManagerFactory");
context.getNamingResources().addResource(narayanaTransactionManager);
final ContextResource transactionSynchronizationRegistry = new ContextResource();
transactionSynchronizationRegistry.setName("TransactionSynchronizationRegistry");
transactionSynchronizationRegistry.setType(javax.transaction.TransactionSynchronizationRegistry.class.getName());
transactionSynchronizationRegistry.setProperty("factory","org.jboss.narayana.tomcat.jta.TransactionSynchronizationRegistryFactory");
context.getNamingResources().addResource(transactionSynchronizationRegistry);
}
};
}
#Bean(destroyMethod = "")
public DataSource jndiDataSource() throws IllegalArgumentException, NamingException {
JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
bean.setJndiName("java:comp/env/jdbc/jbpmProjectDs");
bean.setProxyInterface(DataSource.class);
bean.setLookupOnStartup(false);
bean.afterPropertiesSet();
return (DataSource) bean.getObject();
}
#Bean
CommandLineRunner deployAndValidate() {
return new CommandLineRunner() {
#Autowired
private KieServer kieServer;
#Override
public void run(String... strings) {
log.info("KieServer {} started", kieServer);
}
};
}
}
** properties Config **
#transaction manager configuration
spring.jta.narayana.transaction-manager-id="1"
narayana.transaction-manager-id=1
narayana.dbcp.enabled=true
narayana.dbcp.maxTotal=20
spring.jta.log-dir=./target/tx-object-store
narayana.periodic-recovery-period=10
narayana.recovery-backoff-period=10
POM file just for dependencies:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.kie</groupId>
<artifactId>kie-spring-boot-samples</artifactId>
<version>7.29.0.Final</version>
</parent>
<artifactId>kie-server</artifactId>
<name>KIE Server</name>
<description>KIE Server SpringBoot </description>
<properties>
<version.org.keycloak>5.0.0</version.org.keycloak>
</properties>
<dependencies>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-server-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-dbcp</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-swagger</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-swagger-ui</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>net.minidev</groupId>
<artifactId>accessors-smart</artifactId>
</exclusion>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
<exclusion>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kie.server</groupId>
<artifactId>kie-server-client</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.narayana.tomcat</groupId>
<artifactId>tomcat-jta</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-transaction-spi</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>pull-parser</groupId>
<artifactId>pull-parser</artifactId>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</dependency>
<dependency>
<groupId>com.github.relaxng</groupId>
<artifactId>relaxngDatatype</artifactId>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
<dependency>
<groupId>org.jboss.narayana.tomcat</groupId>
<artifactId>tomcat-jta</artifactId>
<version>5.9.0.Final</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.keycloak.bom</groupId>
<artifactId>keycloak-adapter-bom</artifactId>
<version>${version.org.keycloak}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version>
</dependency>
<dependency>
<groupId>io.marjory</groupId>
<artifactId>model</artifactId>
<version>1.0.99-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.marjory</groupId>
<artifactId>marjory-jta</artifactId>
<version>0.0.2</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-swagger</artifactId>
<version>${version.org.apache.cxf}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-dbcp</artifactId>
<version>8.0.23</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-transaction-spi</artifactId>
<version>7.6.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
<version>1.1.1.Final</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>pull-parser</groupId>
<artifactId>pull-parser</artifactId>
<version>2.1.10</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.20.0-GA</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.8.17</version>
</dependency>
<dependency>
<groupId>com.github.relaxng</groupId>
<artifactId>relaxngDatatype</artifactId>
<version>2011.1</version>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>mysql</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>QuickBuild</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<includes>
<include>com/marjory/kie/server/*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>go-to-hell</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Cheers,
just go to start.jbpm.org and
download ready made spring booy kie-server!

Only first request mapping resolves Java Spring Boot (circular view path)

I'm trying to map several request paths in my Spring Boot application. It's a RESTful web service but I wanted to have two views (main and help) for user interface. I've tried tweaking the names of the return string (ie. from "help.html to "help"), as well as cleaning my project and rebuilding, but I cannot figure why one view resolves and the other view does not and returns a circular path. I've also tried creating a separate HelpController and mapping it there. I don't see anything different I am doing between the two.
Here is my MainController.java:
#Controller
public class MainController {
#RequestMapping(value = "/help", method = RequestMethod.GET)
public String help(){
System.out.println("GET called on help page");
return "help.html";
}
#RequestMapping(value = "/main", method = RequestMethod.GET)
public String landing(){
System.out.println("GET called on index page");
return "landing.html";
}
}
My App.java:
#SpringBootApplication
#EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
public class App {
// private static final Logger logger = Logger.getLogger(App.class.toString());
public static void main(String[] args){
SpringApplication.run(App.class, args);
}
}
I put my two html templates in the resources/static directory:
But only one of these two paths resolve correctly. main.html looks great:
But help.html has a circular reference I cannot resolve or understand:
Here is my pom.xml (certain tags omitted for privacy):
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.2.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>dynamodb-local-oregon</id>
<name>DynamoDB Local Release Repository</name>
<url>https://s3-us-west-2.amazonaws.com/dynamodb-local/release</url>
</repository>
</repositories>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.2.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.derjust/spring-data-dynamodb -->
<dependency>
<groupId>com.github.derjust</groupId>
<artifactId>spring-data-dynamodb</artifactId>
<version>4.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-dynamodb -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
<version>1.11.125</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Gosling-SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>${aws-java-sdk.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>1.5.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>DynamoDBLocal</artifactId>
<version>${aws.dynamodblocal.version}</version>
</dependency>
</dependencies>
</project>
the simplest way to solve your issue is to change the mapping from /help to something else, or rename the static file help.html.
The reason for the circular dependency is because the view name help.html will again get mapped to your controller. Spring MVC uses a suffix to determine a mimetype of the response by default, this means that a method mapped to /help, will intercept the /help.html request as well

Spring Boot attributes of the Model are not loaded on JSP page

I'm desperate, i'm following all the tutorials and the documentations, and i succesfully create a little hello controller with spring boot, but when i'm try to use spring boot on my project, all the attributes of the spring Model/Modelview are not loaded and i don't know why.
Here my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.github.p4535992</groupId>
<artifactId>springMVC12</artifactId>
<version>1.6.10</version>
<packaging>war</packaging>
<name>springMVC12</name>
<description>Demo project for Spring Boot using JSPs</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<!-- Generic properties -->
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
<java.version>1.8</java.version>
<!-- Version of the Maven properties -->
<maven-eclipse-plugin.version>2.9</maven-eclipse-plugin.version>
<maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
<maven-source-plugin.version>2.3</maven-source-plugin.version>
<maven-javadoc-plugin.version>2.3</maven-javadoc-plugin.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version>
<maven-exec-plugin.version>1.1.1</maven-exec-plugin.version>
<maven-tomcat7-plugin.version>2.2</maven-tomcat7-plugin.version>
<maven-dependency-plugin.version>2.10</maven-dependency-plugin.version>
<mysql.version>5.1.6</mysql.version>
<javax.servlet.jstl.version>1.2</javax.servlet.jstl.version>
<!-- Json-->
<json-path.version>2.0.0</json-path.version>
<com.fasterxml.jackson.core.version>2.5.3</com.fasterxml.jackson.core.version>
<!-- Logging -->
<spring-boot-starter-logging.version>1.2.4.RELEASE</spring-boot-starter-logging.version>
<!-- Test -->
<junit.version>4.12</junit.version>
<com.github.dandelion.version>0.10.1</com.github.dandelion.version>
<!-- Apache and Commons -->
<commons-fileupload.version>1.3.1</commons-fileupload.version>
<commons-io.version>2.4</commons-io.version>
<commons-codec.version>1.10</commons-codec.version>
<!-- UTILITY Github -->
<com.github.p4535992.utility.version>1.6.10</com.github.p4535992.utility.version>
<!--<com.github.p4535992.gate-basic.version>1.6.5</com.github.p4535992.gate-basic.version>-->
<com.github.p4535992.ExtractInfo.version>1.6.10</com.github.p4535992.ExtractInfo.version>
<start-class>com.github.p4535992.mvc.JspDemoApplication</start-class>
<!-- <tomcat.version>7.0.52</tomcat.version>-->
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.p4535992</groupId>
<artifactId>extractInfo</artifactId>
<version>${com.github.p4535992.ExtractInfo.version}</version>
<exclusions>
<exclusion>
<groupId>com.github.p4535992</groupId>
<artifactId>utility</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.p4535992</groupId>
<artifactId>utility</artifactId>
<version>${com.github.p4535992.utility.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<!-- Other Spring boot dependency -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<!-- <scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<!-- <scope>provided</scope>-->
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>-->
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>-->
<!-- Github dependency -->
<dependency>
<groupId>com.github.p4535992</groupId>
<artifactId>extractInfo</artifactId>
</dependency>
<dependency>
<groupId>com.github.p4535992</groupId>
<artifactId>utility</artifactId>
</dependency>
<!-- MySQLDatabase -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- ===================== -->
<!-- Needed for JSON View -->
<!-- ===================== -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${com.fasterxml.jackson.core.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${com.fasterxml.jackson.core.version}</version>
</dependency>
<!-- Need for get json response with controller -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${com.fasterxml.jackson.core.version}</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>${json-path.version}</version>
<scope>test</scope>
</dependency>
<!-- Dandelion -->
<dependency>
<groupId>com.github.dandelion</groupId>
<artifactId>datatables-jsp</artifactId>
<version>${com.github.dandelion.version}</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- Apache and Commons -->
<!-- NOTE: commons-dbcp replace from tomcat-jdbc -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons-fileupload.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>
</dependency>
<!-- Needed for PDF View -->
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>4.2.1</version>
</dependency>
<!-- Needed for XLS View -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-beta2</version>
</dependency>
<!-- Needed for RSS View-->
<dependency>
<groupId>com.rometools</groupId>
<artifactId>rome</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-impl</artifactId>
<version>1.2.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- ****************************************-->
<!-- Copy dependency jar to a m2 folder -->
<!-- ****************************************-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${user.dir}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Here my MapController.java:
#Controller
public class MapController {
private static final org.slf4j.Logger logger =
org.slf4j.LoggerFactory.getLogger(MapController.class);
#Autowired
private MapService mapService;
#Autowired
private FileService fileService;
private Marker marker;
private List<Marker> arrayMarker = new ArrayList<>();
private String arrayMarker2 ="";
//List<Marker> supportArray = new ArrayList<>();
private Integer indiceMarker = 0;
/*#RequestMapping(value="/map",method= RequestMethod.GET)
public String loadMap1(Model model){
String html = mapService.getResponseHTMLString();
return "riconciliazione2/mappa/map";
}
#RequestMapping(value="/map",method = RequestMethod.POST)
public String result(#RequestParam(required=false, value="urlParam")String url,Model model){
System.out.println("url: " + url);
return "home";
}*/
#RequestMapping(value="/map",method= RequestMethod.GET)
public String loadMap2(Model model){
//String html = mapService.getResponseHTMLString();
//Site siteForm = new Site();
//model.addAttribute("siteForm",siteForm);
if(!arrayMarker.isEmpty()) model.addAttribute("arrayMarker",arrayMarker);
else model.addAttribute("arrayMarker",null);
arrayMarker2 = JsonUtilities.writeListToJsonArray(arrayMarker);
if(arrayMarker2 != null) model.addAttribute("arrayMarker2",arrayMarker2);
else model.addAttribute("arrayMarker2","");
if(marker!=null)model.addAttribute("marker",marker);
else model.addAttribute("marker",null);
model.addAttribute("indiceMarker",indiceMarker);
model.addAttribute("urlParam",null);
String html = mapService.getResponseHTMLString();
model.addAttribute("HTML",html);
return "riconciliazione2/mappa/leafletMap";
}
/*#RequestMapping("*")
public String hello(HttpServletRequest request,Model model) {
System.out.println(request.getServletPath());
String MAIN = mapService.homeMain();
model.addAttribute("MAIN",MAIN);
return "main";
}*/
#RequestMapping("/")
public String homeMain(Model model){
return "main";
}
#RequestMapping(value="/main",method= RequestMethod.GET)
public String homeMain2(Model model){
//String MAIN = mapService.homeMain();
//model.addAttribute("MAIN",MAIN);
return "main";
}
//---------------------------------------------------------
// NEW GET METHOD
//---------------------------------------------------------
#RequestMapping(value="/map13",method= RequestMethod.GET)
public String loadMap13(){
Model model = new ExtendedModelMap();
//String html = mapService.getResponseHTMLString();
//Site siteForm = new Site();
//model.addAttribute("siteForm",siteForm);
if(!arrayMarker.isEmpty()) model.addAttribute("arrayMarker",arrayMarker);
else model.addAttribute("arrayMarker",null);
arrayMarker2 = JsonUtilities.writeListToJsonArray(arrayMarker);
if(arrayMarker2 != null) model.addAttribute("arrayMarker2",arrayMarker2);
else model.addAttribute("arrayMarker2",null);
if(marker!=null)model.addAttribute("marker",marker);
else model.addAttribute("marker",null);
model.addAttribute("indiceMarker",indiceMarker);
model.addAttribute("urlParam",null);
//String html = mapService.getResponseHTMLString();
//model.addAttribute("HTML",html);
//model.addAttribute("supportArray",supportArray);
return "riconciliazione2/mappa/leafletMap5";
}
//---------------------------------------------------------
// NEW POST METHOD
//---------------------------------------------------------
#RequestMapping(value="/map3",method = RequestMethod.POST)
public String result4(#RequestParam(required=false, value="urlParam")String url,
#RequestParam(required=false,value="arrayParam")List<String> arrayParam
//#ModelAttribute(value="arrayParam") MarkerList arrayParam
//#ModelAttribute(value="markerParam")Marker markerFromJS
){
if(arrayParam!= null && !arrayParam.isEmpty()){
for(String smarker : arrayParam){
if(StringUtilities.isNullOrEmpty(smarker))continue;
marker = new Marker();
try {
marker = JsonUtilities.fromJson(smarker,Marker.class);
} catch (IOException ioe) {
ioe.printStackTrace();
}
arrayMarker.add(marker);
indiceMarker++;
}
}
if(!StringUtilities.isNullOrEmpty(url)) {
String[] splitter;
if (url.contains(",")) {
splitter = url.split(",");
url = splitter[0];
}
System.out.println("url: " + url);
marker = new Marker();
marker = mapService.createMarkerFromGeoDocument(url);
// = new Marker("City",url,"43.3555664", "11.0290384");
//model.addAttribute("marker",marker); //no need is get from the HTTTP GET COMMAND
arrayMarker.add(marker);
indiceMarker++;
}
return "redirect:/map13";
}
Here the link to my JSP page: JSPPage
I don't know why but the attribute arrayMarker2 is always empty, and that give me nuts.
You can find the full code of the project to this link springMVC12.
Ty in advance for any help.
Ok, i solved by myself but i not sure how.
I just replace all the Model of springframework with the ModelAndView Object.

arquillian #Drone injections always returning "about:blank" page

I am having this problem for 2 days now, and I am tending to think that something in my configuration is off. I'll post first my code and then explain:
public class MyTest extends Arquillian {
#Deployment(name = "MyPlatform", testable = false)
public static WebArchive createDeployment() {
WebArchive war;
war = ShrinkWrap
.create (WebArchive.class, "MyPlatform.war")
.merge (Maven
.resolver()
.loadPomFromFile("pom.xml")
.resolve("MyPlatform:My.Platform:war:0.0.1-SNAPSHOT")
.withoutTransitivity()
.asSingle(WebArchive.class));
return war;
}
#Drone
private PhantomJSDriver browser;
#ArquillianResource
private URL deploymentUrl;
#Test(dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER)
#RunAsClient
public void should_login_successfully(#InitialPage LoginPage loginPage) {
System.out.println ("ACTUAL: " + browser.getCurrentUrl ());
System.out.println ("DEPLOYMENT URL: " + deploymentUrl.toExternalForm ());
loginPage.login ("demo", "demo");
Assert.assertEquals (deploymentUrl.toExternalForm () + "index.tm", "https://127.0.0.1:8443/MyPlatform/index.tm");
}
The #ArquillianResource injection works fine, and shows the correct URL. However the #Drone injection shows "about:blank". after some testing i found something weird:
if my war file is called something like MyPlatform.blabla.war, then the Drone trancates after the first "dot" and i get "http://127.0.0.1:8080/MyPlatform/login.tm" which is not what i deployed...so for some reason the #Drone is always trancating my deployment URL and cant seem to find the root of it.
here is my POM just in case
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-api-maven</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<version>1.1.2.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-impl-base</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.2.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-drone-bom</artifactId>
<version>1.2.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.graphene</groupId>
<artifactId>graphene-webdriver</artifactId>
<version>2.0.1.Final</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.graphene</groupId>
<artifactId>graphene-webdriver-spi</artifactId>
<version>2.0.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.graphene</groupId>
<artifactId>graphene-webdriver-impl</artifactId>
<version>2.0.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-remote</artifactId>
<version>7.1.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.testng</groupId>
<artifactId>arquillian-testng-container</artifactId>
<version>1.1.2.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>bsh</groupId>
<artifactId>bsh</artifactId>
<version>2.0b4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
I would be greatful if someone can help me in solving this pickle..!
Typical, After I posted the question i found the problem, and it was simply that my applicaiton is running over SSL and phantomjs is not redirecting from 8080 -> 8443...
Now to figure out how to do this ...

Resources