1

I have a subproject in a Virtual Machine with Ubuntu which I compile with Maven and then run with mvn jetty:run.

Maven also packages it as a war.

All of this works fine and does what is expected.

I am trying to import this WAR from another eclipse in Windows so I have done it by Import -> WAR, thus creating a Web application.

I now want to run it from Eclipse so I have created a new Jetty Server and run my application as Run on Server but I am getting Could not find the main class.

What is the proper way of doing this?

Besides, I have tried deploying the application by putting it in the webapps Tomcat directory . I can see it in the Tomcat GUI and launches the index.html but when I tried to access some of the services it throws No service was found

When deploying, in the Tomcat console I can see runtime NoClassDefFoundErrors.

Is there anything that mvn jetty:run does that the tomcat regular deployment does not? How is it possible that this didn't happen in my Virtual Machine? Shouldn't those classes be all in the WAR?

EDIT:

Here is another hint. When I run the project imported from the WAR in the Ubuntu VM, either with Jetty from eclipse or adding it to the webapps folder it works fine.

It is only hen running it on Windows Host Environment when it fails.

The specific NoClassdefFoundErrors thrown on cmd is the following:

Caused by: java.lang.NoClassDefFoundError: org/ow2/frascati/explorer/
api/FraSCAtiExplorer

That is one of the modules fo the main project.

eskalera
  • 1,072
  • 2
  • 21
  • 36
  • What classes are missing? Are they from libraries that are used within your application or classes of your application? – Kalpak Gadre Oct 11 '12 at 18:25
  • @Kal, they are classes imported in libraries from the main project. The point is the same WAR works in the VM. Any idea? – eskalera Oct 15 '12 at 11:22

2 Answers2

0

If you try to deploy your war in tomcat's webapps folder, and if you miss a class, then you probably miss a jar in your lib folder. It is probably a jar that is supposed to be provided by the web server.

We need to know which class is missing.

Samuel EUSTACHI
  • 3,116
  • 19
  • 24
  • @Samuel_EUSTACHI, it is a class from the main project. But this same WAR worked in the VM. Please see my las EDIT to see the specific class missing. – eskalera Oct 15 '12 at 11:23
  • Do you find the class in your war, in WEB-INF/classes ? – Samuel EUSTACHI Oct 15 '12 at 11:37
  • No, cause there's only one class there: Peer.composite. It is an SCA Application. But for that matter, it has the same as in the linux working WAR – eskalera Oct 15 '12 at 11:55
  • Ok, but then, it comes from somewhere, if not from classes, it comes from a jar, even if this is, logically speaking, the "main project" for you – Samuel EUSTACHI Oct 15 '12 at 12:00
  • It must be in one of the million jars it imports from that main project. I've now been able to run the war from cmd by copying again the WAR in webapps but still getting the "no main class" error in Eclipse. Do you know anything about this? – eskalera Oct 15 '12 at 12:17
  • You should not need a "main class" in eclipse, if you run the project in an embedded web server (tomcat, or jetty). This error probably means that you try to run it as a jar, not a war – Samuel EUSTACHI Oct 15 '12 at 12:20
  • but that is not the case. Is is a WAR for sure. Could it have anything to do with the CLASSPATH? http://stackoverflow.com/questions/6334148/exception-in-thread-main-java-lang-noclassdeffounderror – eskalera Oct 15 '12 at 12:34
0

Finally all errors have been solved by doing the following:

First I recompiled the WAR which did work this time under Jetty in Windows cmd. I apologize as this must be due to some error I still don't know, probably sharing the wrong WAR with Windows HOST OS from the beginning.

On the other hand, the Eclipse was solved by moving the Jetty folder out of the "Program Files" directory. It seems the old Jetty 6 adapter Eclipse comes with does not recognize spaces in its route to the server.

eskalera
  • 1,072
  • 2
  • 21
  • 36