views:

346

answers:

4

So I have spent the past 11 hours now trying to get even the simplest Scala/Lift app to run on Tomcat through Eclipse. Apparently no one is trying to do this or it is the easiest thing in the world so no one has documented how they did it. Creating the code using a maven archetype and running it with mvn tomcat:run is no problem. Making it all work through Eclipse is another story. I will say this is my first attempt to do anything with Maven in Eclipse which has not helped any. I have tried both m2eclipse and eclipse-IAM. If anyone could walk me through the process from start to finish or point me to resources that can, that would be great. Thanks.


Version/Error Details

Scala 2.8 with Lift 2.1

If I use Scala 2.8 with Lift 2.1(?) with eclipse 3.5.2, scala-ide, and eclipse-iam, my pom.xml file tells me this:

Error: Error resolving version for 'org.scala-tools:maven-scala-plugin': Plugin requires Maven version 2.2.1

I created the project from the Maven Project Creation Wizard using this archetype definition:

<archetype>
    <groupId>net.liftweb</groupId>
    <artifactId>lift-archetype-blank_2.8.0</artifactId>
    <version>2.1-SNAPSHOT</version>
    <repository>http://scala-tools.org/repo-snapshots&lt;/repository&gt;
    <description>Shawn's Custom Thinger</description>
</archetype>

From what I understand, the problem here is the pom.xml file created from the 2.1-SNAPSHOT requires Maven 2.2.1, but eclipse-iam does not use that version yet. I have not managed to find a way to use the Maven v2.2.1 that I have installed myself. Supposedly eclipse-iam does not allow use of an external maven install.

Other Attempts

I have tried building projects with this archetype:

<archetype>
    <groupId>net.liftweb</groupId>
    <artifactId>lift-archetype-jpa-blank</artifactId>
    <version>1.1-SNAPSHOT</version>
    <repository>http://scala-tools.org/repo-snapshots&lt;/repository&gt;
    <description>Archetype - blank JPA project for Lift</description>
</archetype>

However, then I get runtime errors from Tomcat for a ClassNotFound error for my bootstrap.liftweb.Boot class. However, I can see that maven created a default Boot class for me.

m2eclipse

I got a project with no errors using m2eclipse, but I was having problems getting it deployed on Tomcat. I intend to revisit this one as I am curious if I did manage to get one project working, but had a case-sensitivity problem in the URL when I tried it. However, this process was much more manual. I would prefer an eclipse-iam solution if possible, but will take what I can get at this point.

A: 

You should be able to generate a native eclipse project through running mvn eclipse:eclipse. This worked relatively well the last time I tried it. Note that you will need the scala plugin for Eclipse.

Submonoid
I am able to create an Eclipse project, particularly easy eclipse-IAM, but I have not had much luck running the app after adding it to tomcat from eclipse.
Marshmellow1328
+2  A: 

Why would you like to run your webapp through Eclipse? Isn't easier to just run it on using Maven Tomcat plugin (mvn tomcat:run) with debug (JPDA) enabled? And then connect to it with Eclipse remote debugger?

IMHO the is the easiest, most flexible and generic way of running/debugging JVM applications built with Maven.

See also - http://stackoverflow.com/questions/3723743/3725566#3725566 .

Henryk Konsek
I like to put everything into a single tool rather than needing to jump out to commandline just to start my local web server. It's nice to simply click the start button on my web server in Eclipse. It also makes it easy to deploy multiple applications locally if they all interact with each other. There's a reason I don't still use vi to write code. GUI'd tools are convenient.
Marshmellow1328
Maven executed from command line == vim? Use Eclipse *and* hold open terminal during the development session. This is the best combination. Actually not everything can be easily done using the IDE. You don't have to be IDE or Console extremist. You can combine them to achieve the best efficiency. They are not mutually exclusive.
Henryk Konsek
A: 

Class not found sounds like the war (exploded or not) doesn't contain the scala jar, or possibly the lift jars.

Jim Barrows
+1  A: 

Maybe you can edit "test/scala/RunWebApp.scala" from jetty to tomcat. With my experience, after "mvn eclipse:eclipse" to generate project files. In Eclispe just run "test/scala/RunWebApp.scala" with "Debug As...", no JRebel or maven need anymore.

jamesqiu