title: Cannot add Module to Java EE Enterprise Application - nullPointer when creating Enterprise Application Project
body: <p>We have been using RAD 7.5.5/WebSphere 6.1, but are upgrade our dev environment to Eclipse Juno/WAS 8.5. While everything works in RAD/WAS 6.1, I am having trouble getting our website running locally in Eclipse/WAS 8.5.</p>
  
  <p>I took a screencast of my creation process, see the link below. The <code>nullPointerException</code> stack trace is included as well.
  <a href="http://screencast.com/t/VE5KxmCCSsQ" rel="nofollow">http://screencast.com/t/VE5KxmCCSsQ</a></p>
  
  <p>Here are some images of my project settings. CBSWebApp is the Java/JSP application, and eCB is the Enterprise Application Project.
  <a href="http://imgur.com/Ol0pDbt,mC4cT1b,WXMYvbQ#0" rel="nofollow">http://imgur.com/Ol0pDbt,mC4cT1b,WXMYvbQ#0</a></p>
  
  <pre><code>eclipse.buildId=M20130204-1200
  java.version=1.7.0_25
  java.vendor=Oracle Corporation
  BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
  Framework arguments:  -product org.eclipse.epp.package.jee.product
  Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product
  
  Error
  Thu Jul 18 15:18:02 EDT 2013
  
  
  java.lang.NullPointerException
      at org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationOp.findReferencedComponent(AddComponentToEnterpriseApplicationOp.java:413)
      at org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationOp.updateEARDD(AddComponentToEnterpriseApplicationOp.java:140)
      at org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationOp.execute(AddComponentToEnterpriseApplicationOp.java:87)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl$1.run(DataModelPausibleOperationImpl.java:385)
      at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:410)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:360)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.doExecute(DataModelPausibleOperationImpl.java:247)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.executeImpl(DataModelPausibleOperationImpl.java:219)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.cacheThreadAndContinue(DataModelPausibleOperationImpl.java:89)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.execute(DataModelPausibleOperationImpl.java:207)
      at org.eclipse.jst.j2ee.project.facet.EarFacetPostInstallDelegate.execute(EarFacetPostInstallDelegate.java:75)
      at org.eclipse.wst.common.project.facet.core.events.internal.LegacyEventHandlerAdapter.handleEvent(LegacyEventHandlerAdapter.java:69)
      at org.eclipse.wst.common.project.facet.core.events.internal.ProjectListenerRegistry.notifyListeners(ProjectListenerRegistry.java:76)
      at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.notifyListeners(FacetedProject.java:1327)
      at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.modifyInternal(FacetedProject.java:454)
      at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.mergeChangesInternal(FacetedProject.java:1181)
      at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.access$2(FacetedProject.java:1117)
      at org.eclipse.wst.common.project.facet.core.internal.FacetedProject$5.run(FacetedProject.java:1099)
      at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
      at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.mergeChanges(FacetedProject.java:1109)
      at org.eclipse.wst.common.project.facet.core.internal.FacetedProjectWorkingCopy.commitChanges(FacetedProjectWorkingCopy.java:2020)
      at org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard.performFinish(ModifyFacetedProjectWizard.java:400)
      at org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard.performFinish(NewProjectDataModelFacetWizard.java:282)
      at org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard$3.run(ModifyFacetedProjectWizard.java:331)
      at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
      at org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard$4.run(ModifyFacetedProjectWizard.java:345)
      at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
  </code></pre>
  
  <p>I also get the below <code>nullPointerException</code> when trying to set the context root to <code>CBSWebApp</code> in Eclipse. When looking at my settings in the working RAD environment, I noticed this field was successfully filled out as 'CBSWebApp', but remains a blank default in Eclipse, and I cannot change it without generating the below error. </p>
  
  <pre><code>null
  Error
  Thu Jul 18 16:06:44 EDT 2013
  
  
  java.lang.NullPointerException
      at org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent.setMetaProperty(VirtualComponent.java:283)
      at org.eclipse.wst.common.componentcore.internal.operation.ServerContextRootUpdateOperation.execute(ServerContextRootUpdateOperation.java:40)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl$1.run(DataModelPausibleOperationImpl.java:385)
      at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:410)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:360)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.doExecute(DataModelPausibleOperationImpl.java:247)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.executeImpl(DataModelPausibleOperationImpl.java:219)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.cacheThreadAndContinue(DataModelPausibleOperationImpl.java:89)
      at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.execute(DataModelPausibleOperationImpl.java:207)
      at org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities.setServerContextRoot(ComponentUtilities.java:337)
      at org.eclipse.jst.j2ee.internal.ui.refactoring.RenameContextRootChange.perform(RenameContextRootChange.java:125)
      at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
      at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
      at org.eclipse.ltk.core.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:258)
      at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
      at org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:306)
      at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.executeChange(UIPerformChangeOperation.java:92)
      at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:223)
      at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
      at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
      at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
  </code></pre>
  
  <p>Your help is greatly appreciated in this - this is causing a lot of problems for me and my team. Thanks!</p>