Maven is not automatically building default folder path in eclipse - java

I am using Eclipse Indigo. I installed the maven package on eclipse. I configured the Pom and nearly everything is fine. Just maven is not building the default folder bath
src/main/java
Here is the pom.
<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>TestProject</groupId>
<artifactId>TestProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.0.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.6</version>
<configuration>
<ajdtVersion>1.6</ajdtVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
I cleaned the project,installed and build it.... also I upgradet the project... the dependencies are all fine... no error at all.. why isn't the folder build ?

Eclipse's integration with maven is (to say at least) appalling. If you want to create a new project: create the pom and the folders, and then run mvn eclipse:eclipse to create the project files for eclipse. The simple solution that I've followed for a couple of years is to use the community edition of Intellij.
Aswering your second question: well... again, the integration is so poor that sometimes you'll need to close and reopen the project for eclipse to read the new changes. Most of the time, a refresh + clean project will force eclipse to read the project configuration.

Related

Eclipse JDT core Java runtime error - java.lang.NoSuchMethodError

I could not find any helping document regarding this error hence I am posting this question.
I am trying to use locally built Eclipse JDT core jar in my project. I followed the flowing steps.
Created an eclipse workspace as described in Link
Built eclipse.jdt.core using the mvn -P build-individual-bundles package
Added the resulting jar file that is created in the target folder to my project (i.e., project A) as a maven dependency.
After the above steps, I could successfully compile project A and now it gives me the following runtime error.
Exception in thread "pool-2-thread-1" java.lang.NoSuchMethodError: org.eclipse.core.runtime.SubMonitor.split(I)Lorg/eclipse/core/runtime/SubMonitor;
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:820)
at utils.JavaASTUtil.parseSource(JavaASTUtil.java:87)
at change.CFile.<init>(CFile.java:32)
at change.RevisionAnalyzer.buildGitModifiedFiles(RevisionAnalyzer.java:310)
at change.RevisionAnalyzer.analyzeGit(RevisionAnalyzer.java:130)
at change.ChangeAnalyzer.analyzeGit(ChangeAnalyzer.java:243)
at change.ChangeAnalyzer.analyzeGit(ChangeAnalyzer.java:228)
at main.MainChangeAnalyzer$2.run(MainChangeAnalyzer.java:99)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
pom.xml of the project is given below
<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>AtomicASTChangeMining</groupId>
<artifactId>AtomicASTChangeMining</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<id>local-maven-repo</id>
<url>file:///Users/xx/Documents/Research_Topic_2/</url>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--Below is the locally built jdt core jar -->
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.23.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>runtime</artifactId>
<version>3.10.0-v20140318-2214</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.core.resources</artifactId>
<version>3.10.0.v20150423-0755</version>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
<version>3.10.0-v20140606-1445</version>
</dependency>
</dependencies>
</project>
Does anybody have any idea about the runtime error?
Thanks a lot!
org.eclipse.core.runtime.SubMonitor is actually in the org.eclipse.equinox.common plug-in.
According to the Javadoc the split methods were added to SubMonitor in version 3.8 of org.eclipse.equinox.common. This corresponds to Eclipse release 4.6.
Do experiments on org.eclipse.core version. You might need to upgrade the version of org.eclipse.birt.runtime. Select the version that contains the method SubMonitor.split().

How can I remove maven dependency jar in Eclipse

I'm really new to Maven and just converted my app-engine project to a Maven project.
I've added dependencies in the pom.xml file in order to get rid of the errors.
but now I get in my code
The method getPart(String) is undefined for the type HttpServletRequest
So after doing a bit of research on Stack Overflow it appears I need to have a single and updated package of servlet-api to make that work properly.
Apparently I may have a conflict with an older version that is in my Maven dependencies but I never added it in the pom.xml and now I'm stuck with this jar not knowing why it is imported and how I can delete it.
Here is my 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>my-project</groupId>
<artifactId>my-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.1</version>
<configuration>
<deploy.promote>true</deploy.promote>
<deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.mailjet</groupId>
<artifactId>mailjet-client</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>com.google.appengine.tools</groupId>
<artifactId>appengine-gcs-client</artifactId>
<version>0.8</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
and here are images of what I get in Maven dependencies in my build path.
my guess is that the error comes from having a 2.5 version of the servlet-api.
So any help is greatly appreciated, I saw something about the exclusion
tag but don't even know where to put it as it doesn't look like anything in the pom.xml is asking for this jar.
You'd better open in Eclipse your pom.xml file and switch to the "dependency hierarchy" tab. Look for the undesired library (type in "serlvet" in the filter) and add exclusion on it through the context menu. This will modify your pom.xml file.
Delete project from workspace and don't check Delete project content on disk. Delete the jar from .m2 folder as well. Import the project using eclipse. Open the pom file and click on dependency Hierarchy. Select the the jar you want to delete. Right click and click on Exclude Maven Artifact. Next time you run the proejct it will not download the jar.

using super pom only for testing

I have a lot of maven projects, which are dependent on each other.
I already have a super pom for the actual projects and this works pretty well.
Now I want to create a super pom for all my integrationtests projects. I did it the same, but every time I run maven test it failed.
[ERROR] Failed to execute goal on project *: Could not resolve
dependencies for project ::jar:0.0.1-SNAPSHOT: The following
artifacts could not be resolved: ::jar:0.0.1-SNAPSHOT,
::jar:0.0.1-SNAPSHOT, ::jar:0.0.1-SNAPSHOT, ::jar:0.0.1-SNAPSHOT: Could not find artifact *:***:jar:0.0.1-SNAPSHOT -> [Help 1]
The problem is that maven looks for jar files but my project consists of war projects. Here is my 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>***</groupId>
<artifactId>***-parent_IntegrationTests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>***_IntegrationTests</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<modules>
<module>../***</module>
<module>../***</module>
<module>../***</module>
<module>../***</module>
<module>../***</module>
<module>../***</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
Is there a way to tell maven to use the war files instead of jars?
Edit: Sorry if it is not clear enough. I want a single maven project to run all my integrationtest projects. each one is a maven project. Therefor I want to use a pom with modules (all the integrationtest project) in it. But every integrationtest project contains dependencies to my other projects and the problem I want to fix is that maven does not find my compiled projects because it looks for jar files but my projects are war files.
You can reference WARs as dependencies by using <type>war</type> in the dependency.

Problems converting Dynamic Web Project to Maven

I'm using Eclipse Luna with Websphere Application Sever 8.5.
When I run a dynamic web project using the Websphere Application Sever 8.5 it runs fine.
However, when I convert a dynamic web project to a maven project, i'm getting around 53 errors starting with Missing artifact com.ibm.websphere e.g Missing artifact com.ibm.websphere.xml:xmlapi:jar:1.0.0' all located in my pom.xml.
I am also getting this error:
The container 'Maven Dependencies' references non existing library
C:\Users\Brian242\.m2\repository\com\ibm\websphere\ws\com.ibm.ws.wccm\1.0.0\com.ibm.ws.wccm-1.0.0.jar'
Not sure if that's part of the problem.
I've looked everywhere for a solution but haven't found anything. So I have decided to ask for some help. Does anyone know how to solve the above problem/s?
Thank you,
Brian
<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>TrialProj</groupId>
<artifactId>TrialProj</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.ibm.tools.target</groupId>
<artifactId>was</artifactId>
<version>8.5.5</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
you created M2_REPO environment variable?
right click on the project root
Build Path-> Configure Puild Path ...
Click button 'Add Variable'
Click 'Set Variable ...'
Click 'New ...'
name: M2_REPO
Path: / path_to_repository_the_maven /
Click Ok
Recompile
If you are using eclipse make sure you add suport for eclipse web tools using:
mvn eclipse:eclipse -Dwtpversion=2.0
(2.0 or your required version) And afterwards recompile maven project:
mvn compile

I'm having troubles to compile a maven project

I've imported my project into Eclipse (Helios + m2eclipse), and also into Netbeans (7.0) and in both IDEs one of the troubles is:
This is what I get in Netbeans when I try to build.
The project com.miCompany:myProject:1.0 (.....) has 1 error
Unresolveable build extension: Plugin
org.apache.axis2:axis2-wsdl2code-maven-plugin:1.3
or one of its dependencies could not
be resolved: Failed to collect
dependencies for
org.apache.axis2:axis2-wsdl2code-maven-plugin:jar:1.3
(): Failed to read artifact descriptor
for
org.apache.woden:woden:jar:1.0-incubating-M7b:
Could not transfer artifact
org.apache.woden:woden:pom:1.0-incubating-M7b
from/to jibx
(http://jibx.sourceforge.net/maven):
No connector available to access
repository jibx
(http://jibx.sourceforge.net/maven) of
type legacy using the available
factories
WagonRepositoryConnectorFactory ->
[Help 2]
This is what I get in Eclipse:
Project build error: Unresolveable build extension: Plugin
org.apache.axis2:axis2-wsdl2code-maven-plugin:1.3
or one of its dependencies could not
be resolved: Failed to collect
dependencies for
org.apache.axis2:axis2-wsdl2code-maven-plugin:jar:1.3
() pom.xml /myProject line 1 Maven
Problem
In Eclipse I've downloaded this: http://www.apache.org/dyn/mirrors/mirrors.cgi/axis/axis2/java/core/1.5.4/axis2-eclipse-service-plugin-1.5.4.zip unzipped and copied the file: "org.apache.axis2.eclipse.codegen.plugin_1.5.4.jar" into the directory "plugins" of my Eclipse instalation. And I still getting the same error.
I am running Netbeans over Win XP and Eclipse over Win XP and also over Mac, allways the same error.
Does somebody have any idea what can I do?
Here goes my 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>
<artifactId>MyParent</artifactId>
<groupId>com.mycompany</groupId>
<version>1.0</version>
</parent>
<groupId>com.mycompany</groupId>
<artifactId>myModule</artifactId>
<version>1.0</version>
<name>myModule</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>src/main/java</directory>
<includes>
<include>com/mycompany/client/*.java</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.3</version>
<extensions>true</extensions>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2code</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>com.mycompany.client</packageName>
<wsdlFile>src/main/axis2/MyWsdl.wsdl</wsdlFile>
<outputDirectory>.</outputDirectory>
<targetResourcesFolderLocation>target/main/axis2</targetResourcesFolderLocation>
<targetSourceFolderLocation>src/main/java</targetSourceFolderLocation>
<namespaceURIs>
<namespaceURI>
<uri>http://schema.mycompany.com/Esb</uri>
<packageName>com.mycompany.services.Esbsrv.schema</packageName>
</namespaceURI>
<namespaceURI>
<uri>http://wsdl.mycompany.com/Esb</uri>
<packageName>com.mycompany.services.Esbsrv.schema</packageName>
</namespaceURI>
<namespaceURI>
<uri>http://schema.mycompany.com/Global/WSException</uri>
<packageName>com.mycompany.schema.global.wsexception</packageName>
</namespaceURI>
</namespaceURIs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
<scope>compile</scope>
</dependency>
-->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
<!--
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-xmlbeans</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
-->
</dependencies>
</project>
Well, I can only offer suggestions as I"m not much of a maven expert, but I did just have to do this today and it was pretty straightforward for me -
set up the maven project to be eclipse friendly : mvn eclipse:eclipse
make sure eclipse can see the libs. this meant going to the projectsetup/buildpath/libraries editor in eclipse and adding the variable M2_REPO to point to your local maven repository (e.g. something like /home/nacho3d/.m2/repository)
Your error, actually, looks to me like maven can't find a dependency for axis. The specifics for that should be on the axis website,
I think you're using maven 3.0+, right?
That pom(org.apache.woden:woden:jar:1.0-incubating-M7b) isn't compatible with maven 3 yet.
If you use maven 2.2.1 to build ESB 4.3.0-03 source, then it would be successfully.
If you have the jar of the missing dependency you can:
1) deploy it on your maven repository, if you have one
2) declare the dependency in your pom with a scope of 'system': check this out
I have also faced the same problem and fixed it by following below step...
In you project directory do the command: mvn eclipse:eclipse
In eclipse project right click->Maven->Update Project.
Again right click->Maven->Disable Maven Nature
Restart eclipse.
Right click on project->Configure->Convert to Maven Project.
Finish. Error will gone.
Thanks

Categories