Convert Maven Desktop App to Dynamic App in Eclipse - java

I have a Maven based desktop App and I have to convert it to a dynamic web app in eclipse or any other IDE ( I am using Eclipse Neon-Java EE).
I have tried with Project Facets (Right click on project name --> Properties --> Project Facets --> dynamic web app) It generates some files but it doesn't seem to be converted to web as in the project folder still appears the letter "M" and not the golobe icon. When I try to run it in Tomcat it doesn't work.
Project Folder
Any suggestion?
Thank you

Look into the project if you have the Maven convert option...
If not, you should check the property of the project, and change them manually, starting from the Deployment Assembly, the target runtime, check all the facets..
Then take a look into the folder of the project, into .classpath and .project and see if they have been refreshed by Eclipse, the pom should package as a war and so on...
The problem here is that you are fighting with Maven and Eclipse togheter, so my main suggestion to do this in lees time, is to create a new Dynamic project and then to copy and paste all the previous Desktop project.. you can do this in a lot of ways...
Or directly from the IDE, or simply by hand than importing again the project...
Let me know if you try one of the above suggestions :)
Moreover obviously after all of this it won't start in tomcat, you have before to configure your web.xml and so on... but at least your structure will follow the Dynamic Web Project structure standards..

Related

What is the proper java app directory structure with Tomcat?

I started to learn JSP and Tomcat Container, and I know how the directories must be stored, but I'm confused by several things:
If we use only web app, why do we need the rest of the folders here? (highlighted blue). Can I just delete them and load my project with "web" as root?
How can I initialize Gradle/Maven or use any other framework inside Tomcat web application? (e.g Where to put pom.xml file?)
The folder .idea and the file Tomcat-web-app.iml are necessary for your IDE, configuration is stored there. If you delete them the project will fall apart in your IDE. You can delete the src folder as long as you're not using it.
pom.xml should be put on the root level of your project, so right under Tomcat-web-app/. Afterwards you can initialize it as a Maven project by adding framework support for Maven - right click on your project (Tomcat-web-app) and you should see it there. Refer to this guide if you're having issues. It is much more straight forward however to just create a Maven project from scratch and then copy in your web files.

Eclipse Web-App Deployment with Tomcat: Providing multiple projects' dependencies?

I have a problem providing some third party librarys (JAR-files) I am using when deploying my dynamic web application with Tomcat 6 and Eclipse.
Please note that I -do know- how to do this in a setup, where the web application project -directly- depends on those JARs.
However, in my setup, I have two Eclipse projects:
core is a class library and depends on, lets say, a.jar.
web is the web application and depends on core.
In the project settings of web, in the Deployment Assembly category, I have added core, so Eclipse (or Tomcat - I'm not quite sure who the responsible actor here is) is putting core.jar into the libs directory of my web application.
The problem is: When I try out the web application, a NoClassDefFoundError is thrown when core accesses classes from a.jar. What am I supposed to do about this? I don't think that putting a.jar into the Deployment Assembly settings page of my web application is the right solution, since it should be of no relevance to the web project, what the core project depends on.
Basically, I am looking for a way to configure Eclipse (Tomcat?) to 'embed' the dependencies of core into core.jar. The problem about this is, that core.jar is generated automatically, when I deploy my web project.
Help is very appreciated.
Thanks in advance!
Well, I've found the answer on my own meanwhile.
For those reading this in the future I will explain step by step, using the semantics I introduced in my original message:
First, open the properties page of your core project and navigate to the 'Libraries' tab of the 'Java Build Path' settings:
Make sure to add your class library a.jar, your core project depends on, via 'Add JARs...'. Then, go ahead to the 'Order and Export' tab and activate the just added a.jar for exporting.
Then go to the 'Deployment Assembly' settings and also add a.jar here by first clicking on 'Add...', then on 'Java Build Path Entries' and finally selecting a.jar. Make sure to enter '../' as the deploy path for a.jar:
Now you are done with your core project. Now open the 'Projects' page of the 'Java Build Path' settings for your web project and add your core project by clicking on 'Add...':
Finally, navigate to the 'Deployment Assembly' settings page, press 'Add...', then take 'Project' and select your core project on the next screen:
You're done. No need to add your core dependencies to your web project.
As far as I know eclipse doesn't do it for you. Project dependencies are for compile time. Runtime dependencies that span across projects should be handled by you. One trick you can use to create user libraries. Go to preferences -> Java -> Build Path -> User libraries. Create a new user library. Add all the jars that your 'core' project depends on. Add it as a dependency to both 'core' and 'web' projects. To do that,, right click on project -> Build Path -> Configure build path -> Libraries tab -> Add Library...
Hope this helps
I suggest using Maven which will automatically compiles the jar files for you and Eclipse works with Maven very well too.
If you have a Gradle-Project make sure, you have the "eclipse-wtp" Plugin in your build.gradle's of the Sub-Projects.

Why can't I step through library code when debugging a web project in Netbeans?

I have a Spring MVC web application where the majority of the code I am interested in sits in two Maven projects - one being the war project and another being a jar project on which the war depends. They also share the same parent pom though that is probably irrelevant for this question.
When I try to debug my web project I can't step into any of the code from the jar. I've checked Windows->Debugging->Sources and the jar project's source directory is present there. Both projects are open. Does Netbeans 7.0 not support stepping through a web project's dependencies?
In your library manager screen, in your sources tab, have you provided the location of the source folder.http://wiki.netbeans.org/AttachSourceToLibrary.
When you are stepping in to class files ( that netbeans could not find source far), there usually is a prompt from Netbeans asking if you want to associate a src with this corresponding file. Either way, I have managed to step into dependent projects using Netbeans.

"Module name is invalid" when exporting an existing eclipse project to a war file

I am trying to export an existing Eclipse project to a war file. But whatever I typed in the "WAR Export" dialog page, the system always returned "Module name is invalid". I do not know how to fix this issue. Thanks for the help.
I had the same issue, and I fixed it. Please follow the steps below, and you can create your war file.
Right-click on folder project.
Click on properties.
Go to project facets.
Activate, if necessary.
Scroll down to Configuration and mark Dynamic Web Module.
This works for me.
you must be sure your project is a Web Project, if it's not a Web Project check this link: http://eclipse.dzone.com/tips/converting-java-project-dynami
In Eclipse STS
Right-click on folder project.
Click on properties.
Go to project facets.
Choose your Java 1.8
Scroll down to Configuration and mark Dynamic Web Module.
After that, it works fine.
In my case error went off when the war file name matched the project name of the eclipse. Its easy to choose one from the drop down box.
If your project is a Maven project. In Export Wizard, Module name combo box will be empty and any inputs will be invalid.
Solution: If you build the project using Maven. - In project / package view Open context menu on the project > Run > Maven Build
The WAR file will be packaged in target directory.
Note: PUM file of the project should be configured for packaging WAR file.
Right-click on folder project.
Click on properties.
Go to project facets.
Choose your Java 1.8
Scroll down to Configuration and mark Dynamic Web Module.
When I follow this step getting me the error (Dynamic Web Module 3.0 java 1.6 or newer)
I'm currently using Java 11
I am not sure about the exact cause. But this gets resolved most of the times if you give the exporting project war file name just same as the project name in the IDE
When I converted my java project onto dynamic web project using eclipse for EE developers, I encountered this.
Then I made a whole new dynamic web project and copied all my source files to it, and I was able to export a war file easily.

Multiple WebContent directories in a single eclipse dymanic web project

I have an existing project that I'm trying to convert correctly into an Eclipse Dynamic Web Project. I've mostly got it working, however there is on issue that I'm not sure how to fix.
The project has something like 2 modules that share the same Java classes, but need to be deployed as separate webapps into the app server (Tomcat 5.5).
So the folder structure is something like
/Webcontent_root
----/app1
..../WEB-INF etc...
----/app2
..../WEB-INF etc...
Is this something that can be controlled within eclipse?
Thanks
I guess, eclipse can't control project with more than one context.
Approach I.
I think you should create three projects: regular java project with classes, one dynamic web project for first webcontent and one for second. Than tune up "Java Build Path" and "Deployment Assembly" settings.
Approach II.
Or you can create two web projects, first with classes and webcontent, second with webcontent and link to first project ("Java Build Path" and "Deployment Assembly" settings).
Create 2 web project and 1 java project for the shared java source. Both web project can use the shared project as a jar file in their web-inf/lib
As #Nantipov says, use the deployment assembly screen to make web projects get the shared java project as a jar in the library filder.
Yes, it can--just not with the UI in WTP (deployment has always been a sore spot and ongoing effort to improve). The .settings/org.eclipse.wst.common.component in your project controls what Eclipse/WTP thinks of as web content root(s) in your project. Odds are you just need to create a new folder in the project and add it as a sibling to the existing element in that file, but with a correct source-path value.

Categories

Resources