I know there are already many questions on this subject but somehow I can't work out how to use maven 3.0.5 behind a proxy.
The settings.xml file inside my .m2/ folder looks like this
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>http-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxyname</host>
<port>8080</port>
<username>Domain\user</username>
<password>password</password>
<nonProxyHosts>127.0.0.1</nonProxyHosts>
</proxy>
</proxies>
</settings>
I also added wagon-http-lighteweight-2.2.jar to MAVEN_HOME/lib/ext.
I'm using maven inside eclipse, but it's showing the correct settings file in eclipse maven properties.
Despite having all these settings I still get the following error message after importing a spring boot project:
Project build error: Non-resolvable parent POM for <ProjectName>:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.4.1.RELEASE from/to central (https://repo.maven.apache.org/maven2): Failed to authenticate with proxy and 'parent.relativePath' points at no local POM
After running maven with the -X switch like Little Santi suggested I saw that the proxy is not the problem but the company I work in uses lokal maven repositories which I had to include.
I added these repositories and mirrors to my settings.xml and now it's working fine.
While running junit test in eclipse I am getting this Exception:
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
I've added junit.jar library file.
I've tried different versions of junit.jar: 4.4, 4.8, etc.
How do I fix this Exception?
Add hamcrest-all-X.X.jar to your classpath.
Latest version as of Feb 2015 is 1.3:
http://code.google.com/p/hamcrest/downloads/detail?name=hamcrest-all-1.3.jar&can=2&q=
According to the JUnit GitHub team website (https://github.com/junit-team/junit/wiki/Download-and-Install), junit.jar and hamcrest-core.jar are both needed in the classpath when using JUnit 4.11.
Here is the Maven dependency block for including junit and hamcrest.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.1.2</version>
<scope>test</scope>
</dependency>
<!-- Needed by junit -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
A few steps you have to follow:
Right click on the project.
Choose Build Path Then from its menu choose Add Libraries.
Choose JUnit then click Next.
Choose JUnit4 then Finish.
Works for me: IntelliJ IDEA 13.1.1, JUnit4, Java 6
I changed the file in project path: [PROJECT_NAME].iml
Replaced:
<library>
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.11.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
By:
<library name="JUnit4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.11.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-library-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
So the final .iml file is:
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.11.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-library-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
P.S.: save the file and don't let to IntelliJ Idea reload it. Just once.
You need junit-dep.jar because the junit.jar has a copy of old Hamcrest classes.
Just in case there's anyone here using netbeans and has the same problem, all you have to do is
Right click on TestLibraries
Click on Add Library
Select JUnit and click add library
Repeat the process but this time click on Hamcrest and the click add library
This should solve the problem
This problem is because of your classpath miss hamcrest-core-1.3.jar. To resolve this add hamcrest-core-1.3.jar as you add junit-4.XX.jar into your classpath.
At first, I encounter this problem too, but after I refer to the official site and add hamcrest-core-1.3.jar into classpath with command line, it works properly finally.
javac -d ../../../../bin/ -cp ~/libs/junit-4.12.jar:/home/limxtop/projects/algorithms/bin MaxHeapTest.java
java -cp ../../../../bin/:/home/limxtop/libs/junit-4.12.jar:/home/limxtop/libs/hamcrest-core-1.3.jar org.junit.runner.JUnitCore com.limxtop.heap.MaxHeapTest
You need to add the hamcrest-core JAR to the classpath as described here: https://github.com/junit-team/junit4/wiki/Download-and-Install
As a general rule, always make sure hamcrest is before any other testing libraries on the classpath, as many such libraries include hamcrest classes and may therefore conflict with the hamcrest version you're using. This will resolve most problems of the type you're describing.
the simplest way of solving the problem to begin with is copying latest version of hamcrest-code.jar into your CLASSPATH that is the file you store other .jar files needed for compilation and running of your application.
that could be e.g.: C:/ant/lib
It sounds like a classpath issue, so there are a few different ways to go about it. Where does org/hamcret/SelfDescribing come from? Is that your class or in a different jar?
Try going to your project Build Path and on the Libraries tab, add a Library. You should be able to choose JUnit to your project. This is a little bit different than just having the JUnit jar file In your project.
In your Run Configuration for the JUnit test, check the Classpath. You could probably fix this by adding making sure your Classpath can see that SelfDescribing class there. The Run option in Eclipse has a different set of options for the JUnit options.
If this problem arise in a RCP project it can be because JUnit has been explicitly imported.
Check the editor for your plugin.xml under Dependencies tab, remove the org.junit from the Imported Packages and add org.junit to the Required Plug-ins.
The problem is when you set up eclipse to point to JRE instead of JDK. JRE has junit4.jar in the lib/ext folder, but not hamcrest.jar :) So the solution is to check installed JREs in Eclipse, remove the existing one and create a new one pointing to your JDK.
This happens when you run Ant via command line. The implicit user dependencies are added in the classpath at the end and take precedence over the project-added classpath. Run Ant with -nouserlib flag. The implicit dependencies would be excluded from the classpath.
There is a better answer to solve this problem.
add dependency
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
The hamcrest-core-1.3.jar available on maven repository is deprecated.
Download working hamcrest-core-1.3.jar from official Junit4 github link .
If you want to download from maven repository, use latest hamcrest-XX.jar.
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
I had the same problem, the solution is to add in build path/plugin the jar org.hamcrest.core_1xx, you can find it in eclipse/plugins.
A few steps you have to follow:
Right click on the project.
Choose Build Path & then from its menu choose Add Libraries.
Choose JUnit then click Next.
Choose JUnit4 then Finish.
This works for me...
"java.lang.SecurityException: class" org.hamcrest.Matchers "'s signer information does not match signer information of other classes in the same package"
Do it:
Right-click on your package
click on Build Path -> Configure Build Path
Click on the Libraries tab
Remove JUnit
Apply and close
Ready.
Try adding the jar files manually or try with force update with the latest hamcrest.jar
The objective I have is to develop a bus with Mule, to run it into a JBoss.
My IDE is eclipse kepler, I have the Anypoint Studio plugin installed, a JBoss 7.1.1, a 3.5 CE runtime, Maven etc etc.
I took a look a this page : Deploy War into Mule Standalone server but I don't see haw it could help.
Context :
- Jboss is an imposed choice. I know it exists an EE version of the runtime, specially for the HA ability (that I need), but it's not an option for my client.
As it's "easier" to test my flows on the standalone (CE) runtime, I wanted to find a way to develop one Mule project to execute it on a CE runtime during the developing phase, and on a JBoss AS during the integration phase.
To do that, I tried to define :
- a jar maven project which contains all the flow
- a "mule" maven project, with the previous jar as the dependency
- a war maven project which athe previous jar and all the module/transport mule jars as dependencies
When I build the mule zip, my jar is included inside, but when it's executed none of ny flew is registered. So it doesn't work.
When I execute the war on JBoss, everything looks fine for the "first" flow (the input one), but I have a crash when the second one is called using a VM connector (other issue, I'll make another request)
Is there a way to do something working with this approach?
I tried to define 2 pom for the same mule project (one pom which generate a war, and a standalone-pom which generate the mule zip), but this is not very "easy to use" for my team, as the eclipse integration of this kind of project is not very friendly.
The last thing I can try is to keep the mule project pom with a mule packaging, and add a maven assembly to build the jar I could include in my war, but I'd prefer a nicer solution...
Thanks for all of your ideas!
Ah, the test flew I'm trying to integrate.
I have 3 flew :
- The first one stands for the HTTP request (to call my CE runtime)
- The second one stands for the Servlet request (to call my JBoss)
- The third one is called by both my CE runtime and my JBoss input flow, throw the VM connector. I'm thinking replace the VM connector by a Flow Call, as the VM inbound-endpoint is not registered when it's embedded into my war (but it works when executed in a CE runtime...)
main file :
<flow name="muleFlow1" doc:name="muleFlow1">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8081" doc:name="HTTP" />
<echo-component doc:name="Echo" />
<vm:outbound-endpoint path="receiver"
exchange-pattern="request-response" responseTimeout="10000" doc:name="VM" />
</flow>
<flow name="muleFlow2" doc:name="muleFlow2">
<servlet:inbound-endpoint path="servlet"
responseTimeout="10000" doc:name="Servlet" />
<echo-component doc:name="Echo" />
<vm:outbound-endpoint path="receiver"
exchange-pattern="request-response" responseTimeout="10000" doc:name="VM" />
</flow>
second file :
<flow name="otroFlow1" doc:name="otroFlow1">
<vm:inbound-endpoint path="receiver"
exchange-pattern="request-response" responseTimeout="10000" doc:name="VM" />
<set-payload value="it works" doc:name="Set Payload" />
<echo-component doc:name="Echo" />
</flow>
Thanks !
I didn't find anything else, so I opted for an assembly descriptor...
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>mule</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}/classes</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.xml</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>classes/**/*.class</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<useTransitiveDependencies>true</useTransitiveDependencies>
<excludes>
<exclude>org.mule:mule-core</exclude>
<exclude>commons-cli:commons-cli</exclude>
<exclude>log4j:log4j</exclude>
<exclude>org.mule.mvel:mule-mvel2</exclude>
<exclude>org.mule.common:mule-common</exclude>
<exclude>org.mule.modules:mule-module-client</exclude>
<exclude>org.mule.modules:mule-module-spring-config</exclude>
<exclude>org.mule.modules:mule-module-annotations</exclude>
<exclude>org.mule.modules:mule-module-xml</exclude>
<exclude>org.mule.modules:mule-module-cxf</exclude>
<exclude>org.mule.modules:mule-module-spring-security</exclude>
<exclude>org.mule.transports:mule-transport-http</exclude>
<exclude>org.mule.transports:mule-transport-ssl</exclude>
<exclude>org.mule.transports:mule-transport-tcp</exclude>
<exclude>commons-codec:commons-codec</exclude>
<exclude>org.mule.modules:mule-module-spring-extras</exclude>
<exclude>org.mule.modules:mule-module-builders</exclude>
<exclude>org.mule.modules:mule-module-management</exclude>
<exclude>org.mule.modules:mule-module-scripting</exclude>
<exclude>org.mule.modules:mule-module-sxc</exclude>
<exclude>org.mule.tests:mule-tests-functional</exclude>
<exclude>org.mule:mule-core</exclude>
<exclude>org.mule.transports:mule-transport-file</exclude>
<exclude>org.mule.transports:mule-transport-jdbc</exclude>
<exclude>org.mule.transports:mule-transport-jms</exclude>
<exclude>org.mule.transports:mule-transport-servlet</exclude>
<exclude>org.mule.transports:mule-transport-vm</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
My mule project is now a jar, which generate a jar file (for my webapp) and a zip file (for my runtime CE)
One important thing :
To realize the spring imports of each flow, we need to specify when mule is deployed in a web app, but the runtime expects to work. It can be done by creating a maven profile and enabling the resources filtering to determine when add "classpath:"...
I downloaded wicket examples 1.6.0 and built successfully in netbeans7.2. but got errors when I tried to deploy on tomcat 7:
Cannot deploy the module. The context.xml file seems to be broken. Check whether it is well-formed and valid.
The module has not been deployed.
See the server log for details.
at
org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at
org.netbeans.modules.maven.j2ee.ExecutionChecker.performDeploy(ExecutionChecker.java:178)
at
org.netbeans.modules.maven.j2ee.ExecutionChecker.executionResult(ExecutionChecker.java:130)
at
org.netbeans.modules.maven.execute.MavenCommandLineExecutor.run(MavenCommandLineExecutor.java:212)
at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
heres the contents in context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
<Loader delegate="true"/>
</Context>
I prefer to run wicket in eclipse as it negates the requirement to mess around with an external tomcat instance.
If you are comfortable with eclipse and maven i would download wicket 1.6 example archetype via maven, import into eclipse and then in the test directory you can run the run.java class to get an internal jetty server host wicket for you.
this should get you started quickly without having to wrestle with tomcat configurations too.
Not really an answer but an alternative route to the same end point
Add parameter path to context tag, same path that app will be served:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/application-path-name/">
<!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
<Loader delegate="true"/>
</Context>
Answer obtained from this question.
I've been given the task of migrating an existing project -- formerly built with Ant -- to use Apache Maven. I'm brand new to the entire concept, though I've spent the last several hours doing as much research as I can on the subject. Sadly, I'm having some proxy issues when it comes to installing things like m2e and Eclipse IAM, so everything must be done from the command prompt. As of right now, I do have maven installed properly; the trick now is to use it in my project rather than Ant. I've looked online and found a few tutorials, but they are all too vague for me considering my lack of experience with all of this. If anyone can break the steps down for me one-by-one in a detailed manner, that would be more than amazing. On a side note, I've been told to add the following to the local Maven Settings:
<settings>
<servers>
<server>
<id>local_tomcat</id>
<username>admin</username>
<password>tomcat</password>
</server>
<server>
<id>artifactory</id>
<username>user</username>
<password>password</password>
</server>
</servers>
<mirrors>
<mirror>
<id>artifactory</id>
<name>Artifactory</name>
<url>https://jenkins.web.jw.local/artifactory/repo1</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy.jw.local</host>
<port>80</port>
<username>user</username>
<password>password</password>
<nonProxyHosts>*.jw.local</nonProxyHosts>
</proxy>
</proxies>
</settings>
With the obvious username and password information filled in. I think I've managed that thus far by simply adding the necessary blocks into the settings.xml file under my ApacheMaven\conf directory. Other than that single step, I'm pretty much lost. Again, any help, especially that of a detailed tutorial in terms of command line instructions to build this project would be wonderful. Oh, and on another side-note, I am using Eclipse... Not sure if that would matter much.
EDIT: Considering Petr Kozelka's answer, I've attempted to make a pom.xml file for my project. Here's what I have so far...
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company</groupId>
<artifactId>appName</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>Application Name</name>
<description>Yadda Yadda</description>
<build>
<plugins>
</plugins>
</build>
<dependencies>
</dependencies>
<repositories>
</repositories>
</project>
Is this heading in the right direction? Also, do I need to construct the archetype.xml file myself, or will Maven do that through the command line somehow? If I need to do it myself, this is what I've come up with thus far:
<archetype xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0 http://maven.apache.org/xsd/archetype-1.0.0.xsd">
<id>lighthouse</id>
<sources>
<source>src/com/jeldwen/lighthouse/controller/AddTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/BugController.java</source>
<source>src/com/jeldwen/lighthouse/controller/DeleteTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/EnterTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/ModifyTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/PersonController.java</source>
<source>src/com/jeldwen/lighthouse/controller/ProjectController.java</source>
<source>src/com/jeldwen/lighthouse/controller/TimeController.java</source>
<source>src/com/jeldwen/lighthouse/model/Area.java</source>
<source>src/com/jeldwen/lighthouse/model/Bug.java</source>
<source>src/com/jeldwen/lighthouse/model/DBModel.java</source>
<source>src/com/jeldwen/lighthouse/model/DefaultModel.java</source>
<source>src/com/jeldwen/lighthouse/model/JWModel.java</source>
<source>src/com/jeldwen/lighthouse/model/JWTime.java</source>
<source>src/com/jeldwen/lighthouse/model/Person.java</source>
<source>src/com/jeldwen/lighthouse/model/Project.java</source>
<source>src/com/jeldwen/lighthouse/util/Lighthouse.java</source>
<source>src/com/jeldwen/lighthouse/util/LighthouseApplicationListener.java</source>
<source>src/com/jeldwen/lighthouse/util/LighthouseServlet.java</source>
<source>src/com/jeldwen/lighthouse/util/LighthouseSystemProperties.java</source>
<source>src/com/jeldwen/lighthouse/LighthouseApp.java</source>
</sources>
<testSources>
<!-- None -->
</testSources>
<allowPartial>true</allowPartial>
</archetype>
First of all: if you wish to customize settings.xml, do not touch the one in maven distro - instead, create a new file in $HOME/.m2/settings.xml where maven finds and uses it.
As the very first step, I recommend you to not use settings.xml at all.
Create a supersimple maven project, and try to compile it:
mvn clean install
Second step
Use very simple settings.xml:
you probably do not need proxy
servers part is needed only for publishing artifacts to a maven repository; that's not important at the beginning
here it is:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<mirrors>
<mirror>
<id>repos</id>
<mirrorOf>*</mirrorOf>
<name>internal mirror</name>
<url>https://jenkins.web.jw.local/artifactory/repo1</url>
</mirror>
</mirrors>
<!-- TODO: the proxy part here -->
</settings>
This assumes that you use inhouse maven repository, for instance Nexus or Artifactory.
Using maven repo makes only sense if your projects are not happy with deps available in the Maven Central Repository - otherwise, you can safely go without it. (let's neglect the performance effect of repoman for now)
Now, add some java sources, dependencies etc. - and watch how new depenencies get automatically downloaded to your local repository...
Third step
Learn how to add further repositories to your repository manager (group "public" on Nexus)...
The rest is probably subject of further research.