Discussion:
How to create a basic camel project with mvn for eclipse (for dummies)?
pmp.martins
2013-11-01 12:37:57 UTC
Permalink
Hello all, as you can see I am quite a beginner using Camel. I am trying to
create a very basic Eclipse project using Camel and Maven but somehow I
always end up with errors and it simply doesn't seem to work.

- I have tried copying folders from other projects and change the name but
then maven doesn't like it and it doesn't let me run anything.
- I decided to start a new project from scratch with maven using:

mvn archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=com.mycompany.app \
-DartifactId=my-app

- Then tried creating a pom.xml myself, I even added the camel-core and the
slf4j dependencies manually (check out my 40 lines of pom.xml at HERE
<http://pastebin.kde.org/p9pccinyf> ), but I still cannot run it in eclipse
and maven is not behaving any better. t

- Before attempting to run this example in eclipse I used the command "mvn
eclipse:eclipse". But in Eclipse IDE I get the following error:

log4j:WARN No appenders could be found for logger
(org.apache.camel.impl.DefaultCamelContext).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.

The code I am trying to run is fairly simple as well, it is from an example
I found in a book. You can check the very simple code sample HERE
<http://pastebin.kde.org/pybxkdebe> .

I am completely lost, nothing I do seems to be able to work, and I still
need to learn how to use Camel LoadBalancer using the failover construct.
Can any one help me and tell me how to create a basic Camel project for
dummies?

Thanks, Pedro.
John Dubchak
2013-11-01 13:56:55 UTC
Permalink
Hi Pedro,

Assuming you're using maven3, you can use the interactive create
archetype process:

$ mvn archetype:generate -Dfilter=org.apache.camel.archetype:

This will allow you to pick the type of camel project you want to
create, the version of camel you're using and set the group, artifact,
and version for your project. After that you can change into the
directory of your new project and run either:

$ mvn eclipse:eclipse

if you're using Eclipse as an IDE, or:

$ mvn idea:idea

if you're using IntelliJ. If you're using something else, then these
commands won't be particularly helpful.

This should be a pretty decent start to get a compilable/working camel
project. I would also avoid copying folders from one maven project to
another unless you're absolutely sure they are not involved in any of
maven's phases because your pom file likely isn't set up to handle them.

Also, Claus has written an excellent book, "Camel in Action", which is
very easy to read and follow especially once you understand how to
generate projects from the above archetype and deploy them to whatever
container you're going to run them in. I can't recommend his book
enough - it'll get you past being a beginner and make you much more
competent with Camel.

I hope this helps.

John
Post by pmp.martins
Hello all, as you can see I am quite a beginner using Camel. I am trying to
create a very basic Eclipse project using Camel and Maven but somehow I
always end up with errors and it simply doesn't seem to work.
- I have tried copying folders from other projects and change the name but
then maven doesn't like it and it doesn't let me run anything.
mvn archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=com.mycompany.app \
-DartifactId=my-app
- Then tried creating a pom.xml myself, I even added the camel-core and the
slf4j dependencies manually (check out my 40 lines of pom.xml at HERE
<http://pastebin.kde.org/p9pccinyf> ), but I still cannot run it in eclipse
and maven is not behaving any better. t
- Before attempting to run this example in eclipse I used the command "mvn
log4j:WARN No appenders could be found for logger
(org.apache.camel.impl.DefaultCamelContext).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.
The code I am trying to run is fairly simple as well, it is from an example
I found in a book. You can check the very simple code sample HERE
<http://pastebin.kde.org/pybxkdebe> .
I am completely lost, nothing I do seems to be able to work, and I still
need to learn how to use Camel LoadBalancer using the failover construct.
Can any one help me and tell me how to create a basic Camel project for
dummies?
Thanks, Pedro.
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-create-a-basic-camel-project-with-mvn-for-eclipse-for-dummies-tp5742489.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Babak Vahdat
2013-11-01 14:02:24 UTC
Permalink
Hi

Welcome to the Camel community.

Actually there's nothing you should do manually, e.g. creating a pom.xml by
yourself. Take a look at the documentation to see how to make use of the
Camel archetypes:

http://camel.apache.org/camel-maven-archetypes.html

Googling a bit you would also find bunch of concrete examples, blogs and
videos on the Web about using Camel archetypes.

Babak
Post by pmp.martins
Hello all, as you can see I am quite a beginner using Camel. I am trying
to create a very basic Eclipse project using Camel and Maven but somehow I
always end up with errors and it simply doesn't seem to work.
- I have tried copying folders from other projects and change the name
but then maven doesn't like it and it doesn't let me run anything.
mvn archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=com.mycompany.app \
-DartifactId=my-app
- Then tried creating a pom.xml myself, I even added the camel-core and
the slf4j dependencies manually (check out my 40 lines of pom.xml at
HERE <http://pastebin.kde.org/p9pccinyf>
), but I still cannot run it in eclipse and maven is not behaving any
better. t
- Before attempting to run this example in eclipse I used the command
log4j:WARN No appenders could be found for logger
(org.apache.camel.impl.DefaultCamelContext).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.
The code I am trying to run is fairly simple as well, it is from an
example I found in a book. You can check the very simple code sample
HERE <http://pastebin.kde.org/pybxkdebe>
.
I am completely lost, nothing I do seems to be able to work, and I still
need to learn how to use Camel LoadBalancer using the failover construct.
Can any one help me and tell me how to create a basic Camel project for
dummies?
Thanks, Pedro.
pmp.martins
2013-11-01 14:05:55 UTC
Permalink
I am reading the Camel in Action book, however it doesn't teach me how to
create projects. The code is all done for me and all I have to do is to run
it. I have never used Camel not Maven before, so I have no idea on how to
use such tools.

As for archtypes, I have no idea what that is. Do you recommend any specific
tutorial? I will try to make a small search on Google for them. The achtype
previously suggested used Spring and ActiveMQ, both tools I would like to
avoid for now.
John Dubchak
2013-11-01 14:13:38 UTC
Permalink
Pedro,

To simplify it, initially think of maven as a black box - the
interactive archetype will help you create the projects you need without
having to learn the details of maven. This will give you the
opportunity to focus on Camel.

You may also want to consider picking up a copy of "Enterprise
Integration Patterns", by Hohpe and Woolf, but it's a more advanced
book. However, it contains a couple of initial chapters that may help
with the background information you need in order to understand the
types of problems that Camel was designed to solve and where it might
fit into the larger picture of an integration architecture.

John
Post by pmp.martins
I am reading the Camel in Action book, however it doesn't teach me how to
create projects. The code is all done for me and all I have to do is to run
it. I have never used Camel not Maven before, so I have no idea on how to
use such tools.
As for archtypes, I have no idea what that is. Do you recommend any specific
tutorial? I will try to make a small search on Google for them. The achtype
previously suggested used Spring and ActiveMQ, both tools I would like to
avoid for now.
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-create-a-basic-camel-project-with-mvn-for-eclipse-for-dummies-tp5742489p5742499.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Claus Ibsen
2013-11-01 14:26:59 UTC
Permalink
Welcome to the community.

Just a comment on the CiA book. Yeah somehow the chapter about how to
create new projects landed as chapter 11. Though we did give a little
hint in the preface that readers should check out this chapter earlier
if they are not familiar with Maven etc.

So a Maven archetype is similar to a recipe for creating pre-setup
Java projects. So there is maven archetypes for many different
libraries out there.

The Apache Camel project has a number of archetypes listed here
http://camel.apache.org/camel-maven-archetypes.html

Maven archetypes can be used from both the command line, or from
within your IDE such as Eclipse, IDEA etc. In fact its easier today
than it was when the book was being written, as for Eclipse you needed
back then to install a special m2eclipse plugin. Today that plugin is
out of the box.

So all you need to do is fire up Eclipse, and choose file -> new
project ... -> maven project -> and use the wizard to choose an
archetype. In the filter box type "Camel" to filter only the Camel
ones.

And for example choose

camel-archetype-java to create a simple Java only project with a
Camel route in Java DSL.

And there is camel-archetype-spring for a Spring based project with a
Camel XML route.


If you use Maven from the command line, then I suggest to use
mvn archetype:generate

Then it runs in interactive mode, alike the wizard in Eclipse. That is
also easier to do than typing a very long command.


And also today you dont need to type mvn eclipse:eclipse. You can just
from Eclipse

File -> Import Existing Project ... -> Maven Project --> and load the
pom.xml of the project.


So you dont need to touch and use Maven from a command line. Its all
out of the box in the Eclipse / IDEA editors today.


Good luck and hopefully have a bit fun riding the Camel.






On Fri, Nov 1, 2013 at 3:05 PM, pmp.martins
Post by pmp.martins
I am reading the Camel in Action book, however it doesn't teach me how to
create projects. The code is all done for me and all I have to do is to run
it. I have never used Camel not Maven before, so I have no idea on how to
use such tools.
As for archtypes, I have no idea what that is. Do you recommend any specific
tutorial? I will try to make a small search on Google for them. The achtype
previously suggested used Spring and ActiveMQ, both tools I would like to
avoid for now.
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-create-a-basic-camel-project-with-mvn-for-eclipse-for-dummies-tp5742489p5742499.html
Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen-H+wXaHxf7aLQT0dZR+***@public.gmane.org
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
pmp.martins
2013-11-01 15:48:53 UTC
Permalink
Hey, thanks for all the help guys!
I am now reading chapter 11 of the book but I am having some problems using
the m2e eclipse plugin. The problem is that when I try to create a maven
project, the camel archetypes don't appear.

I decided to take 4 screenshots to save your time and and so you can
understand the problem:

<Loading Image...>

<Loading Image...>

<Loading Image...>

<Loading Image...>

At first I assumed that the problem was mine, and that I was typing
something wrong in the filter. But after searching for all the archetypes
available, I still could not find anything related to camel.

I will now try the Maven plugin + Eclipse approach, but I wonder why this
approach is not working.

And thanks for the help guys, you're all being great.
Claus Ibsen
2013-11-01 15:57:38 UTC
Permalink
Hi

It may take a while for Eclipse to index the maven archetypes I think.
You can also try on that filter wizard page, to change the catalog.

And btw what version of Eclipse do you use? The later release have the
m2e plugin out of the box, so you didnt have to install it.



On Fri, Nov 1, 2013 at 4:48 PM, pmp.martins
Post by pmp.martins
Hey, thanks for all the help guys!
I am now reading chapter 11 of the book but I am having some problems using
the m2e eclipse plugin. The problem is that when I try to create a maven
project, the camel archetypes don't appear.
I decided to take 4 screenshots to save your time and and so you can
<http://camel.465427.n5.nabble.com/file/n5742510/1.m2e_Plugin.png>
<http://camel.465427.n5.nabble.com/file/n5742510/2.maven_wizard.png>
<http://camel.465427.n5.nabble.com/file/n5742510/3.maven_project.png>
<http://camel.465427.n5.nabble.com/file/n5742510/4.filter.png>
At first I assumed that the problem was mine, and that I was typing
something wrong in the filter. But after searching for all the archetypes
available, I still could not find anything related to camel.
I will now try the Maven plugin + Eclipse approach, but I wonder why this
approach is not working.
And thanks for the help guys, you're all being great.
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-create-a-basic-camel-project-with-mvn-for-eclipse-for-dummies-tp5742489p5742510.html
Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen-H+wXaHxf7aLQT0dZR+***@public.gmane.org
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
pmp.martins
2013-11-01 16:21:10 UTC
Permalink
Well, as stated in my previous images, I am using eclipse Kepler, which I
think it is the latest version if I remember correctly.
This is not a loading time problem, eclipse loads all the available
archetypes almost instantly. I have no idea why eclipse is simply being
stubborn :S
pmp.martins
2013-11-01 16:53:11 UTC
Permalink
Alright, now I am getting desperate. After trying (and failing) with Eclipse
I decided to be a good boy and follow the Maven section in the Camel in
Action book.

So, I created a new project with Maven using:

mvn archetype:create \
-DarchetypeGroupId=org.apache.camel.archetypes \
-DarchetypeArtifactId=camel-archetype-java \
-DarchetypeVersion=2.5.0 \
-DgroupId=camelinaction \
-DartifactId=order-router

Then I entered the created folder and used the commands "mvn clean compile"
and "mvn clean install". I then tried to run the code by using "mvn
camel:run" and THIS <http://pastebin.kde.org/pkynsaph8> is what I got.
Java errors. I don't get this. According to the book the example should be
running just fine, but instead I get a page full of errors.

Have I done something wrong? :S
Claus Ibsen
2013-11-01 17:03:05 UTC
Permalink
It may affect what JDK version you use. Camel 2.5.0 doesn't support Java 7.

So I suggest to use the latest Camel release instead. It support Java 6 and 7.

-DarchetypeVersion=2.12.1 \

On Fri, Nov 1, 2013 at 5:53 PM, pmp.martins
Post by pmp.martins
Alright, now I am getting desperate. After trying (and failing) with Eclipse
I decided to be a good boy and follow the Maven section in the Camel in
Action book.
mvn archetype:create \
-DarchetypeGroupId=org.apache.camel.archetypes \
-DarchetypeArtifactId=camel-archetype-java \
-DarchetypeVersion=2.5.0 \
-DgroupId=camelinaction \
-DartifactId=order-router
Then I entered the created folder and used the commands "mvn clean compile"
and "mvn clean install". I then tried to run the code by using "mvn
camel:run" and THIS <http://pastebin.kde.org/pkynsaph8> is what I got.
Java errors. I don't get this. According to the book the example should be
running just fine, but instead I get a page full of errors.
Have I done something wrong? :S
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-create-a-basic-camel-project-with-mvn-for-eclipse-for-dummies-tp5742489p5742517.html
Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen-H+wXaHxf7aLQT0dZR+***@public.gmane.org
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
pmp.martins
2013-11-01 17:22:29 UTC
Permalink
It still doesn't work. Now when I use the command:
mvn archetype:create -DarchetypeGroupId=org.apache.camel.archetypes
-DarchetypeArtifactId=camel-archetype-java -DarchetypeVersion=2.12.1
-DgroupId=camelinaction -DartifactId=order-router

I get the following ERRORS <http://pastebin.kde.org/pqwthmq9q> .
I also used the "-e" option so you or anyone who actually understand what is
going on can see the stacktrace. Hope it helps :s
pmp.martins
2013-11-01 22:11:20 UTC
Permalink
Well, I want to thank everyone for their hard work in helping me. I am
posting here because I found a solution to the problem of creating a Camel
project using Maven.

I have to admit, I pretty much lost an entire day around something that
should have taken only a few minutes to achieve. Even then, the problem of
creating a Camel project with eclipse is yet to be solved.

Still, HERE
<http://stackoverflow.com/questions/19734476/how-to-create-a-camel-project-using-maven/19735141?noredirect=1>
is the solution that I used.

After running the suggested command, I then did the usual "mvn clean
compile" and "mvn clean install". After that I did "mvn eclipse:eclipse",
imported the project to eclipse and voilá, it was running.

If any of you good souls is still interested, I also took the liberty of
creating a question in stackoverflow to ask why Eclipse is not able to see
camel archetypes - HERE
<http://stackoverflow.com/questions/19735767/create-camel-project-with-eclipse/19735899?noredirect=1>
.

Thanks for everything, I will surely be bugging you very soon :D
Pedro Martins

Loading...