Netflix / Hystrix

Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
24.11k stars 4.7k forks source link

java.lang.NoClassDefFoundError: Could not initialize class com.netflix.hystrix.HystrixCommandMetrics #1725

Open preetigupta25 opened 6 years ago

preetigupta25 commented 6 years ago

Hello,

I am using HystrixNetworkAuditorAgent and HystrixNetworkAuditorEventListener. Please check.

Here is my pom for the agent jar

`

<dependencies>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-hystrix</artifactId>
        <version>1.1.5.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-hystrix-dashboard -->

    <dependency>
        <groupId>com.netflix.hystrix</groupId>
        <artifactId>hystrix-network-auditor-agent</artifactId>
        <version>1.5.12</version>
    </dependency>

</dependencies>

<properties>
    <java.version>1.8</java.version>
    <!--<tomcat.version>7.0.52</tomcat.version>-->
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <shadedArtifactAttached>true</shadedArtifactAttached>
                <shadedClassifierName>jar-with-dependencies</shadedClassifierName>
                <artifactSet>
                    <includes>
                        <include>com.netflix.hystrix:*</include>
            <include>org.slf4j:*</include>
            <include>com.google.guava:*</include>
            <include>org.aspectj:*</include>
            <include>com.fasterxml.jackson.core:*</include>
                    </includes>
                </artifactSet>
        <transformers>

                        <!-- Add a transformer to exclude any other manifest files (possibly from dependencies). -->
                        <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                            <resource>MANIFEST.MF</resource>
                        </transformer>

                        <!-- Add a transformer to include your custom manifest file. -->
                        <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                            <resource>META-INF/MANIFEST.MF</resource>
                            <file>META-INF/MANIFEST.MF</file>
                        </transformer>

                    </transformers>
                <!-- Filename produced will be driftdetector.jar to be consistent with
                     Boot-Class-Path in MANIFEST.MF file -->
                <finalName>${project.artifactId}</finalName>
            </configuration>
        </plugin>
    </plugins>
</build>

<pluginRepositories>
    <pluginRepository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </pluginRepository>
</pluginRepositories>

`

Here is the stack trace of the error I get on application execution.

`java.lang.NoClassDefFoundError: Could not initialize class com.netflix.hystrix.HystrixCommandMetrics

at com.netflix.hystrix.AbstractCommand.initMetrics(AbstractCommand.java:239)
at com.netflix.hystrix.AbstractCommand.<init>(AbstractCommand.java:165)
at com.netflix.hystrix.HystrixCommand.<init>(HystrixCommand.java:142)
at com.netflix.hystrix.HystrixCommand.<init>(HystrixCommand.java:128)
at com.abc.qbdt.validation.utils.HttpCommandExecutor.<init>(HttpCommandExecutor.java:18)
at com.abc.qbdt.validation.data.AbstractHttpConnector._doExecute(AbstractHttpConnector.java:47)
at com.abc.qbdt.validation.data.AbstractHttpConnector.execute(AbstractHttpConnector.java:33)
at com.abc.qbdt.validation.service.AccountValidationImpl.sendEmailusingTxE(AccountValidationImpl.java:216)
at com.abc.qbdt.validation.ValidateLicenseTest.sendMailTest(ValidateLicenseTest.java:31)
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 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:200)
at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:175)
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 org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:212)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:707)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
at org.testng.SuiteRunner.run(SuiteRunner.java:254)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)`
preetigupta25 commented 6 years ago

Anyone there?