kumuluz / kumuluzee

Lightweight open-source framework for developing microservices using standard Java EE technologies and migrating Java EE to cloud-native architecture.
https://ee.kumuluz.com
MIT License
291 stars 71 forks source link

.NoClassDefFoundError: org/glassfish/jersey/internal/ServiceFinder #98

Closed fabiovas closed 6 years ago

fabiovas commented 6 years ago

Hi. Every time I try to start an uber jar with JAX-RS it fails. Exception org.eclipse.jetty.server.AbstractConnector -- Started ServerConnector@41641c84{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} Exception in thread "main" java.lang.NoClassDefFoundError: org/glassfish/jersey/internal/ServiceFinder at org.glassfish.jersey.servlet.internal.ServletContainerProviderFactory.getAllServletContainerProviders(ServletContainerProviderFactory.java:66) at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.onStartup(JerseyServletContainerInitializer.java:134) at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140) at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:63) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:329) at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1515) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1477) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) at org.eclipse.jetty.server.Server.start(Server.java:418) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.server.Server.doStart(Server.java:385) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at com.kumuluz.ee.jetty.JettyServletServer.startServer(JettyServletServer.java:80) at com.kumuluz.ee.EeApplication.initialize(EeApplication.java:360) at com.kumuluz.ee.EeApplication.(EeApplication.java:73) at com.kumuluz.ee.EeApplication.main(EeApplication.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.kumuluz.ee.loader.EeClassLoader.invokeMain(EeClassLoader.java:455) at com.kumuluz.ee.loader.EeBootLoader.launch(EeBootLoader.java:54) at com.kumuluz.ee.loader.EeBootLoader.main(EeBootLoader.java:41) Caused by: java.lang.ClassNotFoundException: Failure to load: org.glassfish.jersey.internal.ServiceFinder at com.kumuluz.ee.loader.EeClassLoader.loadClass(EeClassLoader.java:509) at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

This is my Pom: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>com.ibm.jsf</groupId>
<artifactId>jsf</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>JSF</name>
<description>JSF Test </description>

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <kumuluz.version>2.5.2</kumuluz.version>
    <kumuluzee-config.version>1.1.0</kumuluzee-config.version>
    <kumuluzee-logs.version>1.3.0</kumuluzee-logs.version>
    <kumuluzee-discovery.version>1.1.0</kumuluzee-discovery.version>
    <kumuluzee-rest.version>1.2.0</kumuluzee-rest.version>
    <kumuluzee-cors.version>1.0.2</kumuluzee-cors.version>
    <kumuluzee-health.version>1.0.0</kumuluzee-health.version>
    <kumuluzee-fault-tolerance.version>1.0.0</kumuluzee-fault-tolerance.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.kumuluz.ee</groupId>
            <artifactId>kumuluzee-bom</artifactId>
            <version>${kumuluz.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>com.kumuluz.ee</groupId>
        <artifactId>kumuluzee-core</artifactId>
    </dependency>
    <dependency>
        <groupId>com.kumuluz.ee</groupId>
        <artifactId>kumuluzee-servlet-jetty</artifactId>
    </dependency>
    <dependency>
        <groupId>com.kumuluz.ee</groupId>
        <artifactId>kumuluzee-jsp-jetty</artifactId>
    </dependency>
    <dependency>
        <groupId>com.kumuluz.ee</groupId>
        <artifactId>kumuluzee-el-uel</artifactId>
    </dependency>
    <dependency>
        <groupId>com.kumuluz.ee</groupId>
        <artifactId>kumuluzee-jsf-mojarra</artifactId>
    </dependency>

    <dependency>
        <groupId>com.kumuluz.ee</groupId>
        <artifactId>kumuluzee-cdi-weld</artifactId>
    </dependency>
    <dependency>
        <groupId>com.kumuluz.ee</groupId>
        <artifactId>kumuluzee-jax-rs-jersey</artifactId>
    </dependency>
    <dependency>
        <groupId>com.kumuluz.ee</groupId>
        <artifactId>kumuluzee-json-p-jsonp</artifactId>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.kumuluz.ee</groupId>
            <artifactId>kumuluzee-maven-plugin</artifactId>
            <version>${kumuluz.version}</version>
            <executions>
                <execution>
                    <id>package</id>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

jmezna commented 6 years ago

I was not able to reproduce your exception. I used your pom configuration to create an empty project, but it starts up without any exceptions.

Can you provide any additional info about your project? Which version of Java are you using.

fabiovas commented 6 years ago

Hi. My eclipse, where I am building the project, is using :

Java(TM) SE Runtime Environment (build 1.8.0_151-b12) Java HotSpot(TM) Client VM (build 25.151-b12, mixed mode)

I am trying to execute the jar using same JAVA build (that by the way is IBM SDK) or OpenJDK:

OpenJDK Runtime Environment (build 1.8.0_162-8u162-b12-0ubuntu0.16.04.2-b12)

I attached the project, that is very simple. First I started using the JSP sample and now I am trying to add JAX-RS and JPA libs. jsf.zip

jmezna commented 6 years ago

Your project works OK in my environment. Maybe it is the problem with your Eclipse build. Try building the project with Maven

mvn clean package

and then execute the JAR:

java -jar .\target\jsf-1.0.0.jar

fabiovas commented 6 years ago

Yes, when I build using the linux console it works. This is my eclipse version: Version: Oxygen.2 Release (4.7.2) Build id: 20171218-0600 Eclipse was using the maven 3.5.3 that I had installed.

fabiovas commented 6 years ago

THANKS A LOT!!!!!