Community
Participate
Working Groups
Build ID: M20071023-1652 Steps To Reproduce: 1. IProgressMonitor monitor = new NullProgressMonitor(); 2. IProject project = ... some web project. 3. EARArtifactEdit edit = new EARArtifactEdit(project,false); 4. edit.setWebContextRoot(project,"test"); ->NPE More information: The variable edit contains after line 3 a not null reference value. Line 4 creates a null pointer exception. I also do not understand why I need a project to create the EARArtifactEdit and when I want to set the web context root I need the project again? I don't know how to set the web context root otherwise.
Udo, do you just have a standalone Web project, that you want to set the Context Root for? Or is this Web project a member of an EAR? And is it a Servlet 2.5 Web module? Or Servlet 2.4 or earlier?
Also, if the project in step 2 is a web project, it should not be passed into EARArtifactEdit's constructor - that is for EAR projects. (So this would appear to be a usage problem.)
The project facets are: Dynamic Web Module 2.5 Java 6.0
How can I change the context path of a "not EAR" web project?
The appropriate way to set the context root for a Web project is via J2EEProjectUtilities.setServerContextRoot(webProject, contextRoot); While J2EEProjectUtilities is an internal class, it is used extensively by both WTP code and adopters. If requested, an API can be created to access this. I am lowering the severity of this bug for now.
Hi Carl, a public API for setting the context root would be great!
The proper place to put this would be in WebUtilities.
Created attachment 159476 [details] A public API to set the context root
Committed to HEAD for WTP 3.2 M6
Thanks, I will try in one of our next releases.