i'm stuck with a problem and can't figure what's wrong.
I have a multi-module maven project, using spring boot.
Layout of the project
I'm using STS, and everything is fine. If i run the app, it runs the server, and i have my index in localhost:8080.
However, i'd like to generate a jar from this. So, i'm using mvn clean install. It generates a jar in /target. The layout in the jar is fine, with the source, and the source of the client.
Then, i'm running my jar with java -jar myJar.jar. The server runs properly, but when i'm trying to access to the site, i have an error 404. It can't find the views.
The error :
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Dec 28 19:45:52 CET 2016
There was an unexpected error (type=Not Found, status=404).
No message available
Here's my pom.xml of the web and client module.
Client pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>projet.si</groupId>
<artifactId>projetsi</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>projet.si</groupId>
<artifactId>ProjetSI_client</artifactId>
<name>ProjetSI_client</name>
<url>http://maven.apache.org</url>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/webapp</directory>
</resource>
<resource>
<directory>${project.build.directory}/dist</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<outputDirectory>${project.build.directory}/classes/</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Module web pom.xml :
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>projet.si</groupId>
<artifactId>projetsi</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>projet.si</groupId>
<artifactId>ProjetSI_web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ProjetSI_web</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>projet.si</groupId>
<artifactId>ProjetSI_business</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>projet.si</groupId>
<artifactId>ProjetSI_client</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<configuration>
<outputDirectory>${project.build.directory}/dist/</outputDirectory>
<includeArtifactIds>ProjetSI_client</includeArtifactIds>
<includeGroupIds>projet</includeGroupIds>
<includes>**/*</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I've search over stackoverflow but haven't find anything :/
If you need more details or code, ask me i'll edit.
Thanks !
Please check if you have any method attached to the url your are hitting from the browser. 404 - not found, the resource or url you are trying to access does not exists. You should have a Method of a controller mapped to "/" or whatever url you are hitting.
Related
I created a maven project and added a JavaFX project to it. I made the following pom.xml
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>SEF-PROJ</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<javafx.version>16</javafx.version>
<javafx.maven.plugin.version>0.0.6</javafx.maven.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${maven.compiler.release}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.maven.plugin.version}</version>
<configuration>
<executable>/home/mrsaiba/.jdks/corretto-1.8.0_292/jre</executable>
<mainClass>src.sampe.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I run the mvn javafx:run, I got the error
Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.6:run (default-cli) on project SEF-PROJ: Error
I googled it for days, but nothing useful showed up. I am using Java 8 and JavaFX 16(I don't want use a newer version of Java). I set up the JAVA_HOME with the path to the Java 8 jre.
In Maven 3 if you just had a failed download and have fixed it (e.g. by uploading the jar to a repository) it will cache the failure.
To force a refresh add -U to the command line.
Source: https://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
I am trying to test the basic structure of my GUI application that I started using WindowBuilder. I am also using Maven so that I can just download the dependencies from their repository.
I don't have any errors when I do a "Maven Clean" or a "Maven Install", but when I try to do "Run As--->Java Application", I get the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-win32-3044 in java.library.path
swt-win32-3044 was what I found in the Maven Repository to satisfy the requirements for the WindowBuilder. I don't have any errors in my POM file, but here is what I have...
<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>blah.blah.blah</groupId>
<artifactId>blah</artifactId>
<version>1.0.0</version>
<name>blah</name>
<dependencies>
<dependency>
<groupId>swt</groupId>
<artifactId>swt-win32</artifactId>
<version>3.0m8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>java.library.path</name>
<value>${project.build.directory}</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
Any help would be greatly appreciated. Thanks.
So I changed the POM around a little bit. I tried a different Maven dependency for WindowBuilder and changed my syntax for defining the maven-surefire-plugin.
<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>blah.blah.blah</groupId>
<artifactId>blah</artifactId>
<version>1.0.0</version>
<name>blah</name>
<dependencies>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
<version>4.3</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
It now launches the Java application window as expected.
I'm very new to maven, so kindly bear with me.
i have a maven project with almost 100 dependencies all of which are present in my local system. So I'm adding them to my classpath via pom.xml with <scope> being system and <systemPath> giving path to the said dependencies. A rough structure of my pom.xml looks like this:
<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</groupId>
<artifactId>MAVEN_APP</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>MAVEN_APP</name>
<properties>
<jdk.version>1.8</jdk.version>
</properties>
<dependencies>
<dependency>
<groupId>jar1</groupId>
<artifactId>dependency1</artifactId>
<version>0.9.5</version>
<scope>system</scope>
<systemPath>path/to/directory/outside/project/directory/jar1Name.jar</systemPath>
</dependency>
......
<dependency>
<groupId>jar100</groupId>
<artifactId>dependency10</artifactId>
<version>1.9.7</version>
<scope>system</scope>
<systemPath>path/to/directory/outside/project/directory/jar10Name.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
This includes all the jars into my classpath and everything is running fine.
But i would like to keep the path/to/directory/outside/project/directory/ inside my app.propeties file and pom.xml should fetch this path from the properties file.
Is there a way in maven to do this.
Could somebody help me here. Thanks in advance.
Desperatley trying to create a EAR bundle with some modules, using the maven EAR plugin version 2.10.1 with Maven 3. There is a problem with the generate-application-xml goal, I´m getting the error:
Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.10.1:generate-application-xml (default-generate-application-xml) on project wineapp-ear: Unable to parse configuration of mojo org.apache.maven.plugins:maven-ear-plugin:2.10.1:generate-application-xml for parameter version: Cannot find 'version' in class org.apache.maven.plugin.ear.EjbModule -> [Help 1]
here is the pom.xml snippet:
<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>
<artifactId>wineapp-parent</artifactId>
<groupId>com.jueggs</groupId>
<version>1.0.0</version>
</parent>
<artifactId>wineapp-ear</artifactId>
<packaging>ear</packaging>
<name>wineapp-ear</name>
<dependencies>
<dependency>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-ejb</artifactId>
<version>1.0.0</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-web</artifactId>
<version>1.0.0</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-jpa</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<!--<version>6</version>-->
<!--<applicationXml>/src/main/application/META-INF/</applicationXml>-->
<modules>
<ejbModule>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-ejb</artifactId>
<version>1.0.0</version>
<bundleFileName>ejb.jar</bundleFileName>
</ejbModule>
<webModule>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-web</artifactId>
<version>1.0.0</version>
<bundleFileName>web.war</bundleFileName>
</webModule>
<jarModule>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-common</artifactId>
<version>1.0.0</version>
<bundleDir>lib</bundleDir>
<bundleFileName>common.jar</bundleFileName>
</jarModule>
<jarModule>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-jpa</artifactId>
<version>1.0.0</version>
<bundleDir>lib</bundleDir>
<bundleFileName>jpa.jar</bundleFileName>
</jarModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
what the hack is wrong here? or is it just a f.. typo in the xml? inside the configuration element, the automatic tag detection by IDE (how is the word for that..) also not working, but i compared it with examples nearly a thousand times. don´t know what else matters for error finding, there´s also a parent pom
An module did not have a version tag see modules. The version is already defined by the dependency blog and the module blog is just use for renaming the artifacts in the ear file (since you define a new bundleFileName). So try to remove all version tags in your modules like this:
<modules>
<ejbModule>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-ejb</artifactId>
<bundleFileName>ejb.jar</bundleFileName>
</ejbModule>
<webModule>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-web</artifactId>
<bundleFileName>web.war</bundleFileName>
</webModule>
<jarModule>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-common</artifactId>
<bundleDir>lib</bundleDir>
<bundleFileName>common.jar</bundleFileName>
</jarModule>
<jarModule>
<groupId>com.jueggs</groupId>
<artifactId>wineapp-jpa</artifactId>
<bundleDir>lib</bundleDir>
<bundleFileName>jpa.jar</bundleFileName>
</jarModule>
</modules>
Or better remove the complete modules blog because I do not think its important for you to rename the dependencies in the ear and it is OK to use the Maven default names.
I am using maven in my project & I've put database.properties file under
maven resources folder.
I am accessing it in spring application context
<context:property-placeholder location="classpath:database.properties" />
But I don't understand why I am getting this file not found error on server start.
Could not load properties; nested exception is
java.io.FileNotFoundException: class path resource
[database.properties] cannot be opened because it does not exist
To my knowledge whatever resource is put under resources folder it is added to the classpath automatically by maven.
pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp</groupId>
<artifactId>myapp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>myapp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>myapp</finalName>
</build>
</project>
NOTE: Seems like there is some problem with the M2E plugin of eclipse luna. Executed the same code in Juno & it worked fine.
That's not enough to build a deployable war file with maven. You need at least the war plugin. There's a thorough tutorial here:
http://crunchify.com/how-to-create-a-war-file-from-eclipse-using-maven-plugin-apache-maven-war-plugin-usage/
Your pom will look something like below, and you'll need to run mvn clean install against that.
Also I see you have a spring app, where are the spring dependencies in 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>CrunchifyTutorial</groupId>
<artifactId>CrunchifyTutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
</project>