我正在尝试将JHipster用于使用微服务的项目,但最新的JHipster Registry不会让我的网关或微服务访问配置服务器并拒绝它们。
我安装了JHipster Vagrant DevBox,然后使用docker run -p 8761:8761 jhipster/jhipster-registry
来运行JHipster注册表。
然后,我在this之后生成了一个网关和2个微服务,它起作用了。
但后来我想使用GitHub的JHipster注册表,所以我克隆了它并运行它(显然它在此期间已经更新到2.0.0)。遗憾的是,网关和微服务无法访问此注册表。他们仍然可以访问Docker镜像注册表(我想Docker没有更新它)。但由于它更加漂亮,而且可能更新,我想使用最新版本的注册表,与GitHub中的相同。所以我尝试用docker pull
更新Docker镜像Jhipster Registry。现在它不适用于任何一个注册表 - 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
在注册表的shell中我也得到了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版本的微服务,所以我也尝试直接将中心服务器配置的秘密复制到应用程序的配置,但显然无济于事。
你能帮我解决这个问题吗?
非常感谢你。
编辑:
我尝试使用npm install -g generator-jhipster
将JHipster更新为3.2.1,这显然有用,但是当我运行yo jhipster
时,Yeoman仍然使用JHipster 3.1.0。实际上,即使我用npm uninstall -g generator-jhipster
卸载JHipster,Yeoman仍然可以使用JHipster 3.1.0 ......
编辑:
如果我在本地重新安装所有内容(在我使用yo jhipster
的目录中),它可以正常工作。
但是,我还是无法在Yeoman全局更新JHipster。当我尝试使用npm install -g generator-jhipster
时,它将JHipster全局更新为3.2.1但是Yeoman仍然使用3.1.0。如果我尝试使用yo
/“更新您的生成器”/ 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 su
在我尝试运行yo
时给我这个:
/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 ......
答案 0 :(得分:4)
这是因为您将JHipster Registry升级到2.0.0版本。这个新版本是安全的,这就是为什么你有401&#34;未经认证的&#34;错误,因为您没有提供任何登录/密码来连接。
3个解决方案:
答案 1 :(得分:0)
当使用从使用IntelliJ IDEA本地运行的github中提取的最新JHipster Registry时,我发现了相同的行为 - 服务器将启动,但前端无法提供。
结果是运行/调试配置中的空白工作目录存在问题。一旦填充完毕,就可以从IDE中找到工作。