Problems when compiling and running a simple Maven project with Spring in JDeveloper 12c - spring

I'm trying to compile and run the first examples of the book "Beginning Spring" in JDeveloper but I'm running with some issues.
Here's the 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wiley.beginningspring</groupId>
<artifactId>spring-book-ch2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring-book-ch2</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.5.RELEASE</version>
</dependency>
</dependencies>
<repositories/>
<pluginRepositories/>
</project>
JDeveloper marks the following imports with errors of package not found:
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Qualifier;
Of course I can't compile the project since those errors are present.
I've already installed Spring integration in the Updates menu.
In Netbeans 8 and Spring Tool Suite the project marks no errors and compiles and runs fine.

Try adding this dependency to your pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>

Related

Migrate old Java 8 maven/netbeans project to a modern GraalVM/Java 19 in VScode

I'm studying Visual Studio Code and GraalVM, I have this pack [1] and an old Java 8 project. What is the best way to make VScode/Maven/Netbeans Language Server to compile my project with the latest Java to see what should I fix?
Here's the 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.vsetec</groupId>
<artifactId>vsetec-utilities</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax.sip</groupId>
<artifactId>jain-sip-ri</artifactId>
<version>1.3.0-91</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<type>jar</type>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<name>Utilities</name>
<description>Some reusable procedures</description>
</project>
Everything is a bit old, so I'm going to make it check against the modern Java and fix dependencies one by one, but I'm guessing the "compiler source and target" are already an obsolete Maven plugin configurations. Any tips?
[1] https://www.graalvm.org/latest/tools/vscode/graalvm-extension-pack/

Missing artifact spring-webmvc:spring-webmvc:jar:4.0.6.RELEASE

I am very much new to the world of Java, Spring.
Building my first Maven project today with loads of issues.
I'm unable to get my pom.xml working.
this is the auto XML built in my eclipse and using Maven, Dynamic Web Project.
<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.bapu</groupId>
<artifactId>SpringMVCDemo</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>SpringMVCDemo 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>
<dependency>
<groupId>spring-webmvc</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet-api</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>SpringMVCDemo</finalName>
</build>
</project>
updated the 4.0.6 to the available version 4.0.3 as per the jars list in WEB-INF\lib folder.
It worked perfect.

Project build error: Non-parseable POM : expected START_TAG or END_TAG not TEXT (position: TEXT seen ...</dependency>\ufeff\r\n <d... #28:7)

I am new to spark-scala, i am trying to write spark application in scala IDE, so i have created a maven project and trying to edit pom.xml file, when i add dependency to the pom.xml, i am getting below error
Project build error: Non-parseable POM : expected START_TAG or END_TAG not TEXT (position: TEXT seen ...</dependency>\ufeff\r\n <d... #28:7)
the error appearing at one of dependency.
Kindly help, thru old answers i didn't able to resolve.
<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.orientit.spark.training</groupId>
<artifactId>firstpgm</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>firstpgm</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.4</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The error indicates that your XML format is incorrect and thus cannot be parsed by the XML parser. You have to check your XML carefully for opening and closing tags. For some reason your closing tag is followed by the UTF-16 Byte Order Marker.
<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.orientit.spark.training</groupId>
<artifactId>firstpgm</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>firstpgm</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.4</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

Download/import all dependencies from Spring IO

I work for a large organization where all development tools must go through a rigorous certification process and security assessment. I want to have Spring IO Brussels SR2 certified, along with Apache Maven.
I'd like to provide them with a ZIP file containing all JARs (dependencies and transitive dependencies) of the Spring IO platform so they can do the security assessment on it.
Being a new Maven user, I've created a new Maven project in Eclipse, and simple added this in 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>my.company</groupId>
<artifactId>MySpringApp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>MySpringApp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR2</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>MySpringApp</finalName>
</build>
</project>
The project compiles and packages correctly, but it's not importing/adding any JARs to the packaged WAR file. I've also tried to change the scope to compile.
Is it possible? Is it because it's a bill of material?
Thank you
According to the Website you have to enable the dependency-tree using
<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>my.company</groupId>
<artifactId>MySpringApp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>MySpringApp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<build>
<finalName>MySpringApp</finalName>
</build>
</project>
Eclipse and Maven are designed to be able to work alone, a bit of experiences is required to let them work together, often a cleanup using Update Project ... (project-rightclick/maven) is required
I ended up downloading the dependency versions list into a CSV file, then loop through it in a simple Java class, outputting the results in a tag manually. Then, I was able to copy/paste all those tags into my pom.xml file and then get all those dependencies resolved by Maven.
Finally, I have taken the content of /target/WEB-INF/lib.

Accessing Elasticsearch through JAVA API with Eclipse

I'm a beginner trying to access elasticsearch through JAVA with eclipse, but after following the instructions available at this guide , eclipse is not able to import packages like org.elasticsearch.node.* and I haven't been able to continue.
This is my first time with Maven, and the configurations might be wrong.
This is my pom.xml 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>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>elasticsearch</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${es.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I can access elasticsearch through a terminal or browser, but not with eclipse. What step I am missing?
You haven't defined es.version in your properties section. mvn install should have thrown errors because it can't download elasticsearch dependencies. I think following change to your pom would work.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<es.version>0.90.3</es.version>
</properties>
Here is the pom.xml in my eclipse Maven project. It works. Just for you reference.
<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>elastic.mapper</groupId>
<artifactId>importer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>importer</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</project>

Resources