user5692953
user5692953

Reputation: 11

Could not publish to Tomcat 7 server NullPointerException

Eclipse 4.4.2v2015024-1700

I'm trying to launch a local Tomcat 7 server that's for an older project I haven't modified in a couple of years. I was able to get the server up and started this morning, then I made some code changes that required a newer version of a shared library, so I updated the relevant POM with the new version number. I shut the tomcat server down, then tried to restart it and it's been stuck in this perpetual error of

"Could not publish to the server.
java.lang.NullPointerException"

Things that I've tried:

Any ideas?

Related log entry in Workspace > .metadata > .log file

!ENTRY org.eclipse.wst.server.core 4 0 2018-02-27 15:30:03.862
!MESSAGE Could not publish to the server.
!STACK 0
java.lang.NullPointerException
    at org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl.getFirstTaggedRootSource(WorkbenchComponentImpl.java:234)
    at org.eclipse.wst.common.componentcore.internal.impl.WorkbenchComponentImpl.getDefaultSourceRoot(WorkbenchComponentImpl.java:587)
    at org.eclipse.wst.common.componentcore.internal.resources.VirtualResource.getProjectRelativePaths(VirtualResource.java:133)
    at org.eclipse.wst.common.componentcore.internal.resources.VirtualFile.getUnderlyingFiles(VirtualFile.java:104)
    at org.eclipse.wst.common.componentcore.internal.resources.VirtualFile.getUnderlyingResources(VirtualFile.java:93)
    at org.eclipse.wst.common.componentcore.internal.resources.VirtualResource.exists(VirtualResource.java:88)
    at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getNonBinaryComponentManifest(ManifestUtilities.java:124)
    at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getManifest(ManifestUtilities.java:81)
    at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getManifestClasspath(ManifestUtilities.java:147)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getManifestClasspath(J2EEModuleVirtualComponent.java:248)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.calculateManifestReferences(J2EEModuleVirtualComponent.java:368)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.cacheManifestReferences(J2EEModuleVirtualComponent.java:360)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:176)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:214)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:207)
    at org.eclipse.jst.common.internal.modulecore.SingleRootUtil.hasConsumableReferences(SingleRootUtil.java:217)
    at org.eclipse.jst.common.internal.modulecore.SingleRootUtil.validateSingleRoot(SingleRootUtil.java:165)
    at org.eclipse.jst.common.internal.modulecore.SingleRootUtil.isSingleRoot(SingleRootUtil.java:93)
    at org.eclipse.jst.common.internal.modulecore.SingleRootExportParticipant.canOptimize(SingleRootExportParticipant.java:88)
    at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.canOptimize(FlatVirtualComponent.java:203)
    at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.cacheResources(FlatVirtualComponent.java:185)
    at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.fetchResources(FlatVirtualComponent.java:118)
    at org.eclipse.wst.web.internal.deployables.FlatComponentDeployable.members(FlatComponentDeployable.java:227)
    at org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable.members(J2EEFlexProjDeployable.java:267)
    at org.eclipse.wst.server.core.internal.ModulePublishInfo.fillCache(ModulePublishInfo.java:314)
    at org.eclipse.wst.server.core.internal.ModulePublishInfo.getDelta(ModulePublishInfo.java:396)
    at org.eclipse.wst.server.core.internal.ServerPublishInfo.getDelta(ServerPublishInfo.java:366)
    at org.eclipse.wst.server.core.internal.Server.getPublishedResourceDelta(Server.java:1575)
    at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.getPublishedResourceDelta(ServerBehaviourDelegate.java:698)
    at org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour.getPublishedResourceDelta(TomcatServerBehaviour.java:958)
    at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.computeDelta(ServerBehaviourDelegate.java:874)
    at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:909)
    at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:774)
    at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:3157)
    at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:345)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Upvotes: 0

Views: 1734

Answers (2)

Tom Rutchik
Tom Rutchik

Reputation: 1692

I'll share my experience with the same error except I was launching a version 9 tomcat that had been working in version 8.

It turns out that my server.xml configuration had a problem in it. Even though the configuration had an error in it, it worked in version 8 of Tomcat but not in version 9. The error was that I changed the defaultHost value in the Engine section, but I didn't change the Host section name value so that the two would match. The apache documentation says that it's an error it the defaultHost value doesn't match a Host with the same name. Again, in version 8, the error was just ignored, but in version 9 I would get the NullPointer exception. I corrected that issue, and things started working again.

I will say that I did a couple of other things, so I'll mention them in case they are also important. I deleted the Server from eclipse. I closed eclispe. I deleted the tmp(?) files in the ".metadata/plugins/org.eclipse.wst.server.core. I restarted eclipse and then added the Server definition for tomcat v9.0. I then could start tomcat. I no longer got the NullPointer exception. I'm pretty sure that the issue was related with my configuration issue, since I had tried all the other things that I mentioned without making the configuration change, and that didn't work.

In exploring this issue, I noticed others mentioning that you should check your configuration files. What may catch you off guard is that you might have a bad configuration that was overlooked in the previous version. Is anyone aware of any tools that you can use to validate your Tomcat configuration? That would certain be helpful.

Upvotes: 0

user5692953
user5692953

Reputation: 11

I can't explain why this didn't seem to work yesterday, but this resolved my problem:

  1. Restore eclipse from a backup.
  2. Create a new work space.
  3. Import existing Maven Projects.
  4. Add a local embedded Tomcat server and set the project as a module to it.
  5. Start the server.

The only thing that I did differently from when I posted the question was #1. I can't help but think that the one of the eclipse components either in the work space or from the binaries somehow got corrupted yesterday.

Upvotes: 1

Related Questions