Deploy war failure on glassfish 4.1

660 views Asked by At

While deploying a war on Glassfish 4.1, I get the following error :

Caused by: java.lang.NoClassDefFoundError: org/jvnet/hk2/internal/ServiceLocatorImpl
at com.timm.mcr.api.guice.APIJerseyModule.configureServlets(APIJerseyModule.java:47)
at com.google.inject.servlet.ServletModule.configure(ServletModule.java:55)
at com.google.inject.AbstractModule.configure(AbstractModule.java:62)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
at com.google.inject.spi.Elements.getElements(Elements.java:110)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:138)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.timm.common.guice.core.guice.AbstractBindingManager.createInjector(AbstractBindingManager.java:68)
at com.timm.common.guice.core.guice.AbstractBindingManager.getInjector(AbstractBindingManager.java:53)
at com.timm.mcr.api.guice.APIGuiceServletContextListener.getInjector(APIGuiceServletContextListener.java:68)
at com.google.inject.servlet.GuiceServletContextListener.contextInitialized(GuiceServletContextListener.java:47)
at com.timm.mcr.api.guice.APIGuiceServletContextListener.contextInitialized(APIGuiceServletContextListener.java:38)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:5394)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:743)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5963)
... 34 more
Caused by: java.lang.ClassNotFoundException: org.jvnet.hk2.internal.ServiceLocatorImpl
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1783)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633)
    ... 51 more

Glassfish 4.1 have hk2-locator library installed. Why such error ?

1

There are 1 answers

5
Athi On

It looks like your project or something that its using needs that class and probably the containing jar has its scope set to provided.

If you'r using maven try to add hk2-locator-2.1.9.jar to your project:

http://mvnrepository.com/artifact/org.glassfish.hk2/hk2-locator/2.1.9

or

add the jar to glassfish4/glassfish/domains/yourdomain/lib and restart the server.

if using maven to check if Your project is using it run:

mvn dependency:tree