Setup a Eclipse Workspace With One Dynamic Web Project and Multiple Java Projects - eclipse

Can someone guide me to setup a web app project in Eclipse. I want to have a Dynamic Web Project and multiple Pure Java Projects. My Web project will contain JSPs and Java projects will contain Struts Action classes, Spring Bean, Hibernate Entities etc. I want to use those Java Projects as dependency to the WAR. I have done work in such environments, but haven't setup a workspace from the scratch. Can you please guide me or share a link?
Note: I want to use Apache Tomcat or Glassfish as server

In every project you can set the JavaBuild Path properties.
So suppose you have project1 that is dependent on project 2 and some other libraries provided as jars. Go to that option for project1, choose tab Projects and add project2 (that of course is already a eclipse project), than go to tab Libraries and clic on Add external jars.. You are done. This is not dependant by the nature of the project.
Specifically, since you have a Dynamic Web Project, you'll need to go also to Deployment Assembly and add project2 and your jars to the list of files needed by the server.

Related

When adding resources to a Tomcat server in Eclipse, what can be a resource?

When I bring up the "Add and Remove" resource dialog to add things like .war files (I think war is an example), I would like to know what sort of things constitute "resources" and how Eclipse identifies them as such. I am working on a new project that has a fairly complex Maven build and it is not clear to me what exactly I am adding to Tomcat. Could a directory be a resource? A pom file?
I should mention that I see a SNAPSHOT file (actually, the thing named this seems to be a Windows folder which does not hold jars) as a resource that can be added but the build does not seem to be producing a war or jar file which is named in this way. What does get added if I choose to add this resource seems to be composed of a bunch of jars or wars.
Perhaps you didn't create your project as "Dynamic Web Project", so Eclipse doesn't recognize it like a web project. Create new "Dynamic Web Project" or go to Properties -> Projects Facets and check Dynamic Web Module
It looks like entities other than jars can be added to a server.

Developing two related Projects in Eclipse for Tomcat

I have two projects in Eclipse. One Project is a dynamic web project which is deployed on the integrated tomcat server everytime i make changes to it (which works great).
The second project is a library project which currently needs to be build with ant. The resulting .jar file needs to be copied manually to the first project's WEB-INF/lib directory and the whole project needs to be refreshed, rebuilt and the tomcat needs to be restarted.
Is there a way to connect the library project to the web project so that changes made to the library will be automatically deployed to the web project? This would make the whole development process a lot easier
In your webapp project go to properties. Under "Deployment Asselmbly" you can add your other project. So it's automaticaly added to your WEB-INF/lib folder.
More information here.

Grails Project - Common Java Project Dependency in Eclipse

All,
We have standard java projects that contain our common data model, common util classes, etc...
What I can’t seem to figure out is how, to make my Grails project (in Eclipse) have a dependency on the other standard (non Grails) java project in the workspace. When I add the project in the “Java Build Path” the project doesn’t show any compiler errors, but it when I run “Grails Tools -> Refresh Dependencies” or attempt to run the project (run-app) it fails.
This seems like it would be a pretty common thing, but I have searched all over the web and have been unable to find a solution. We are not using maven in our environment. Since we build Eclipse RCP applications on the client side, we use OSGI manifests to manage our project / bundle dependencies.
You can use linked source directories to include the Java or Groovy dependencies in the grails project and you need to set the output directory to Project/target/classes (these configurations go into the grails project preferences in Java Build Path options -> Source Tab).
The change in the output directory allows Eclipse to detect changes in the dependencies and auto load it when running the app using grails run-app.
You can use autocomplete and debug the sources of the dependencies with this configuration.
I prepared a step and step process that includes screenshots for Java and Groovy here
The documentation includes information on customizing the build.
You can add this to your BuildConfig.groovy:
grails.compiler.dependencies = {
fileset (dir:"/path/to/jars")
}
That should get you started.
If the dependencies are not stored in an Ivy/Maven repository then AFAIK your only option is to copy the dependencies to the lib directory of the Grails project.

Create complete EAR Project with Maven and Eclipse Helios

I read some articles about how to set up eclipse and maven to create a new empty ear project but all solutions weren't complete or are to old.
I believe that I need to create three pom.xml files / or three projects:
client project with the WEB-APP structure (like a regular dynamic web project).
This should result in a WAR file.
server project with the ejbs. This should be a JAR file.
ear project which joins both projects together.
I tried that with help of the integrated maven plugin in eclipse. Since (I believe Helios) maven is already integrated in eclipse. So I go to
file -> new -> maven -> maven project
and leave the "create a simple project" checkbox unchecked. On the next side I got the archetype catalog. To create the client project I looked for maven-archetype-webapp Version 1.0.
But all the folders like WebContent\META-INF etc. are missing.
So how can I create all three projects are build them together?
Thanks a lot,
Hauke
PS.: I read in question 5668710 about creating the project without maven and activate the dependency management. But is that the right way? I don't think so.
Creating the projects via console and importing them via m2eclipse would be the best way, as you can read it in the comments of your question.
Start off with this line in your console
mvn archetype:generate
Then use the archetype maven-archetype-j2ee-simple
This will generate you a project structure for ejb, ear and web projects. Otherwise you can create 3 simple projects maven-archetype-quickstart on your own and add the concering plugins
maven-ear-plugin
maven-ejb-plugin
maven-war-plugin
Here is another post, handling your problem: Maven2: Best practice for Enterprise Project (EAR file)
Another nice example you can find here
The best and the most clean way for creating an Enterprise Application (all the three projects ear, jar, war.... i.e. jar and war are linked into ear).... is to create through maven Enterprise Application in NETBEANS and import the whole project into Eclipse.
Thanks
Imran

How to set up JRebel in a Tomcat environment

I'm having a hard time getting JRebel to work in my current development environment.
I have multi module maven projects. Currently, the Tomcat instance is controlled via service (tomcat monitor) and the deployed web apps are configured with a XML located at ${catalina.home}/conf/Catalina/localhost where the docBase attribute points ${absolute maven project path}/target/app (and the attribute reloadable is true). So every time I do a maven build I only have to manually restart tomcat if there any classes changed. If the modifications occurred in the static resources (JSP, HTML, JS,
etc..) a page refresh will do it.
On my first attempt, I configured the web apps to run on a tomcat server running inside Eclipse. The maven plugin provided was also configured with success: all my sub-modules inherited the plugin configuration and I can saw in the tomcat startup the output messages from JRebel indicating the absolute project paths that were been listen. The only problem is that Eclipse WTP / Tomcat plugins don't go weel with War overlay feature in eclipse. After starting the server, only the resources present in the last web app (the module that have other War as dependencies) were deployed.
So, I returned to my original configuration development and introduced JRebel to it. I passed the JRebel java options to the Tomcat Vm, all maven modules had the rebel.xml (listening to the correct resource folders), but nothing happens. I can't see the usual JRebel messages and I experimented changing a JSP in the source folder and do a page refresh but the file ins't automatically redeployed (in this case a simple copy from the source folder the the ${maven.projec}/target/app will do the trick).
My two questions are:
It's possible to over come that eclipse WTP issue?
What is a funcional development environment involving maven eclipse and a external tomcat?
Any help would be much appreciated!
UPDATE 1
So, I got it. Kind of...I'm still struggling with the war modules overlaying. I have a main web app module that depends on several webapps modules. Because the rebel.xml it's generated dynamically via jrebel maven plugin when the main webapp build occurs, only the it's jrebel.xml prevail. All the other are squashed. The rebel.xml for the jars modules are at the right places (inside the jar file).
I can get it work if I create a custom rebel.xml for the main webapp that points to all the absolute directories containing the source files (static files such as JSP, HTML, JS, CSS, images, etc.) of the depending web apps. But this is worthless for my team development environments. I'm using maven properties but we've have two different maven multi-module hierarchy that don't know about each other and I can't use a root pom to connect them. So these kind of properties will not be enough to guarantee that the absolute paths generated on each developer machine in the rebel.xml are correct.
For now, I'm trying to tackle using some kind of maven plugin to do the rebel.xml merge. For the record without success yet.
This is becoming another issue a bit different of the original question :) Maybe I should through another question.
UPDATE 2
I got it working!..finally.
I used the XSLT Generator Maven Plugin to help me merge the various rebel.xml files. Also had to use the fabulous Maven Copy Plugin because the xslt transformation occurred after the final war packaging and I had to add the resulting rebel.xml to that WAR.
If someone needs the configuration files details down't hesitate asking.
Hope's this helps someone out there.
I got it working!..finally. I used the XSLT Generator Maven Plugin to help me merge the various rebel.xml files. Also had to use the fabulous Maven Copy Plugin because the xslt transformation occurred after the final war packaging and I had to add the resulting rebel.xml to that WAR.