paulc4 / microservices-demo

Demo application to go with Blog on spring.io
889 stars 830 forks source link

Needs build instructions #17

Closed JetForMe closed 6 years ago

JetForMe commented 7 years ago

I'm trying this demo on macOS. But you need some command-line build instructions. What gradle command do I invoke? I tried gradle jar, and that did something, but the results are in build/libs, not target.

Anyway, trying to run that jar, I get:

$ java -jar build/libs/microservices-demo-1.1.0.RELEASE.jar registration
no main manifest attribute, in build/libs/microservices-demo-1.1.0.RELEASE.jar

gradle build works better, but I get:

$ java -jar build/libs/microservices-demo-1.1.0.RELEASE.jar registration

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.0.RELEASE)

68646: INFO  RegistrationServer - No active profile set, falling back to default profiles: default
68646: WARN  ConfigurationClassPostProcessor - Cannot enhance @Configuration bean definition 'refreshScope' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
68646: INFO  DiscoveryJerseyProvider - Using JSON encoding codec LegacyJacksonJson
68646: INFO  DiscoveryJerseyProvider - Using JSON decoding codec LegacyJacksonJson
68646: INFO  DiscoveryJerseyProvider - Using XML encoding codec XStreamXml
68646: INFO  DiscoveryJerseyProvider - Using XML decoding codec XStreamXml
68646: WARN  AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
68646: ERROR SpringApplication - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1076)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:851)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
    at io.pivotal.microservices.services.registration.RegistrationServer.main(RegistrationServer.java:26)
    at io.pivotal.microservices.services.Main.main(Main.java:36)
    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:497)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58)
Caused by: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:603)
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:443)
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:424)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:310)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
    ... 25 common frames omitted
Caused by: java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
    at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187)
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:600)
    ... 32 common frames omitted
JetForMe commented 7 years ago

Updating spring-boot to 1.4.3.RELEASE seems to fix the exceptions.

Amalraj7692 commented 7 years ago

Hi JetForMe, where have you updated the Spring-Boot version. In the pom.xml ?

JetForMe commented 7 years ago

I was using Gradle, so it would've been in the gradle build file.

Amalraj7692 commented 7 years ago

But I am trying to do from Eclipse IDE.

paulc4 commented 7 years ago

You will need to modify the pom.xml to use a later version of the spring-cloud parent. Try changing Brixton.RELEASEtoCamden.SR6.

--

Alternatively look at the maven dependency XML on the Spring Cloud project page: http://projects.spring.io/spring-cloud/

It takes a different approach, importing Spring Boot 1.4.5 as the parent and using Spring Cloud as a BOM (the dependencyManagement section).

Either way you will need to run Maven -> Update Project in Eclipse once you've updated the pom.xml.

On 21 March 2017 at 20:41, Amalraj7692 notifications@github.com wrote:

But I am trying to do from Eclipse IDE.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/paulc4/microservices-demo/issues/17#issuecomment-288025160, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkXgrc_ZtPCPd3tMp8IumkcsUQu-nkDks5rn5tDgaJpZM4LVLMa .

Amalraj7692 commented 7 years ago

Hi Paul, I didnt notice your reply.

But yes, I have modified the release as Camden.Release and it worked like a charm.

Thanks a ton.

javiqm12 commented 7 years ago

Upgrading to Camden.RELEASE and updating the build.gradle as described in https://spring.io/blog/2016/09/26/spring-cloud-camden-release-and-brixton-sr6-are-available did the work for me. UPDATE: Even simpler in gradle.properties change pringBootVersion=1.4.0.RELEASE to springBootVersion=1.4.5.RELEASE

paulc4 commented 6 years ago

Have added note that gradle clean assemble can be used as an alternative to mvn clean package.