2

我正在尝试将 JHipster 用于使用微服务的项目,但最新的 JHipster Registry 不会让我的网关或微服务访问配置服务器并拒绝它们。

我安装了 JHipster Vagrant DevBox,然后用来docker run -p 8761:8761 jhipster/jhipster-registry运行 JHipster 注册表。然后,我在此之后生成了一个网关和 2 个微服务,并且它起作用了。

但是后来我想使用来自 GitHub 的 JHipster Registry,所以我克隆了它并运行了它(显然它同时已更新到 2.0.0)。遗憾的是,网关和微服务无法访问此注册表。不过,他们仍然能够访问 Docker 镜像注册表(我想 Docker 没有更新它)。但由于它更漂亮,而且可能更新,我想使用最新版本的注册表,与 GitHub 上的相同。所以我尝试用docker pull. 现在它不适用于任何一个注册表——Docker 镜像或 GitHub 克隆。

当注册表正在运行并且我运行网关或微服务时,我得到了 6 倍:

2016-05-10 15:39:07.511 DEBUG 20706 --- [           main] s.n.www.protocol.http.HttpURLConnection  : sun.net.www.MessageHeader@86ba8f5 pairs: {GET /config/gateway/dev/master HTTP/1.1: null}{Accept: application/json, application/*+json}{User-Agent: Java/1.8.0_91}{Host: localhost:8761}{Connection: keep-alive}
2016-05-10 15:39:07.522 DEBUG 20706 --- [           main] s.n.www.protocol.http.HttpURLConnection  : sun.net.www.MessageHeader@43c7802510 pairs: {null: HTTP/1.1 401 Unauthorized}{Server: Apache-Coyote/1.1}{X-Content-Type-Options: nosniff}{X-XSS-Protection: 1; mode=block}{Cache-Control: no-cache, no-store, max-age=0, must-revalidate}{Pragma: no-cache}{Expires: 0}{Content-Type: application/json;charset=UTF-8}{Transfer-Encoding: chunked}{Date: Tue, 10 May 2016 15:39:07 GMT}

然后我得到一个错误:

2016-05-10 15:39:13.781 ERROR 20706 --- [           main] o.s.boot.SpringApplication               : Application startup failed

然后我得到Java异常:

java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:110)
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator$$FastClassBySpringCGLIB$$fa44b2a.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.retry.interceptor.RetryOperationsInterceptor$1.doWithRetry(RetryOperationsInterceptor.java:74)
at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:263)
at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:154)
at org.springframework.retry.interceptor.RetryOperationsInterceptor.invoke(RetryOperationsInterceptor.java:101)
at org.springframework.retry.annotation.AnnotationAwareRetryOperationsInterceptor.invoke(AnnotationAwareRetryOperationsInterceptor.java:118)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator$$EnhancerBySpringCGLIB$$a0abff82.locate(<generated>)
at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:89)
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:640)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at com.soprasteria.example.GatewayApp.main(GatewayApp.java:73)
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.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:478)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:641)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:597)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:475)
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.getRemoteEnvironment(ConfigServicePropertySourceLocator.java:130)
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:81)
... 23 common frames omitted

[WARNING] 
java.lang.reflect.InvocationTargetException
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.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:478)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:110)
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator$$FastClassBySpringCGLIB$$fa44b2a.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.retry.interceptor.RetryOperationsInterceptor$1.doWithRetry(RetryOperationsInterceptor.java:74)
at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:263)
at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:154)
at org.springframework.retry.interceptor.RetryOperationsInterceptor.invoke(RetryOperationsInterceptor.java:101)
at org.springframework.retry.annotation.AnnotationAwareRetryOperationsInterceptor.invoke(AnnotationAwareRetryOperationsInterceptor.java:118)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator$$EnhancerBySpringCGLIB$$a0abff82.locate(<generated>)
at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:89)
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:640)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at com.soprasteria.example.GatewayApp.main(GatewayApp.java:73)
... 6 more
Caused by: org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:641)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:597)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:475)
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.getRemoteEnvironment(ConfigServicePropertySourceLocator.java:130)
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:81)
... 23 more

最后是BUILD FAILURE一个 Maven 错误:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.3.3.RELEASE:run (default-cli) on project gateway: An exception occurred while running. null: InvocationTargetException: Could not locate PropertySource and the fail fast property is set, failing: 401 Unauthorized -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

在注册表的外壳中,我也得到了这条线 6 次:

2016-05-10 15:39:07.519 DEBUG 17958 --- [io-8761-exec-10] i.g.j.r.s.Http401UnauthorizedEntryPoint  : Pre-authenticated entry point called. Rejecting access

我尝试更新所有内容,并且目前正在尝试降级(因为文档说“我们建议您使用与用于 JHipster 生成器的版本相同的版本标签”,但我认为它不会在 JHipster 之后工作Registry 的最新版本是 2.0.0,JHipster 生成器在 3.0 版本中引入了微服务),我也尝试直接从 central-server-config 复制秘密到应用程序的配置,但显然无济于事。

你能帮我解决这个问题吗?

非常感谢您提前。

编辑:

我尝试使用 将 JHipster 更新到 3.2.1 npm install -g generator-jhipster,这显然有效,但是当我运行时yo jhipster,Yeoman 仍然使用 JHipster 3.1.0。实际上,即使我用 卸载 JHipster npm uninstall -g generator-jhipster,Yeoman 仍然可以使用 JHipster 3.1.0...

编辑:

如果我在本地重新安装所有东西(在我使用的目录中yo jhipster),它工作正常。但是,我仍然无法在 Yeoman 中全局更新 JHipster。当我尝试使用npm install -g generator-jhipster时,它会将 JHipster 全局更新为 3.2.1,但 Yeoman 仍然使用 3.1.0。如果我尝试使用yo/"Update your generators"/generator-jhipster 更新 JHipster,我会收到错误消息:

npm WARN deprecated npmconf@2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/generator-jhipster
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
/usr/local/lib
└── generator-jhipster@3.2.1 

npm ERR! Linux 3.13.0-85-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "generator-jhipster"
npm ERR! node v4.4.4
npm ERR! npm  v3.8.9
npm ERR! path /usr/local/lib/node_modules/generator-jhipster
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/generator-jhipster'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/generator-jhipster']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/generator-jhipster' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/npm-debug.log

I've just updated your generators. Remember, you can update
a specific generator with npm by running:

    npm install -g generator-_______

当我尝试运行时,使用sudo会做同样的事情并给我这个:sudo suyo

/usr/local/lib/node_modules/yo/node_modules/configstore/index.js:53
                throw err;
                ^

Error: EACCES: permission denied, open '/root/.config/configstore/insight-yo.json'
You don't have access to this file.

    at Error (native)
    at Object.fs.openSync (fs.js:549:18)
    at Object.fs.readFileSync (fs.js:397:15)
    at Object.create.all.get (/usr/local/lib/node_modules/yo/node_modules/configstore/index.js:34:26)
    at Object.Configstore (/usr/local/lib/node_modules/yo/node_modules/configstore/index.js:27:44)
    at new Insight (/usr/local/lib/node_modules/yo/node_modules/insight/lib/index.js:37:34)
    at Object.<anonymous> (/usr/local/lib/node_modules/yo/lib/cli.js:163:11)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)

编辑:

好的,即使使用本地安装它也不起作用...网关确实可以访问注册表,但是当我尝试访问 localhost:8080 时它会显示一个调试页面。实际上,在生成过程中,我permission denied又得到了一个,并且缺少依赖项(gulp-rev)。

我刚刚看到这个:“使用标签拥有稳定版本是明智的:JHipster DevBox标签与JHipster Generator标签相同,因此使用DevBox v3.2.0也意味着使用生成器v3.2.0”上DevBox GitHub页面,所以也许我会删除并再次下载DevBox......

4

2 回答 2

4

这是因为您将 JHipster Registry 升级到了 2.0.0 版本。这个新版本是安全的,这就是为什么您有 401“未经身份验证”错误,因为您没有提供任何登录名/密码来连接。

3个解决方案:

  • 继续使用与您的 JHipster 版本匹配的旧 JHipster Registry 版本。
  • 将登录名/密码(默认为 admin/admin)添加到您的 Eureka 和 Spring Cloud Config URL。有关保护 JHipster Registry 的详细文档在这里- 在撰写本文时它不完整,但我会尽快更新它
  • 更新到 JHipster v3.2.1,这意味着与 JHipster Registry v2.0.0 一起使用,并且所有内容都将自动配置。
于 2016-05-11T06:22:32.593 回答
0

当使用从 github 中提取的最新 JHipster Registry 并在 IntelliJ IDEA 本地运行时,我发现了相同的行为——服务器将启动,但前端无法提供服务。

结果是运行/调试配置中的空白工作目录存在问题。一旦填充完毕,就可以从 IDE 中找到工作了。

于 2016-05-17T17:02:39.063 回答