Import and run WAR on eclipse - eclipse

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.

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.

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.

Related

CDI imports cannot be resolved in Eclipse

i have written an application on my pc using CDI as the backing bean for jsf, the application works completely fine.
Now i setup everything on a new pc, installed glassfish 4.1, setup eclipse kepler by putting the installed jre as jdk7 from the glassfish folder.
when i make a war for the application on my pc and deploy it onto the glassfish server on the other pc everything works fine.
now i tried taking the project from my pc and imported it onto the new pc. the eclipse on the new pc wont recognize import javax.enterprise.context.SessionScoped; giving compiler error that this annotation is not available.
The import javax.enterprise.context cannot be resolved
it doesnt recognize javax.enterprise.context.* at all. like CDI is not available. i am using JDK 7 which contains JSR 346, so i am completely confused what the issue could be.
if i deploy the application directly through the glassfish admin console using the war file it works perfectly fine but if i try to publish it through eclipse, it gives me unresolved compilation errors
Eclipse did not import ALL glassfish jars, so you need to:
Right Click on the project name, Build Path, Configure build path, under Libraries Click Add External Jars, go to where you have extracted Glassfish and import all jars that exists in:
glassfish4\glassfish\modules
and all sub directories two, like endoresed.
This will fix the problem for CDI and other stuff lik JAX-RS
If I had to guess, your .project and .classpath files are pointing to JAR locations that are specific to your old computer.
This is why people like build tools such as maven, or gradle, you can pick up and reimport a project; it'll resolve all dependencies for you.
Do you happen to use the GlassFish Tools plugin for Eclipse? I found that the GlassFish System Libraries classpath container, which is created implicitly by that plugin and which is added to all projects that specify a GlassFish server as their runtime, misses cdi-api.jar. This is where the javax.enterprise.context.* package is located (and many others).
So I could fix this by adding cdi-api.jar as an External Jar to the build path. After that, you may get a warning like Classpath entry [...]/cdi-api.jar will not be exported or published. Runtime ClassNotFoundExceptions may result., which can be eliminated by using the Quick Fix to Exclude the associated raw classpath entry from the set of potential publish/export dependencies. That JAR file is already contained in the modules folder of GlassFish, obviously.
Maybe this problem only occurs with the GlassFish Web Profile, at least that's what I use.

Deploy helloworld to wildfly using eclipse

I want to deploy my helloworld project to my wildfly (former jboss) application server.
I can use maven mvn install wildfly:deploy and it will deploy the app.
But when I want to use eclipse to run on Server it does nothing.
I don't get a console output or anything which looks like building and deploying.
I added the server runtime to the project and also added the wildfly server.
Why is Eclipse not deploying?
This works for me: do a mvn install in order to build the war and have it at the target folder. Then right-click on wildfly-server. You will see an add-remove option. Click on it, select your project from the list and then add your project to the server. Click finish. If the server is running the project should be deployed.
Another approach would be to simply copy the war from your target directory and place it in the standalone/deployments folder of your wildfly installation.
Make sure that you have stopped the server before copying the war. After you have copied the war to the deployments folder, start he server.
Your application should be deployed successfully.

Netbeans Maven project to IDEA 12

Short version: I would like to deploy Maven generated WAR to Local Tomcat server and not to build the war with internal IDEA process since the produced WAR file is not the same as the Maven generated one.
Long version: I have been using the Netbeans IDE for my Maven Java project. One of the modules is packaged as a WAR and should be deployed to tomcat server.
In Netbeans when I selected "Run" on the Web Module it asks for application server configuration then it runs the maven 'package' goal and deploys the application(generated WAR) to the Tomcat Server probably via Tomcat manager. So far so good.
We are now in the process of switching to Scala language. Scala classes extend old Java classes and the project is now "Mixed". I have configured Maven to compile the project as a mix of scala and java code. Maven produces a WAR which can then be deployed to Tomcat server without trouble - everything works as it should.
Now I would like to switch to Intellij-idea 12 IDE. But I have a problem: IDEA is refusing to deploy Maven created artifacts and insists of building one by it's own. The war is not the same and can't be used. Is there a way to tell IDEA to use Maven generated WARs and not try to make it's own ?
Just for the record I have already read these articles:
http://riddhimandas.com/blog/111
http://www.jetbrains.com/idea/webhelp/configuring-web-application-deployment.html Manually build WAR by IDEA - Want the maven generated one
IntelliJ IDEA: Maven, project compilation and deployment There is a hint here that IDEA can deploy Maven artifact from the 'target' directory but there is no information on how to do that.
With the help of CrazyCoder I figured it out.
You can make Intellij-Idea to upload your war by selecting External Source
But that's not all, even if you have a context.xml file difining your Context Root inside your WAR file: http://docs.oracle.com/javaee/1.4/tutorial/doc/WebApp3.html
You must specify one for every artifact you deploying (Unless someone will correct me)
The before launch section can be used to tell Idea what to Maven Goal to Run if any

How to deploy a web application on Jetty

I create a war file , then i executed in eclipse, like described here.
I don't know configure the context path, how can I run the war file?
There are two ways you can run your webapp using Jetty Server
Configure jetty server using Jetty_WTP_Plugin and run webapp within eclipse
Download stand alone jetty server from Jetty Distributions from Eclipse
If you use second option, you need to create war file keep war file interface /webapps folder.
I haven't used jetty but I know that its quite similar to tomcat. Just place your war file (say foo.war) in webapps directory; Start jetty by the following command in
java -jar start.jar
and hit http://localhost:8080/foo in your browser
By the way the tutorial you're using is quite an old one and may not work for jetty 8 or 9

Deploying GWT app to tomcat in eclipse

I want to use tomcat server in development mode with GWT. When I use embedded Jetty it deploys application to the current directory(where my war folder is located). So it generates all the files there. How can I configure eclipse to use tomcat server and all the deployment stuff to be copied to tomcat webapps directory. I have tried to use -noserver option in Run conigurations, but it doesn't copy any resource from war directory to server deployment directory.
Can I use tomcat server in such manner?
P.S. i want to solve this problem withou ant or maven
Using my own server in development mode instead of GWT's built-in Jetty instance
You will need to copy the contents of the WAR folder over, but only once.
Have you looked at Eclipse WTP? It allows deploying to a server right from within Eclipse.
For a GWT project, you'd then, in addition, follow that recipe: http://code.google.com/eclipse/docs/faq.html#gwt_in_eclipse_for_java_ee