New to using Maven/Spring, and messing around trying to create a simple web app. I've got an index.html which I've added to src/main/resources/templates, as well as the main Application, Controller etc.
I'm also using cucumber to do testing, and one of the steps is to GET "http://localhost/billparser/index". I've also set up an application.properties file under src/main/resource, with the entry:
#server.contextPath=/billparser
However I get these lines of logging out:
17:41:47.935 [main] DEBUG o.s.w.s.r.ResourceHttpRequestHandler - Trying relative path [index] against base location: ServletContext resource [/]
17:41:47.935 [main] DEBUG o.s.w.s.r.ResourceHttpRequestHandler - Trying relative path [index] against base location: class path resource [META-INF/resources/]
17:41:47.936 [main] DEBUG o.s.w.s.r.ResourceHttpRequestHandler - Trying relative path [index] against base location: class path resource [resources/]
17:41:47.936 [main] DEBUG o.s.w.s.r.ResourceHttpRequestHandler - Trying relative path [index] against base location: class path resource [static/]
17:41:47.936 [main] DEBUG o.s.w.s.r.ResourceHttpRequestHandler - Trying relative path [index] against base location: class path resource [public/]
I've checked, and my index.html file has been put into target/classes/templates.
I've done some googling online but I'm new to any of this sort of stuff, and seem a little bewildered. I'm using https://github.com/excellentdrums/Cucumber-JVM-Spring-MVC-Test-HTMLUnit-Demo as a bit of a template for getting it working, and followed what he's done but having no luck myself.
I've done some googling but I'm still lost. Can anyone point me in the right direction?
Thank you.
Pom.xml looks as such:
<?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>org.tmh.bill</groupId>
<artifactId>billParser</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Bill Parser</name>
<description>Parse out a JSON to show a bill.</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.0.RC5</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test-mvc-htmlunit</artifactId>
<version>1.0.0.M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-spring</artifactId>
<version>1.1.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.40.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<start-class>bill.Application</start-class>
<java.version>1.7</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestone</id>
<url>http://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestone</id>
<url>http://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
A Spring Boot application starts up on port 8080 by default. Also, the server.contextPath property in your application.properties file is commented out, so this does not affect your context path. The correct URL for you should be http://localhost:8080/index, as long as you have the /index path mapped in your controller.
You can test this by running the example GitHub project you referenced and navigating to http://localhost:8080/hello, which will give you the following:
Related
I'm trying to use SpringBoot to display a .JSP page using embedded tomcat. Whenever I try to access the localhost URL, I get the Whitelabel Error Page with 404 Not Found. As you'll see below, I tried making a method for #RequestMapping to find the JSP location, to no avail. Previously, I was having issue importing Tomcat into pom.xml (was giving "not found" error). I fixed this by commenting out the <repositories> section in pom.xml, running it, then uncommenting it. How can I get my project to view .JSP files properly? I am following all steps in this Udemy course to a T. I will provide more info where needed.
SpringBoot version is 3.0.0 M3
My Java version is 18.0.1.1 2022-04-22
I'm using IntelliJ IDEA 2022.1.3 Community Edition
The JSP is called "sayHello.jsp" and it's located at /src/main/resources/META-INF/resources/WEB-INF/jsp/sayHello.jsp (the file directory picture below shows this). It just has Hello World HTML code in it
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 https://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>3.0.0-M3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.springboot</groupId>
<artifactId>springboot-first-web-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-first-web-app</name>
<description>My first SpringBoot web application from the Udemy Course</description>
<properties>
<java.version>18</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<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> <!-- Commenting/Un-commenting out <repositories> made it so tomcat-embed jasper dependency worked -->
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
SayHelloController.java (directory of files pictured later below)
package com.springboot.springbootfirstwebapp.hello;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
#Controller
public class SayHelloController
{
#RequestMapping("say-hello")
#ResponseBody
public String sayHelloDefault()
{
return "Hello! What are you learning today?";
}
#RequestMapping("say-hello-jsp")
public String sayHelloJsp()
{
return "sayHello";
}
#RequestMapping("say-hello-html")
#ResponseBody
public String sayHelloOld()
{
StringBuffer sb = new StringBuffer();
sb.append("<html>");
sb.append("<head>");
sb.append("<title>My first SpringBoot HTML page!</title>");
sb.append("</head>");
sb.append("<body>");
sb.append("This is an HTML page with a body!");
sb.append("</body>");
sb.append("</html>");
return sb.toString();
}
}
application.properties
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
# For more information
logging.level.org.springframework=debug
The DEBUG log showing the 404 Not Found error
My file directory in IntelliJ
Your folder structure is wrong. Should be
main -> webapp -> WEB-INF -> jsp -> sayHello.jsp
My goal is to get the config for world-service from a config-service.
The architecture:
config-service with dependency spring-cloud-config-server at localhost:8888
world-service with dependency the spring-web and spring-cloud-starter-config.
What I have done:
I have set up the Config Server and send a GET request to http://localhost:8888/hello-service/master and the config server get the hello-service.properties from the config-repo repository. (If you need the config-service's source code, I will push it to this repository.)
My expected result:
The world-service use port 8081.
My actual result:
The world-service use port 8080.
bootstrap.properties
spring.application.name=world-service
spring.cloud.config.uri=http://localhost:8888
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 https://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>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>world-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>world-service</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2020.0.0-M5</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
</project>
With Spring Cloud 2020, they made a change in how bootstrap works and you have to include a new starter: spring-cloud-starter-bootstrap.
I spent a day on it and finally found a solution. It may help others
You need to add new dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
According to the Spring Cloud 2020.0
Bootstrap, provided by spring-cloud-commons, is no longer enabled by
default. If your project requires it, it can be re-enabled by
properties or by a new starter.
To re-enable by properties set spring.cloud.bootstrap.enabled=true or
spring.config.use-legacy-processing=true. These need to be set as an
environment variable, java system property or a command line argument.
The other option is to include the new spring-cloud-starter-bootstrap
(in your POM file).
I used the first option and that worked for me.
Spring Boot 2.4 introduced a new way to import configuration data via the spring.config.import property. This is now the default way to bind to Config Server.
To connect to config server set the following in application.yml:
spring:
application:
name: APPLICATION_NAME
config:
import: optional:configserver:http://USER:PASSWORD#MY_HOST:PORT/
You can see more details in: https://docs.spring.io/spring-cloud-config/docs/3.0.0/reference/html/#config-data-import
I have added two jar files to my internal repository and created its corresponding folder directory as shown below in image. but it is showing compile time error in my pom.xml where i have added the dependency for both the jars, saying "Missing artifact common:common-jar:jar:1.0" and "Missing artifact mediator:mediator-jar:jar:1.0"
look at my pom.xml below
<properties>
<jdk.version>1.7</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Maven plugin & MOJO versions -->
<version.maven-compiler-plugin>3.1</version.maven-compiler-plugin>
</properties>
<repositories>
<repository>
<id>in-project</id>
<name>In Project Repo</name>
<url>file://${basedir}/libs</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>common</groupId>
<artifactId>common-jar</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>mediator</groupId>
<artifactId>mediator-jar</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
please suggest what to do.
I think there is some problem identifying value for ${basedir} but i have also tried ${project.basedir} as well, it is also not working.
The problem lies in your url tag. Instead of <url>file://${basedir}/libs</url> try removing the double slash before ${basedir}: <url>file:${basedir}/libs</url>
You have a nice guide here if you want to check it.
First : Never use <scope>system</scope>
Follow the Example:
Project folder - C:\UX\X5SCX\GIT_STORE\SRC\FACTOR\fwk\broker\lib
<repositories>
<repository>
<id>local-repo</id>
<url>file://${basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>ews</groupId>
<artifactId>ews-java-api</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
I am trying to add the dependency of Gephi in POM.xml file (in Eclipse). Here is the POM file:
<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>ch.unifr</groupId>
<artifactId>facebook</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>Facebook Example</name>
<repositories>
<repository>
<id>gephi-snapshots</id>
<name>Gephi Snapshots</name>
<url>http://nexus.gephi.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>gephi-releases</id>
<name>Gephi Releases</name>
<url>http://nexus.gephi.org/nexus/content/repositories/releases/</url>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gephi.maven.requiredVersion>3.0.4</gephi.maven.requiredVersion>
<netbeans.run.params.ide/>
<netbeans.run.params>${netbeans.run.params.ide}</netbeans.run.params>
<!-- Netbeans Platfrom version -->
<netbeans.version>RELEASE721</netbeans.version>
<!-- Gephi version -->
<gephi.version>0.9-SNAPSHOT</gephi.version>
<!-- Java compilation settings -->
<gephi.javac.source>1.6</gephi.javac.source>
<gephi.javac.target>1.6</gephi.javac.target>
<gephi.javac.xlint>-Xlint:all</gephi.javac.xlint>
<gephi.javac.debug>true</gephi.javac.debug>
<gephi.javac.optimize>true</gephi.javac.optimize>
<gephi.javac.showDeprecation>true</gephi.javac.showDeprecation>
<gephi.javac.showWarnings>true</gephi.javac.showWarnings>
<gephi.javac.fork>true</gephi.javac.fork>
<!-- Testing settings -->
<gephi.junit.version>4.7</gephi.junit.version>
<gephi.test.maxMemory>768M</gephi.test.maxMemory>
<gephi.test.reportsDirectory>${project.build.directory}/surefire-reports/plain</gephi.test.reportsDirectory>
<gephi.test.failureIgnore>${testFailureIgnore}</gephi.test.failureIgnore>
<!-- Repository URLs -->
<gephi.release.repository.id>gephi-nexus</gephi.release.repository.id>
<gephi.snapshot.repository.id>gephi-nexus</gephi.snapshot.repository.id>
<gephi.release.repository.url>http://nexus.gephi.org/nexus/content/repositories/releases</gephi.release.repository.url>
<gephi.snapshot.repository.url>http://nexus.gephi.org/nexus/content/repositories/snapshots</gephi.snapshot.repository.url>
<!-- SCM -->
<gephi.scm>git</gephi.scm>
<!--==== Plugin Versions ==================================================================================-->
<gephi.maven-assembly-plugin.version>2.4</gephi.maven-assembly-plugin.version>
<gephi.maven-clean-plugin.version>2.5</gephi.maven-clean-plugin.version>
<gephi.maven-compiler-plugin.version>3.0</gephi.maven-compiler-plugin.version>
<gephi.maven-dependency-plugin.version>2.6</gephi.maven-dependency-plugin.version>
<gephi.maven-deploy-plugin.version>2.7</gephi.maven-deploy-plugin.version>
<gephi.maven-gpg-plugin.version>1.4</gephi.maven-gpg-plugin.version>
<gephi.maven-install-plugin.version>2.4</gephi.maven-install-plugin.version>
<gephi.maven-jar-plugin.version>2.4</gephi.maven-jar-plugin.version>
<gephi.maven-jarsigner-plugin.version>1.2</gephi.maven-jarsigner-plugin.version>
<gephi.maven-javadoc-plugin.version>2.9</gephi.maven-javadoc-plugin.version>
<gephi.maven-license-plugin.version>1.9.0</gephi.maven-license-plugin.version>
<gephi.maven-release-plugin.version>2.3.2</gephi.maven-release-plugin.version>
<gephi.maven-resources-plugin.version>2.6</gephi.maven-resources-plugin.version>
<gephi.maven-source-plugin.version>2.2.1</gephi.maven-source-plugin.version>
<gephi.maven-surefire-plugin.version>2.13</gephi.maven-surefire-plugin.version>
<gephi.build-helper-maven-plugin.version>1.7</gephi.build-helper-maven-plugin.version>
<gephi.wagon-maven-plugin.version>1.0-beta-4</gephi.wagon-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.restfb</groupId>
<artifactId>restfb</artifactId>
<version>1.6.12</version>
</dependency>
<dependency>
<groupId>com.google.code.facebookapi</groupId>
<artifactId>facebook-java-api</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-beta9</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-beta9</version>
</dependency>
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-model</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>org.gephi</groupId>
<artifactId>gephi-toolkit</artifactId>
<version>0.9-SNAPSHOT</version>
<dependency>
</project>
As you may notice, the dependency is for Gephi. This is part of the error message as below:
Multiple annotations found at this line:
- Missing artifact org.netbeans.api:org-netbeans-modules-queries:jar:RELEASE721
- Missing artifact commons-codec:commons-codec:jar:1.6
- Missing artifact org.apache.xmlgraphics:batik-util:jar:1.7
- Missing artifact gnu.trove:trove:jar:2.1.0
- Missing artifact javax.activation:activation:jar:1.1
- Missing artifact org.netbeans.api:org-openide-modules:jar:RELEASE721
Could anyone help me how to solve this problem? I do not know why POM does not accept the Gephi dependency however I have already added some other dependencies such as openrdf and restfb. I also added the Gephi repository as shown in the POM file. Your help is very much appreciated.
Looking at the documentation page, it looks like you'll need to add their repository to your POM, as well:
<project>
...
<repositories>
<repository>
<id>gephi-snapshots</id>
<name>Gephi Snapshots</name>
<url>http://nexus.gephi.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>gephi-releases</id>
<name>Gephi Releases</name>
<url>http://nexus.gephi.org/nexus/content/repositories/releases/</url>
</repository>
...
</repositories>
...
</project>
I am new to pom but went through the "Getting started" on maven.apache.org and also referred to an existing project within the company before i started on this project.
Info:
If i specify the jars as referenced libs in eclipse the project is running smooth and no issues are observed.
Problem: compilation errors since unable to download dependent code from repository.
My project structure is [simplified for easier understanding]
utils
utils/commons [has source in src/main/java style] [uses package org.apache.commons.io.IOUtils]
utils/commons/pom.xml
utils/pom.xml [parent]
Now I began with commons folder to write the pom.xml as the only module and no reference to any parent / other module.
After I ran mvn install it gave errors as
ToolUtils.java:[17,28] error: package org.apache.commons.io does not exist
ToolUtils.java:[18,23] error: package org.apache.log4j does not exist
If i commented the code which was using org.apache.commons.io.IOUtils then the mvn install works fine and generates a jar.
I looked up the net and found that the issue is failing to locate the repository so i updated the reference
to parent pom.xml.
And also included the repositories details in the parent pom.xml. [which is directly under utils folder]
I am still getting the same error and the build does not move further.
ToolUtils.java:[17,28] error: package org.apache.commons.io does not exist
ToolUtils.java:[18,23] error: package org.apache.log4j does not exist
I am using an internal URL which i have verified manually in a broswer.
Also I have verified that the proxy details are correct since another old project refers to the same URL and is getting built properly.
[Unfortunately the project is far too complex to copy paste the pom.xml and modify ,
hence writing the pom.xml from scratch.]
Can some point what am i missing which causes no download from repository ?
Thanks in advance.
Any help would be deeply appreciated.
Note:
1) I am pasting snippets from the 2 different pom.xml with their directory names for easier identification. Attachments can be provided on request.
2) I have modified the references to confidential data across to protect some identities.
utils/common/pom.xml [commons module]
....
<parent>
<groupId>com.osg.rtos</groupId>
<artifactId>rxutils</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
....
<dependencyManagement>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>com.osg.rtos</groupId>
<artifactId>rtos-commons-service</artifactId>
<version>${rtos.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
utils/pom.xml [parent]
....
<groupId>com.osg.rtos</groupId>
<artifactId>rxutils</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>rxutils</name>
<packaging>pom</packaging>
<repositories>
<repository>
<id>release</id>
<url>http://internal.com/~devbuild/repository</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.osg.rtos</groupId>
<artifactId>rtos-commons-service</artifactId>
<version>${rtos.version}</version>
</dependency>
<dependency>
<groupId>com.osg.rtos</groupId>
<artifactId>rtos-data</artifactId>
<version>${rtos.version}</version>
</dependency>
<dependency>
<groupId>com.osg.rtos</groupId>
<artifactId>rtos-exception</artifactId>
<version>${rtos.version}</version>
</dependency>
<dependency>
<groupId>com.osg.rtos</groupId>
<artifactId>rtos-mailbox-service</artifactId>
<version>${rtos.version}</version>
</dependency>
<dependency>
<groupId>com.osg.rtos</groupId>
<artifactId>rtos-message-service</artifactId>
<version>${rtos.version}</version>
</dependency>
<dependency>
<groupId>com.osg.rtos</groupId>
<artifactId>rtos-rest</artifactId>
<version>${rtos.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>commons</module>
<module>rxutils</module>
<module>tool</module>
</modules>
...
You need to remove the <dependencyManagement> tags that surround the <dependencies> section in the commons module pom.xml.
The <dependencyManagement> section allows you to specify dependency information, such as version number, in a parent pom (as you have done) so that you can simplify dependencies in the child poms. However, you still need a <dependencies> section to specify what dependencies are required for that child.
in pom.xml use
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
remove or comment <exclusions> and <exclusion>