#WicketHomePage not found - maven

Blockquote
J have a Eclipse workspace with a maven parent project (parent) and child > >projects (Domain,Web,Win)
The parent pom contains the wicket-spring-boot-starter-parent
<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>
<groupId>org.SteinKo.ATM</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<name>Parent</name>
<url>http://maven.apache.org</url>
<modules>
<module>Domain</module>
<module>Web</module>
<module>Win</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<scm>
<connection>scm:git#github.com:steinKo/ATM.git</connection>
<url>https://github.com/steinKo/ATM.git</url>
</scm>
<parent>
<!-- https://mvnrepository.com/artifact/com.giffing.wicket.spring.boot.starter/wicket-spring-boot-starter-parent -->
<groupId>com.giffing.wicket.spring.boot.starter</groupId>
<artifactId></artifactId>
<version>2.0.3</version>
</parent>
The web projects contains a Wicket pages
package steinKo.ATM;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import steinKo.ATM.presentaion.web.HomePage;
#SpringBootApplication
public class Web {
public static void main(String[] args) throws Exception {
new SpringApplicationBuilder().sources(Web.class).run(args);
}
public Class<HomePage> getHomePage() {
return HomePage.class;
}
}
package steinKo.ATM.presentaion.web;
import com.giffing.wicket.spring.boot.context.scan.WicketHomePage;
import org.apache.wicket.markup.html.WebPage;
import steinKo.ATM.domain.ATM;
import steinKo.ATM.domain.Bank;
#WicketHomePage
public class HomePage extends WebPage {
/**
*
*/
private static final long serialVersionUID = 1L;
private ATM atm;
private Bank bank;
public HomePage() {
bank = new Bank();
atm = new ATM(bank);
add(new MenuPanel("menuPanel"));
add(new ContentPanel("contentPanel", atm));
}
}
The pom.xml for the web contain dependency to wicket-spring-boot-starter
http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
<artifactId>Web</artifactId>
<parent>
<groupId>org.SteinKo.ATM</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1</version>
<relativePath />
</parent>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.wicket/wicket-core -->
<dependency>
<groupId>com.giffing.wicket.spring.boot.starter</groupId>
<artifactId>wicket-spring-boot-starter</artifactId>
</dependency>
When I execute maven test on parent project I get the message
[INFO] Scanning for projects...
[ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for com.giffing.wicket.spring.boot.starter:wicket-spring-boot-starter:jar is missing. # org.SteinKo.ATM:Web:[unknown-version], /Users/stein/Development/ATM/Parent/Web/pom.xml, line 20, column 16
[ERROR] 'dependencies.dependency.version' for org.seleniumhq.selenium:selenium-java:jar is missing. # org.SteinKo.ATM:Web:[unknown-version], /Users/stein/Development/ATM/Parent/Web/pom.xml, line 28, column 13 #
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR] The project org.SteinKo.ATM:Web:0.0.1 (/Users/stein/Development/ATM/Parent/Web/pom.xml) has 2 errors
[ERROR] 'dependencies.dependency.version' for com.giffing.wicket.spring.boot.starter:wicket-spring-boot-starter:jar is missing. # org.SteinKo.ATM:Web:[unknown-version], /Users/stein/Development/ATM/Parent/Web/pom.xml, line 20, column 16
[ERROR] 'dependencies.dependency.version' for org.seleniumhq.selenium:selenium-java:jar is missing. # org.SteinKo.ATM:Web:[unknown-version], /Users/stein/Development/ATM/Parent/Web/pom.xml, line 28, column 13
[ERROR]
and
the
import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; and
#WicketHomePage is marked red in the has a message "Can not be resolved"
Why?

It look like maven build issue for me dependencies.dependency.version not properly loading the dependency of com.giffing.wicket.spring.boot.starter from parent . Please build using mvn clean install from parent to all the project and fix . Its nothing to do with code .
And more over i'm not sure whether you shared your full pom add this Your pom not correct change this
<groupId>com.giffing.wicket.spring.boot.starter</groupId>
<artifactId></artifactId>
<version>2.0.3</version>
to
<dependency>
<groupId>com.giffing.wicket.spring.boot.starter</groupId>
<artifactId>wicket-spring-boot-starter</artifactId>
<version>2.0.3</version>
</dependency>

Related

Maven dependency provided on submodule ear throws ClassNotFoundException

Environment:
Java 11
JBoss 7.2
Maven 3.5
I am getting this ERROR java.lang.ClassNotFoundException: net.sf.jasperreports.engine.JRException when I try to execute a method from a class in app-commons module. Jasper dependency in app-commons is compiled and app-commons dependency in app-back is provided.
How could I solve this?
Error
09:29:24,013 SEVERE [org.primefaces.application.exceptionhandler.PrimeExceptionHandler] (default task-1) net/sf/jasperreports/engine/JRException: java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRException
...
Caused by: java.lang.ClassNotFoundException: net.sf.jasperreports.engine.JRException from [Module "deployment.accfor2.ear" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
... 78 more
Modules:
app (pom)
app-ear
app-back
app-commons (provided)
app-front
app-commons (provided)
app-commons
jasperreports (compiled)
...
pom.xml (app-commons)
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<groupId>com.name.app</groupId>
<artifactId>app</artifactId>
<version>8.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>app-commons</artifactId>
<packaging>jar</packaging>
<name>app-commons</name>
...
<dependencies>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.15.0</version>
</dependency>
</dependencies>
...
ReportManager.java (app-commons)
public class ReportManager {
...
public static void addParam(Map<String, Object> params, String nom, byte[] compiledReport) throws ReportException {
try {
params.put(nom, SerializationUtils.deserialize(compiledReport));
} catch (Exception e) {
throw new ReportException("Error deserialize compiledReport.");
}
}
...
pom.xml (app-back)
<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>com.name.app</groupId>
<artifactId>app</artifactId>
<version>8.0.0</version>
</parent>
<artifactId>app-back</artifactId>
<packaging>war</packaging>
<name>app-back</name>
<description>Módul back (intranet)</description>
<dependencies>
...
<dependency>
<groupId>com.name.app</groupId>
<artifactId>app-commons</artifactId>
<scope>provided</scope>
</dependency>
...
ExecuteReportBean.java (app-back)
public class ExecuteReportBean.java
...
public void compileReport(Informe informe, Map<String, Object> parametresSend) {
ReportManager.compilaReport(parametre.getJasperReport());//ERROR java.lang.ClassNotFoundException: net.sf.jasperreports.engine.JRException
...
If you declare the dependency as provided, it will not be packaged into the WAR.
Either change the scope to compile or let the application server provide it (by e.g. putting it into a JBoss module).
Because of transitive dependencies are not included when dependency is provided, so I had to restructure the modules this way.
Modules:
app (pom)
app-ear
jasperreports (compiled) MOVED FROM APP-COMMONS
app-back
app-commons (provided)
app-front
app-commons (provided)
app-commons
...
I was not able to change app-commons dependency to compiled because it is dependent of app-front and app-back. In app-commons as compiled I have an #ApplicationScope class that it would produce ambiguous Beans pointing to the class in app-commons because of jakartaee context management.

How to access application.yml properties in Spring 1.5.9

I'm spinning my wheels on this.
Here is a simple Spring Boot app. I'm trying to use a yaml properties file, but I can't seem to get it to find the properties file or let me access the values in it. I've tried many variations from advice I've searched for here and elsewhere. Nothing is working.
(For reasons I can't go into, I have to use an older version of Spring. (1.5.9))
In IntelliJ I have the Lombok plugin installed, annotations enabled and the language is set to Java 1.8.
Here is the error I'm getting currently:
[ERROR] demo/src/main/java/com/example/demo/Foo.java:[9,10] cannot find symbol
[ERROR] symbol: method value()
[ERROR] location: #interface lombok.Value
[ERROR] demo/src/main/java/com/example/demo/Foo.java:[9,3] annotation type not applicable to this kind of declaration
[ERROR] demo/src/main/java/com/example/demo/Foo.java:[13,5] cannot find symbol
[ERROR] symbol: variable log
[ERROR] location: class com.example.demo.Foo
Here is the folder structure:
Here is the application.yml file:
project:
thing:
path: resources/foo_files
Here is the main class:
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
Foo foo = new Foo();
SpringApplication.run(DemoApplication.class, args);
}
}
Here is class Foo:
package com.example.demo;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
#Slf4j
class Foo {
#Value("${project.thing.path}")
private String projectThingPath;
public Foo() {
log.info("path is: " + projectThingPath);
}
}
Here is the pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.21.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
For getting value from application.yml you should be using #Value from the package org.springframework.beans.factory.annotation.Value but you are using lombok's #Value
package com.example.demo;
import org.springframework.beans.factory.annotation.Value; // Changed
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
#Slf4j
#Component // EDIT : Added
class Foo {
#Value("${project.thing.path}")
private String projectThingPath;
public Foo() {
log.info("path is: " + projectThingPath);
}
}
EDIT
So another important point is that, a class should be annotated with stereotype annotation ( To tell Spring to configure the data).
You have compile error because you are using #Slf4j (lombok annotation) but you have not Slf4j lib in your dependencies
In this case you can use #Log or add Slf4j to your dependencies

Spring Boot Not Finding Any Controllers

Hello i've tried to create a simple controller and put it in the same package with the main class but it looks like it's not finding it.Basically, when i run the app it's not mapping the endpoint.
I just can't figure out what is wrong with it.
Here is the code:
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class TestProject1Application {
public static void main(String[] args) {
SpringApplication.run(TestProject1Application.class, args);
}
}
package com.example.demo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class HomeController {
#RequestMapping(value="/hello", method = RequestMethod.GET)
public String sayHello() {
return "HELLO";
}
}
Project Structure and Console:
This is my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.tsv</groupId>
<artifactId>TestProject-1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TestProject-1</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Although in your log, I do not see 'ServletRegistrationBean' getting initialized, I find no issue with your configuration. Try execute the Spring boot app again & you should be able to invoke the HomeController via 'localhost:8080/hello'.

Openshift spring boot deploy fails

I am deploying a simple spring boot application in open shift
But fails after build success.
POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.example</groupId>
<artifactId>springdemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>springdemo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<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>
<!-- Add tomcat only if I want to run directly -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>springdemo</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
AppMain
#SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
Controller
#RestController
public class SampleController {
#GetMapping("/test")
public String test(){
return "Spring Boot running......";
}
}
all this on git when I start pulling from OpenShift it build success but after get error and not deployed.
I have selected Java and Redhut jboss(tomcat 8)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:15.524s
[INFO] Finished at: Sat Mar 04 12:24:08 UTC 2017
/usr/bin/mvn: line 9: 33 Killed $M2_HOME/bin/mvn "$#"
Aborting due to error code 137 from Maven build
error: build error: non-zero (13) exit code from registry.access.redhat.com/jboss-webserver-3/webserver30-tomcat8-openshift#sha256:727603994024d133ead698832e07xxxxxxxxxxxxxxxxxxxxxxxx
Check the resources tag in the build yaml file.
If not add resources like below
resources:
limits:
cpu: '2'
memory: 2Gi
requests:
cpu: '1'
memory: 1Gi

SpringBootApplication cannot be resolved to a type

Hi below is my Spring code and pom.xml. Maven is not able to update even though I tried to force project update. Any resolution on this or direction where I am getting wrong.
package com.boot;
import org.springframework.*;
#SpringBootApplication
public class App
{
public static void main( String[] args )
{
System.out.println("Hello World");
}
}
pom
<groupId>com.boot</groupId>
<artifactId>das-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>
<name>das-boot</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>com.boot.App</start-class>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
I am not getting why Maven is not able to get the dependencies for my project. A
I faced the same issue.
I changed the version from 2.0.5.RELEASE to 2.0.3.RELEASE to make it work
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
If you are fine to move to 2.x then please follow below steps:
Step 1 copy below pom
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.boot</groupId>
<artifactId>das-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>das-boot</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Step 2: Here is your main application class:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class DasBootApplication {
public static void main(String[] args) {
SpringApplication.run(DasBootApplication.class, args);
}
}
or you can also stay with 1.4.2, just change java version to 1.6.
You should provide the class name in the run() method like below:
#SpringBootApplication
public static void main(String[] args) {
SpringApplication.run(App.class, args);
Sytem.out.print("Started");
}
And remove the below line from pom.xml
<start-class>com.boot.App</start-class>

Resources