- This topic has 16 replies, 2 voices, and was last updated 19 years, 9 months ago by Riyad Kalla.
-
AuthorPosts
-
gjeudyMemberHi,
I’m trying to generate a WAR file from my Web Project but don’t seem to get the correct files in my WAR file. What is the best practice to organize a Web Project.
We are using CVS with our project within Eclipse. The project structure is the following. NB: We don’t use EJB, JSP, etc, just plain java classes & servlets.
src/*.java
bin/*.classes (IGNORED BY CVS)
doc/*.zip (3rd party library documentation), nice to have on CVS
lib/*.jar (3rd party libraries)
scripts/*.xml (ant build script)
war/*.war (3rd party web app)However, when I deploy the application whether as exploded or packaged archive I get all the files above in the distribution. I’d like however to include only bin/*.classes & lib/*.jar.
What would be the best practice?
I can’t seem to find options to exclude certain parts of the web project for deployment.
Thanks for your time,
Guillaume Jeudy
Riyad KallaMemberWhat is the best practice to organize a Web Project.
http://www.myeclipseide.com/FAQ+index-myfaq-yes-id_cat-30.html#111, very standard/popular format.
However, when I deploy the application whether as exploded or packaged archive I get all the files above in the distribution. I’d like however to include only bin/*.classes & lib/*.jar.
You need to create a Web Project and follow that structure. What you have above looks like a plain-jane Java project. MyEclipse does not support plain Java projects that will and I would honestly just suggest you to write a 6-10line Ant task to create your WAR file for you with the structure above, it is very straight forward and simple.
If you still want to use MyEclipse though you’re web project will look a little strange in that your WebRoot dir will be empty, as well as your WEB-INF directory. Just your WEB-INF/lib and WEB-INF/classes directory will have anything in them.
Riyad KallaMemberI take that back, your WEB-INF dir will have your web.xml file in it that defines your servlets. It is just your WebRoot that will be empty (or maybe have a simple index.jsp in it?)
gjeudyMemberThanks for the pointers,
Currently, after converting my plain java project to web project I had new dirs created under my project root.
META-INF/manifest.mf
WEB-INF/lib
WEB-INF/web.xmlwhen generating the WAR from MyEclipse I currently have every single files in my web project included because my webroot is also the project root which is bad I guess. It also automatically includes classes from my /bin/ output dir into the WEB-INF/classes/ dir, as well as include jars from my /lib/ dir into the WEB-INF/lib/ dir. I had to check an option for the jars to work.
I’m going to try and reorganize the structure of my project. I’d still like to use MyEclipse because I want to take advantage of the ‘sync on demand’ feature for exploded deployments.
I’ll let you know if this works.
Thanks for your help,
Guillaume Jeudy
Riyad KallaMembermy webroot is also the project root which is bad I guess.
It depends on the project, but in this case yes it’s not the best.
I’m going to try and reorganize the structure of my project.
I suggest this for the easiest move over:
1) Open your old Java Project (JP)
2) Create a new Web Project (WP), Web root context (whatever you want), Web Root directory set to “WebRoot” or “webroot” or something you want (“docroot” works too… whatever).
3) Copy ALL of the contents of your JP/src dir into your WP/src dir… you will likely get a ton of compilation errors due to missing libraries
4) Copy ALL the contents of your JP/lib dir into your WP/WebRoot/WEB-INF/lib dir, now make sure everything compiles into your WP/WebRoot/WEB-INF/classes dir (you will have to switch to Navigation view).
5) Copy your JP/docs and JP/scripts dirs right into the root of your WP, it will create /docs and /scripts sub dirsSo now you should have something like:
WebProject + /src (contains all sources) + /docs + /scripts + /webroot + /WEB-INF + web.xml (generated web.xml file) + /classes (this is your output dir, all files compiled into here) + /lib (all your libs from JP/lib got copied into here)
That should give you everything you need nice and smoothly without errors… let me know if you run into trouble.
gjeudyMemberThanks alot.
It worked as expected, like a charm. 😀
Best regards,
Guillaume Jeudy
gjeudyMemberNew problem.
I’m trying to explode my web project to a mapped network drive (web server) the directory already exists. I just want it to overwrite whatever is in META-INF & WEB-INF directories. Instead it creates a new directory bearing the name: (existing dir name + web project name).
What can I do to avoid this? The webcontext was set to a simple ‘/’ because META-INF & WEB-INF are directory in the root of my webapp directory (on the web server)
Thanks again,
Guillaume Jeudy
Riyad KallaMemberErase the dir first then try the deployment, did that work?
IIRC we had a case where 2 users actually erased their hard drives using custom deployments and deleting the locations (deploying to root of drive), so we added some fail-safe code into the custom deployment setup that refuses to deploy to an existing dir as a safety percaution against anyone doing this (one user deployed to thier Desktop dir, and ended up erasing it!).
gjeudyMemberHooray, it worked now !
Added a JSP for fun and darn just noticed the “Sync On-Demand” literally replaced every darn file on my web server deployment.
I’m using “Custom Deployment” option because our web server “SunOne WebServer 6.1” is not supported by MyEclipse.
Any pointers or is this how it should work? It takes several minutes to redeploy everything over the network.
Thanks,
GJ
gjeudyMemberAlso I’d like to add that I manually copied back alot of files that were originally in my web app dir (css, html, js) and that I’m not willing to include in the eclipse web project for the moment because we are still evaluating your product.
Maybe that action triggered a full redeploy of the web-app when I added a test JSP file to my web project. Just a thought.
Regards,
GJ
Riyad KallaMemberThe hot syncing will only replace files that exist in your project and do not match in your deployment (time stamp). So if you added a new JSP, it will get deployed, if you changed a CSS file, it will get deployed, if you changed a single Java file, it’s class will get deployed. It won’t trigger a full redeployment, I don’t know why you saw that unless you used the “redeploy” button in the deployment tool to explicitly cause it to redeploy everything.
gjeudyMember1./ Does the hot syncing occur automatically whenever a file is modified and or created ?
2./ The full redeployment consistently occurs when other files are copied to the deployment dir by other means that the ‘MyEclipse’ IDE, then when a new file is created or modified in ‘MyEclipse’ it performs a full redeploy. If I manage all files from ‘MyEclipse’ the update works as expected and doesn’t replace everything.
Solution: From what I’ve seen, it is not recommended to tamper with the ‘deployment’ dir outside of the ‘MyEclipse’ IDE. I’ll have to integrate every single files in the project.
Guillaume Jeudy
Riyad KallaMember1) If automatic build (Project menu) is turned on, then yes. On every save it is synced.
2) Strange…
gjeudyMemberUpdate:
As with most applications we have a dev environment & prod env. Considering the way the ‘Hot Sync’ works we would modify, develop the application with a ‘hot-synced’ deployment on our dev server, which is fine for development purposes.
However, a problem occurs when we want to deploy changes to the production environment.
1./ We can’t use the deploy feature in the production environment unless we delete the deployment dir manually beforehand. (not very handy)
2./ Even if we use the deploy feature, we don’t want the ‘hot-sync’ feature to be active for our production environment. (Imagine untested code accidently ending up in production and screwing everything up).
Our requirements can’t seem to be consistently met by ‘MyEclipse’. Ideally we would need a button ‘Synchronize Web Project’ which will identify changes and let us approve the sync beforehand. (Similar to the Team CVS Synchronize Repository feature built-in Eclipse).
Current Workaround: Manually copy changes to the production environment (error-prone).
Regards,
Guillaume Jeudy
Riyad KallaMemberWhy not use File > Export > J2EE War File, for production machine every time you want to deploy the production version?
-
AuthorPosts