build CDT source code with m2eclipse - maven

all,
I am trying to build one of CDT plugin and export it independently. For example, I built "org.eclipse.cdt.ui" plugin, and then I got the following built error message:
Project has not been setup yet MavenProject: org.eclipse.cdt:org.eclipse.cdt.ui:5.5.0-SNAPSHOT # C:\Documents and Settings\0359\workspace\org.eclipse.cdt\core\org.eclipse.cdt.ui\pom.xml org.eclipse.cdt.ui line 1 Maven Problem
I am headless with this problem, any suggestion is good. thanks.
its pom.xml is as following:
<?xml version="1.0" encoding="UTF-8"?>
<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>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
<version>8.2.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<version>5.5.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.ui</artifactId>
<packaging>eclipse-plugin</packaging>
< /project>

Related

ivy.xml to pom.xml file

I am attempting to replace our internal Ivy repository with Artifactory and converting everything to Maven. The current repository is hosted on one of our servers in subversion and I am trying to get away from this. My biggest question has to do with the markdown of the ivy.xml and how it relates to pom.xml. I used the ant task makepom to convert but it seems to exclude the configurations and the publications section in the ivy.xml file. To be honest, I am new to ivy and maven and can't seem to find anything that explains this is maven terms. The particular file in question looks like this
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../../../../xsl/ivy-doc.xsl"?>
<ivy-module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:noNamespaceSchemaLocation="../../../../xsd/ivy.xsd">
<info organisation="net.java.dev.jna" module="jna" revision="3.4.0" status="release" publication="20111210120000">
<license name="GNU Lesser General Public License, version 2.1 or later" url="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html"/>
<ivyauthor xmlns:ivyde="http://ant.apache.org/ivy/ivyde/ns/" name="Ivy RoundUp Repository" url="https://github.com/archiecobbs/ivyroundup/blob/master/src/modules/net.java.dev.jna/jna/3.4.0/"/>
<repository xmlns:ivyde="http://ant.apache.org/ivy/ivyde/ns/" pattern="https://raw.githubusercontent.com/archiecobbs/ivyroundup/master/repo/modules/[organisation]/[module]/[revision]/ivy.xml" ivys="true" url="https://github.com/archiecobbs/ivyroundup" name="ivyroundup"/>
<description homepage="https://github.com/java-native-access/jna">
</info>
<configurations>
<conf name="core" description="JNA core library"/>
<conf name="platform" description="JNA platform library"/>
<conf name="default" extends="core,platform" description="JNA core + platform library"/>
</configurations>
<publications>
<artifact name="jna" ext="pom" type="pom"/>
<artifact conf="core" name="jna"/>
<artifact conf="core" name="jna-source" type="source" ext="zip"/>
<artifact conf="core" name="jna-javadoc" type="javadoc" ext="zip"/>
<artifact conf="platform" name="platform"/>
<artifact conf="platform" name="platform-source" type="source" ext="zip"/>
<artifact conf="platform" name="platform-javadoc" type="javadoc" ext="zip"/>
</publications>
The pom file I have created looks like so
<?xml version="1.0" encoding="UTF-8"?>
<!--
Apache Maven 2 POM generated by Apache Ivy
http://ant.apache.org/ivy/
Apache Ivy version: 2.4.0 20141213170938
-->
<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>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<packaging>jar</packaging>
<version>3.4.0</version>
<url>https://github.com/java-native-access/jna</url>
</project>
I've omitted some of the code connecting to our server. Trying to publish with maven publishes an empty jar file, I want to just publish the existing 3rd party jar. Any ways, if I could get some more clarification on migrating that publications block over to the pom file, that would be great.

NullPointerExpection on basic EJB application in NetBeans 7.3.1

I'm doing a course on Enterprise computing using Beginning Java EE 6 Platform with GlassFish 3: From Novice to Professional
Last chapter was about EJB and I've actually found it very hard to understand.
I've been trying to run one of the book's sample codes in order to try to better understand EJB but I'm getting a NullPointerException whenever I call for the EJB.
I'm using NetBeans 7.3.1 and the Maven and Glassfish versions provided with NetBeans (Maven seems to be 3.0.5, and Glassfish is 4.0)
This is the code for the main class:
package org.beginningee6.book.chapter06;
import javax.ejb.EJB;
/**
* #author Antonio Goncalves
* APress Book - Beginning Java EE 6 with Glassfish
* --
*/
public class Main {
// ======================================
// = Attributes =
// ======================================
#EJB
private static BookEJBRemote bookEJB;
// ======================================
// = Public Methods =
// ======================================
public static void main(String[] args) {
// Creates an instance of book
Book book = new Book();
book.setTitle("The Hitchhiker's Guide to the Galaxy");
book.setPrice(12.5F);
book.setDescription("Science fiction comedy series created by Douglas Adams.");
book.setIsbn("1-84023-742-2");
book.setNbOfPage(354);
book.setIllustrations(false);
book = bookEJB.createBook(book);
System.out.println("### Book created : " + book);
book.setTitle("H2G2");
book = bookEJB.updateBook(book);
System.out.println("### Book updated : " + book);
System.out.println("Execution succeeded");
}
}
Here is the persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="chapter06PU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<!--<jta-data-source>jdbc/__default</jta-data-source>-->
<jta-data-source>jdbc/chapter06DS</jta-data-source>
<class>org.beginningee6.book.chapter06.Book</class>
<properties>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.logging.level" value="INFO"/>
</properties>
</persistence-unit>
</persistence>
And this 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>
<groupId>org.beginningee6.book</groupId>
<artifactId>chapter06</artifactId>
<packaging>jar</packaging>
<version>2.0</version>
<name>Week5</name>
<parent>
<groupId>org.beginningee6.book</groupId>
<artifactId>chapters</artifactId>
<version>2.0</version>
</parent>
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>${javax.persistence-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>${eclipselink-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>${glassfish-version}</version>
</dependency>
</dependencies>
<!--To avoid multiple modules with Maven, here is what you need to manually do (it's not nice, but it works)
1) Comment the following section (maven-jar-plugin), package the jar, and deploy to GlassFish
2) Uncomment the following section, package the jar and run the Main class with app client -->
<build>
<!-- <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${plugin-jar-version}</version>
<configuration>
<archive>
<manifest>
<mainClass>org.beginningee6.book.chapter06.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>-->
</build>
</project>
I'm getting this error:
Exception in thread "main" java.lang.NullPointerException
at this line:
book = bookEJB.updateBook(book);
Apparently Maven is giving this error:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project chapter06: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project chapter06: Command execution failed.
And after activating Maven's debugging option the last command line before the error is:
Executing command line: C:\Program Files (x86)\Java\jdk1.7.0_21\bin\java.exe -classpath C:\Users\Manuel_Laptop\Desktop\Week5\COIT20227LabSolWeek5\Week5\target\classes;C:\Users\Manuel_Laptop\.m2\repository\org\eclipse\persistence\javax.persistence\2.0.0\javax.persistence-2.0.0.jar;C:\Users\Manuel_Laptop\.m2\repository\org\eclipse\persistence\eclipselink\2.0.1\eclipselink-2.0.1.jar;C:\Users\Manuel_Laptop\.m2\repository\org\glassfish\extras\glassfish-embedded-all\3.0.1-b19\glassfish-embedded-all-3.0.1-b19.jar org.beginningee6.book.chapter06.Main
After going through some course tips and some forums I went and set my JAVA_HOME and M2_HOME to their respective directories but nothing worked. I even found a link to someone having an issue on the same chapter of the textbook (https://getsatisfaction.com/javaee6/topics/yet_another_chapter_6_ejb_problem) after seeing it referenced here in StackOverflow, but couldn't find anything there (didn't understand it to be honest)
It's not maven issue, you should set up ejb container in java SE enviroment to use EJB.
Try someithing like this
EJBContainer.createEJBContainer()
you can get complete example at http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/embeddedContainerDemo/EmbeddedContainerDemo.html

Maven, multi web modules shared Controllers, jsp, styles, scripts

It's it possible with Maven to share common controllers, jsp's and other resources to the web module.
Structure
web1 (packaging jar)
--main
--java
--controller
MyControllerToShared with #Controller annotation
--resources
--webapp
--scripts
javascripts files
--styles
css files
--WEB-INF
--views
jsp to share
pom.xml
web2 (packaging war)
Classic web app structure with dependency of web1.jar
My web2 app works but no mapping found for HTTP request with URI define in web1 module. I use annotation #Controller and #RequestMapping. I defined in the servlet.xml:
<context:component-scan base-package="controller" />
<mvc:annotation-driven/>
How can I share controllers and resources between different web modules?
At the end, I need to have 3 web app with commons stuffs (error handler, jsp's errors, styles, js, ...).
Why don't you just create an extra project with all the shared resources? You can reuse that in all your web apps, just include the shared file in your pom.xml as a dependency.
You can start with an additional project with the shared resources:
<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>nl.connexys</groupId>
<artifactId>shared</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Shared resources</name>
</project>
In your webapp project you can then use that project as a dependency:
<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>nl.connexys</groupId>
<artifactId>webapp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Webservice endpoints</name>
<dependencies>
<dependency>
<groupId>nl.connexys</groupId>
<artifactId>shared</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
But this is all very basic Maven stuff. I think the examples should point you in the right direction.
Take a look at this answer:
https://stackoverflow.com/a/14143954/600007
, and the refernce for that: http://maven.apache.org/plugins/maven-war-plugin/overlays.html
It will work for jsp-s, js-s, etc...

Causes for java.io.FileNotFoundException: class path resource [services.xml] cannot be opened because it does not exist

I have a web-application on RAD 7.5. I am building the application using Maven and deploying on WebSphere 6.1.
A part of my web.xml is:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:services.xml</param-value>
</context-param>
This is the only place where I am referencing services.xml.
My services.xml is in folder
FruitApplication/src/main/resources/services.xml
After building with maven, services.xml is in the following path in the target folder
target/FruitApplication-1.0.0/WEB-INF/classes/services.xml
On deployment, I continuously get below mentioned error. However, on building the application two three times, it disappears on its own and then reappears again haphazardly.
What is the actual cause of this error ?
How to solve this error ?
The top of my services.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
Is something needs to be changed here ???
Below is the complete pom.xml I am using for "maven-install":
<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>FruitApplication</groupId>
<artifactId>FruitApplication</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<archive>
<manifestFile>
src/main/webapp/META-INF/MANIFEST.MF
</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
... dependencies here ...
</dependencies>
</project>
I have already tried all the below three options:
<param-value>classpath:services.xml</param-value>
<param-value>classpath:/services.xml</param-value>
<param-value>WEB-INF/classes/services.xml</param-value>
How I am deploying:
I am removing the application from the server by right clicking on server and "add or remove applications"
I am doing a run-as "maven-clean" and then run-as "maven-install" on the application and again adding the application by right clicking on the server and "add or remove applications"
Did you try classpath:/services.xml? The leading slash means to pull the resource from the root of the classpath. Without it, the file is expected to be in the package of whatever class is loading it (which I admit I don't know what that would be in this case).
See http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html#getResourceAsStream%28java.lang.String%29
Select project where the reource files exist.Right click - Build path - configure build path - sources -Add folder - add the folder where you resource file exist.This would add the folder to you class path.
If the above project/jar is part of another WAR/EAR then select that WAR and/or EAR - properties - j2ee module dependecies and select the above project to get added to build path.
Restart the server.
Figure out if its Websphere/RAD or a application issue?
First build the war file and drop it in a Tomcat container and check if you still see the error.
1. If you see then copy the services.xml to WEB-INF and WEB-INF/classes directory and see if it works.
2. Also check your CLASSPATH system environment variable, system CLASSPATH can override your application classpath.
If everything is fine with Tomcat, there is something specific to Websphere/RAD:
3. Check you websphere environment, I recall there is some option in websphere where you can set/override/prefix the classpath.

Where do maven goals go?

I'm using Maven 3.0.3. I want to write a simple task to copy a war file from my target directory to the Tomcat deploy directory. Where do I put my goal? I tried ...
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>socialmediaproxy</groupId>
<artifactId>socialmediaproxy</artifactId>
<packaging>war</packaging>
<version>0.1</version>
<goal name="copy-war" description="Copies the war file to the webapps directory">
<!-- This is Ant stuff -->
<copy file="${basedir}/target/${artifactId}-${version}.war" tofile="${warDestinationDir}"/>
</goal>
but when I run
mvn copy-war -P dev
I get this error ...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project socialmediaproxy:socialmediaproxy:0.1 (/Users/davea/Documents/workspace-sts-2.6.0.SR1/socialmediaproxy/pom.xml) has 1 error
[ERROR] Malformed POM /Users/davea/Documents/workspace-sts-2.6.0.SR1/socialmediaproxy/pom.xml: Unrecognised tag: 'goal' (position: START_TAG seen ...y-war" description="Copies the war file to the webapps directory">... #9:84) # /Users/davea/Documents/workspace-sts-2.6.0.SR1/socialmediaproxy/pom.xml, line 9, column 84 -> [Help 2]
Any ideas? - Dave
The goal part in the pom does not exist anymore, cause that's from Maven 1...but you defined a pom (model version 4.0.0) which is intended for Maven 3. Take a look into the current reference for the pom.
You can use ANT itself to copy the stuff from your target directory to the Tomcat Dir
Since you want to move the files from the target dir, run the ANTRUN plugin in the package phase.
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<phase>package</phase>
<configuration>
<target>
<copy file="${basedir}/target/${artifactId}-${version}.war" tofile="${warDestinationDir}"/>
</target>
</configuration>
<goals>
<goal>run</goal>
This will run the ANT task mentioned in <target> after executing the plase goal.

Resources