Archive

Archive for February, 2013

Eclipse Error: “Enabling Maven Dependency Management” has encountered a problem

February 17, 2013 7 comments

The following error apears if one imports a project which was created with Maven (mvn eclipse:eclipse) and tries the “Configure” -> “Convert to Maven Project” function:
An internal error occurred during: “Enabling Maven Dependency Management”. Unsupported IClasspathEntry kind=4

To fix this error open the project with Eclipse, run the “mvn eclipse:clean” command and try the “Configure” -> “Convert to Maven Project” function again.

Advertisements
Categories: Build-Management, Eclipse

Create A Java Project With Maven

To create a Java Project from Maven Template open a terminal (*uix or Mac) or command prompt (Windows), navigate to the folder you want to store the project and call the following commands:

mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Example:

mvn archetype:generate -DgroupId=com.mycompany -DartifactId=MyMavenProject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

To convert the Maven project to support Eclipse IDE, navigate to the project in terminal and call this command:

mvn eclipse:eclipse

The default JDK version is 1.4. If you want to update the POM, open the pom.xml file and add the compiler plugin to tell Maven which JDK version to compile your project:

...
<build>
<plugins>
...
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<version>3.0</version>
	<configuration>
		<source>1.6</source>
		<target>1.6</target>
	</configuration>
</plugin>
</plugins>
</build>
</project>

You can also update the JUnit version to latest 4.11:

...
<dependencies>
<dependency>
	<groupId>junit</groupId>
	<artifactId>junit</artifactId>
	<version>4.11</version>
	<scope>test</scope>
</dependency>
<build>
...

The Packaging with Maven can be done with the following command:

mvn package

It compiles, runs your tests and generates the project “jar” file in project/target folder.

To run the application call this command:

java -cp target/{project-name}-1.0-SNAPSHOT.jar {project-packaging}.{main-class}

Example:

java -cp target/MyMavenProject-1.0-SNAPSHOT.jar com.mycompany.App

With the jar plugin you can add a Manifest file to the jar.

...
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-jar-plugin</artifactId>
	<version>2.4</version>
	<configuration>
		<archive>
			<manifest>
				<addClasspath>true</addClasspath>
				<classpathPrefix>lib/</classpathPrefix>
				<mainClass>com.mycompany.App</mainClass>
			</manifest>
		</archive>
	</configuration>
</plugin>
...
java -jar target/MyMavenProject-1.0-SNAPSHOT.jar

Adding Remote Message Broker using .broker file

  • Stop the Message Broker Toolkit
  • Add the configuration file (.broker file) in Message Broker Toolkit workspace:
    <YOUR_WORKSPACE>\.metadata\.plugins\com.ibm.etools.mft.broker.runtime\
  • Start the Message Broker Toolkit again

The user environment was not adequately prepared to continue execution.

If you try to run a command like ‘mqsireportproperties'and got the error below you need to run mqsiprofile BEFORE you run your command.

The user environment was not adequately prepared to continue execution. Locate and run the profile supplied with the product. This file is called mqsiprofile, and is located in the bin subdirectory for the product.

SET "BROKER_HOME=C:\Program Files\IBM\MBroker\7.0"
SET "path=%path%;%BROKER_HOME%\bin"
mqsiprofile
mqsireportproperties MB7BROKER -e EXECUTIONGROUP-o HTTPConnector -r