Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including spring-cloud-starter-eureka-server in dependencies causes application startup to fail #255

Closed
sampengilly opened this issue Mar 13, 2015 · 6 comments
Labels

Comments

@sampengilly
Copy link
Contributor

Without "spring-cloud-starter-eureka-server" in the dependencies, the SpringApplication starts up without issue. When I add the eureka server starter to dependencies the SpringApplication fails during startup with the following stacktrace:

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
    at com.***********.******.eurekaserver.EurekaServerApplication.main(EurekaServerApplication.java:15)
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:98)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:75)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:378)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:155)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
    ... 7 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:340)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:88)
    ... 12 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 14 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 16 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:925)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 18 common frames omitted

Gradle file is as follows:

buildscript {
    ext {
        springBootVersion = "1.2.2.RELEASE"
        springRepo = "http://repo.spring.io/libs-release"
    }

    repositories {
        mavenCentral()
        maven { url springRepo }
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = "2.3"
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'application'

jar {
    baseName = 'eureka-server'
    version = '0.0.1-SNAPSHOT'
}

//noinspection GroovyUnusedAssignment
sourceCompatibility = 1.8
//noinspection GroovyUnusedAssignment
targetCompatibility = 1.8

springBoot {
    requiresUnpack = [
            'com.netflix.eureka:eureka-core',
            'com.netflix.eureka:eureka-client'
    ]
}

repositories {
    mavenCentral()
    maven { url springRepo }
}

dependencies {
    versionManagement "io.spring.platform:platform-versions:1.1.1.RELEASE@properties"

    compile("org.springframework.boot:spring-boot-starter")
    compile ('org.springframework.cloud:spring-cloud-starter-eureka-server:1.0.0.RELEASE') {
        exclude module: 'logback-classic'
    }

    testCompile("org.springframework.boot:spring-boot-starter-test")
}

eclipse {
    classpath {
        containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
        containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
    }
}

idea.module {
    inheritOutputDirs = false
    outputDir = file("$buildDir/classes/main")

    excludeDirs += [
            file("bin"),
            file("work"),
            file("logs"),
            file("data"),
            file(".settings")
    ]
}
@sampengilly
Copy link
Contributor Author

At this point my code only consists of the main application class, the only annotations on it are configuration and enable auto configuration. Adding enable eureka server annotations does not change the output above.

@dsyer
Copy link
Contributor

dsyer commented Mar 13, 2015

That stack trace actually isn't telling use anything. There will be one higher up the console causing this. My guess (since it works for me with Maven) is that you are falling foul of Gradle's idiosyncratic dependency resolution rules. You can use the https://github.com/spring-gradle-plugins/dependency-management-plugin with the spring-cloud-starter-parent as a bom, and I think it should fix the classpath.

@dsyer dsyer added the question label Mar 13, 2015
@sampengilly
Copy link
Contributor Author

That appears to have worked. Should a note be added to the docs about this idiosyncrasy? Or a Gradle version of the example project put together?

I'm happy to contribute time into doing either of these. I'll leave this issue open while I await a response.

@dsyer
Copy link
Contributor

dsyer commented Mar 16, 2015

There's already a pull request here: spring-cloud-samples/eureka#9 for one sample. If you want to add some Gradle snippets to the user guide that would be excellent too.

@alok001
Copy link

alok001 commented Dec 16, 2017

Hello Guys

I am new to spring boot and all was trying to configure eureka server. Below are details and error. Need help here

pom.xml


4.0.0

<groupId>com.Vehicle</groupId>
<artifactId>VehicleEureka-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>VehicleEureka-service</name>
<description>Demo project for Spring Boot</description>

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>1.5.9.RELEASE</version>
	<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	<java.version>1.8</java.version>
	<spring-cloud.version>Edgware.RELEASE</spring-cloud.version>
</properties>

<dependencies>
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter-eureka-server</artifactId>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
	</dependency>
</dependencies>

<dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-dependencies</artifactId>
			<version>${spring-cloud.version}</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>
<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>
	</plugins>
</build>

application main class

@EnableEurekaServer
@SpringBootApplication
public class VehicleEurekaServiceApplication {

public static void main(String[] args) {
	SpringApplication.run(VehicleEurekaServiceApplication.class, args);
}

}
application.properties
server.port=8070

application.yml
eureka:
client:
registerWithEureka: false
fetchRegistry: false

Error:
Post-processing of merged bean definition failed; nested exception is java.lang.NoClassDefFoundError: org/apache/http/config/RegistryBuilder

@spencergibb
Copy link
Member

@alok001 it's generally preferable to open a new issue if you think you've found a bug. I was unable to reproduce your error. If you can provide a full project (zip or github) that reproduces the problem, open a new issue.

Also,
Please learn how to properly format code and logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants