- This topic has 7 replies, 2 voices, and was last updated 21 years, 5 months ago by Scott Anderson.
-
AuthorPosts
-
johnswMemberI recently installed Eclipse M1 (on Win2K) with Tomcat 4.1.24 and Sysdeo’s tomcat plugin. I have been able to create and run web projects which comprise JSP and servlets.
I recently installed EnterpriseWorkbenchInstaller_020101 on a clean Eclipse M1 install, but have been having problems getting a project to run a servlet – I was getting a “Requested resource not available” error.
There are no problems with JSPs. And I have read the documentation, and think that I have done evrything correctly.
When I created the servlet, I used the MyEclipse wizard, and made sure that the web.xml file to be updated was: /myproject/Web Root/WEB-INF
I can see that the servlet class has been generated in the D:\eclipse\workspace\myproject\Web Root\WEB-INF\classes (in an expanded package)
Only after using the Project->MyEclipse->Deploy command was I able to get the servlet to work. But I can see that “deploying” places the expanded web app under the Tomcat webapps directory (so no surprises that it works).
Here are some questions which should help me to understand what is going on:
1) Why does running JSPs not require you to use the Project->MyEclipse->Deploy command, but servlet do?
2) How does TC know about your web project if you don’t deploy? Should servlets work even if you don’t use the deploy command?
3) Why does the directory structure between a not yet deployed web app (eg D:\eclipse\workspace\myproject\Web Root) differ from a deployed app (eg D:\java\jakarta-tomcat-4.1.24\webapps\myproject)?
4) Is the server.xml file EVER modified by MyEclipse? And can I safely add a context here for my project with additional resource, and realm authentication information etc?
5) If I want to create bean classes (in a package) should these be placed in java sources, or can they be referenced from another eclipse project. The reason I’m asking is that we have to use CVS for source code, and the MyEclipse web project structure is not quite how we would configure the CVS directory structure.
Aplogies for the long message, but could someone help clear up my confusion?
Thanks
Scott AndersonParticipantJohn,
I’ll see if I can answer your questions for you.
I recently installed EnterpriseWorkbenchInstaller_020101 on a clean Eclipse M1 install
First, the M1 build is not a supported configuration and there are known problems with it. MyEclipse Enterprise Workbench is currently only certified on Eclipse 2.1. We will ship an Eclipse 2.1.1 version with the GA release on 7/15. In the meantime, please use Eclipse 2.1 only with the Enterprise Workbench.
For more information on our Eclipse version support strategies, please see:
1) Why does running JSPs not require you to use the Project->MyEclipse->Deploy command, but servlet do?
Actually running anything requires you to deploy it. The fact that your JSPs work without deploying tells me that you’ve previously modified your server.xml file to point to this project.
2) How does TC know about your web project if you don’t deploy? Should servlets work even if you don’t use the deploy command?
The only way it could know is by user intervention by editing the server.xml file. Without such intervention, nothing should work without using the Deploy command because Tomcat would have no way to know about your project.
3) Why does the directory structure between a not yet deployed web app (eg D:\eclipse\workspace\myproject\Web Root) differ from a deployed app (eg D:\java\jakarta-tomcat-4.1.24\webapps\myproject)?
The only real difference is that a top-level directory is created on deployment and your exploded web root directory content is placed within it. Other than that, it’s the same. The reason for the creation of the top-level directory is so that the project will have a context path.
4) Is the server.xml file EVER modified by MyEclipse? And can I safely add a context here for my project with additional resource, and realm authentication information etc?
No, we do not modify (or read) server.xml. For all our exploded deployments we take advantage of the server capability to understand an exploded deployment dropped into a “deployment” directory. If you explicitly add a context, you should remember to point it to the exploded deployment directory under Tomcat, rather than back to your Eclipse project itself.
5) If I want to create bean classes (in a package) should these be placed in java sources, or can they be referenced from another eclipse project.
The easiest way is to place them in Java sources. Using a dependent project can work, but right now the deployer does not support this model so you’d have to use the jar exporter to create a jar and place it in the web project’s WEB-INF/lib directory whenever it was modified. However, full debugging would still function. We’ll be adding a dependent project model in an upcoming release.
–Scott
MyEclipse Support
johnswMemberScott, Thanks for the info, and help.
I will get the 2.1 version of Eclipse.
One last question (I hope).
My servlet extends org.apache.catalina.servlets.WebdavServlet. I added the jars for servlets-default.jar and servlets-webdav.jar using the project->properties->java build path->libraries, so that the servlet would compile within Eclipse.
When I start TC via Eclipse, and access the servlet I get a javax.servlet.ServletException: Error allocating a servlet instance (root cause java.lang.NoClassDefFoundError: org/apache/catalina/servlets/WebdavServlet).
This is strange because these jars exist in the server\lib directory within the TC directory, and so should presumably be on the classpath.
Any ideas why this is causing this problem?
Scott AndersonParticipantThe classpath problem is an interesting one. Do you have this same issue when starting Tomcat outside of Eclipse? You are correct that anything within the Tomcat server/lib directory should be loaded on the classpath by Tomcat when it starts up.
This could be a problem because you’re using the M1 build, but here are a couple of things to try:
1) Append the jars to the Tomcat connector’s classpath manually under the Tomcat preferences then see if your results are different.
2) Alternatively, you can add these jars to the WEB-INF/lib directory which will force them to be deployed with your webapp.
3) Wait to do all of this until you install Eclipse 2.1. 🙂–Scott
MyEclipse Support
johnswMemberI reinstalled Eclipse 2.1 with Tomcat 5 (now) and MyEclipseIDE.
The problem did exhibit itself whe Tomcat was run standalone. The solution was to copy the appropriate jars from /server/lib to my deployed webapp project, eg myproject/WEB-INF/lib
What’s puzzling is that the sample webdav webapp in TC 4 works without having to copy the jars to the WEB-INF/lib. But I couldn’t figure out why the example worked, and my servlet in my webapp did not…
Can I add jar files to the Web Root/WEB-INF/lib directory in my eclipse project and have them deployed automatically when I next run TC? Is there something that I have to do to tell Eclipse to deploy them?
What is the best way to deal with jar files that my servlets require i) in order to compile within Eclipse, and ii) to be available to TC when running the webapp?
Thanks again.
Scott AndersonParticipantJohn,
I reinstalled Eclipse 2.1 with Tomcat 5 (now) and MyEclipseIDE.
Good deal; the “power duo” of web app development. 😉
The problem did exhibit itself whe Tomcat was run standalone.
That makes sense. I figured it would because our launch is extremely similar to the launch done with the scripts.
But I couldn’t figure out why the example worked, and my servlet in my webapp did not…
Sometimes it’s just more time efficient to fix the problem and keep moving.
Can I add jar files to the Web Root/WEB-INF/lib directory in my eclipse project and have them deployed automatically when I next run TC?
Absolutely. Our deployer takes care of that for you.
Is there something that I have to do to tell Eclipse to deploy them?
You already did; you put them in the web app’s lib directory. That’s enough of a clue to MyEclipse that they’re important. 🙂
What is the best way to deal with jar files that my servlets require i) in order to compile within Eclipse, and ii) to be available to TC when running the webapp?
Just put them in the lib directory of your web app project. MyEclipse will automatically add them to the project classpath and make sure they get deployed. If you need to remove them, just delete them from the lib directory and MyEclipse will take them off the classpath and undeploy them. That’s it. It’s really a cool feature, if only our doc was complete enought to let everyone know about it. 😉
–Scott
MyEclipse Support
johnswMemberJust put them in the lib directory of your web app project. MyEclipse will automatically add them to the project classpath and make sure they get deployed. If you need to remove them, just delete them from the lib directory and MyEclipse will take them off the classpath and undeploy them. That’s it. It’s really a cool feature, if only our doc was complete enought to let everyone know about it. 😉
Actually this is a feature that I couldn’t get to work. Using Windows explorer I added a jar file to the myproject/WEB-INF/lib directory. It didn’t get deployed automagically to the Tomcat/webapps/myproject/WEB-INF/lib directory. I had to copy the file manually.
The only way I could get this to work, was to first undeploy the app, and then to redeploy the app. Is this how it should work?
Also, placing the jar file myproject/WEB-INF/lib directory, did not mean that Eclipse knew about it, in the same way it would it you added the jarfile to the build path. Is that correct too?
Apologies for the endless questions – but I really like this product and want to understand it as best I can to get the most out of it.
Scott AndersonParticipantUsing Windows explorer I added a jar file to the myproject/WEB-INF/lib directory. It didn’t get deployed automagically to the Tomcat/webapps/myproject/WEB-INF/lib directory. I had to copy the file manually.
After doing any file operations outside of Eclipse, you need to be sure to refresh the project so that Eclipse will recognize the changes. The way we’d suggest doing this instead is:
1) Select the lib directory you’d like to import into in the package explorer.
2) Choose File->Import…->File System
3) Pick the jar you want add to the lib directory and import it
4) Notice that your classpath was updated and your project recompiled as a result.Also, placing the jar file myproject/WEB-INF/lib directory, did not mean that Eclipse knew about it, in the same way it would it you added the jarfile to the build path. Is that correct too?
I think that’s caused by the lack of a refresh too. Using Import should clear that up.
The only way I could get this to work, was to first undeploy the app, and then to redeploy the app. Is this how it should work?
I walked through these steps and noticed that the new lib is NOT being copied out to the deployment areas once imported. That’s a defect and I’ve logged it into our internal system so it can be fixed for the GA release. The workaround in the meantime is to undeploy and redeploy the project, as you found out.
Apologies for the endless questions – but I really like this product and want to understand it as best I can to get the most out of it.
Thanks for reporting your experiences as it makes the product better for everyone.
–Scott
MyEclipse Support -
AuthorPosts