Getting 404 from microservices in gateway front - jhipster

I've created a microservices architecture following jhipster instructions. I have a gateway, the registry and a simple microservice. After that i've called the entity sub-generator in the gateway to generate the front-end code for the microservice.
After doing that, I can propertly create/list/update the microservice resources from the Administration-API section in the gateway, but in the 'Entities' section (via front-end) i'm getting a 404 in all the microservices requests.
The 3 apps are running in dev profile, and the jwt secret token is the same for all of them: my-secret-token-to-change-in-production. I have not touched the config ymls.
¿What could be the problem? 404 is not a security problem ¿Isn't it? ¿Maybe the problem is the proxy? I'm behind a proxy.
I follow the Julien Dubois video, https://www.youtube.com/watch?v=dOO-8cAKDu8 and he just re-generate the entity in the gateway to access the front-end via 'Entities' menu (minute 33 aprox).
Thank you!
Gateway generator options:
{
"generator-jhipster": {
"jhipsterVersion": "3.6.1",
"baseName": "testgw",
"packageName": "com.test.app",
"packageFolder": "com/test/app",
"serverPort": "8080",
"authenticationType": "jwt",
"hibernateCache": "hazelcast",
"clusteredHttpSession": "no",
"websocket": "no",
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": "elasticsearch",
"buildTool": "maven",
"jwtSecretKey": "92bc8dd1e1cb0aacacfebe994abfb472862c512d",
"useSass": true,
"applicationType": "gateway",
"testFrameworks": [
"gatling",
"cucumber",
"protractor"
],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "es",
"languages": [
"es",
"en"
]
}
}
Microservice generator options:
{
"generator-jhipster": {
"jhipsterVersion": "3.6.1",
"baseName": "patient",
"packageName": "com.test.app",
"packageFolder": "com/test/app",
"serverPort": "8081",
"authenticationType": "jwt",
"hibernateCache": "hazelcast",
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": "elasticsearch",
"buildTool": "maven",
"jwtSecretKey": "f9e757eb9259f0cfd8886bb08beda392463a4391",
"enableTranslation": true,
"applicationType": "microservice",
"testFrameworks": [
"gatling",
"cucumber"
],
"jhiPrefix": "jhi",
"skipClient": true,
"skipUserManagement": true,
"nativeLanguage": "es",
"languages": [
"es",
"en"
]
}
}

Related

jhipster v7.9.0 got error when generate the project

I was trying to create the project using the following .yo-rc.json file:
{
"generator-jhipster": {
"applicationType": "monolith",
"authenticationType": "jwt",
"baseName": "baby",
"blueprints": [],
"buildTool": "maven",
"cacheProvider": "ehcache",
"clientFramework": "angularX",
"clientPackageManager": "npm",
"clientTheme": "none",
"clientThemeVariant": "",
"creationTimestamp": 1659322452305,
"cypressAudit": false,
"cypressCoverage": true,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"devServerPort": 4200,
"dtoSuffix": "DTO",
"enableGradleEnterprise": false,
"enableHibernateCache": true,
"enableSwaggerCodegen": false,
"enableTranslation": true,
"entitySuffix": "",
"jhiPrefix": "jhi",
"jhipsterVersion": "7.9.0",
"jwtSecretKey": "ZDkzZDZjZmFiYjljYTU4YzQ3MzI1ZDlmMTkxMTZkZjVlMzg3OWVlNDgwNzY3ZmQ5ZjcyNmUzYmFmOTc2ODcwMGZlZjRhZTgwZTQ4MDkyMGMxZDcyOGNmNTI3ZTU1YmRkZDA2M2MxNjEwODcyZWJhYzdhZWMyNjJlZGJhNzY3MDY=",
"languages": ["en", "pt-br"],
"messageBroker": false,
"microfrontend": false,
"microfrontends": [],
"nativeLanguage": "en",
"otherModules": [],
"packageName": "com.mamazinha.baby",
"pages": [],
"prodDatabaseType": "postgresql",
"reactive": false,
"searchEngine": false,
"serverPort": "8080",
"serverSideOptions": [],
"serviceDiscoveryType": "no",
"skipCheckLengthOfIdentifier": false,
"skipFakeData": false,
"skipUserManagement": false,
"testFrameworks": ["cypress"],
"websocket": false,
"withAdminUi": true
}
}
I run the jhipster command on windows 10 at the powershell. I 've got the following error message:
PS C:\Users\Blog\Documents\Projects\_ERROR_v7.9.0_mamazinha-monolithic> npm run clean-www
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
> baby#0.0.1-SNAPSHOT clean-www
> rimraf target/classes/static/app/{src,target/}
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\Blog\Documents\Projects\_ERROR_v7.9.0_mamazinha-monolithic
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Blog\AppData\Local\npm-cache\_logs\2022-08-01T05_45_51_701Z-debug-0.log
The solution
It doesn't work if you run npm run clean-www command from windows powershell! After I run it using git bash on windows it all works out!
After that, I tried the hipster command at git bash and everything works fine!

babel-jest doesn't correctly run on jest

I have a folder of code that functions as a plugin, so it is a subdirectory of a main directory. The main directory correctly runs the tests that use import statements, but the subfolder does not. The subfolder has its own .babelrc they are posted below.
.babelrc
{
"presets": [
"#babel/preset-env"
],
"plugins": [
["#babel/plugin-proposal-decorators", { "legacy": true }],
"#babel/plugin-proposal-function-sent",
"#babel/plugin-proposal-export-namespace-from",
"#babel/plugin-proposal-numeric-separator",
"#babel/plugin-proposal-throw-expressions",
"#babel/plugin-proposal-class-properties",
"#babel/plugin-transform-runtime",
"#babel/plugin-transform-modules-commonjs",
[
"module-resolver",
{
"alias": {
"example-lib": "./src"
}
}
]
],
"env": {
"test": {
"presets": [
[
"#babel/preset-env",
{
"modules": "commonjs"
}
]
]
}
}
}
package.json
"jest": {
"transform": {
"^.+\\.jsx?$": "babel-jest"
}
}
"devDependencies": {
"#babel/core": "^7.3.4",
"#babel/plugin-transform-modules-commonjs": "^7.2.0",
"#babel/preset-env": "^7.3.4",
"example-lib": "^0.11.4",
"babel-jest": "^24.5.0"
},
jest --debug
{
"configs": [
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "/private/var/folders/y6/prqm_t9s177bp3zhfyc1czbr0000gn/T/jest_dx",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"cwd": "/Users/user/development/repo/lib/plugin",
"dependencyExtractor": null,
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"filter": null,
"forceCoverageMatch": [],
"globalSetup": null,
"globalTeardown": null,
"globals": {},
"haste": {
"computeSha1": false,
"providesModuleNodeModules": []
},
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
"js",
"json",
"jsx",
"ts",
"tsx",
"node"
],
"moduleNameMapper": {},
"modulePathIgnorePatterns": [],
"name": "d855449ce7629afe8ca2c6248201816b",
"prettierPath": "prettier",
"resetMocks": false,
"resetModules": false,
"resolver": null,
"restoreMocks": false,
"rootDir": "/Users/user/development/repo/lib/plugin",
"roots": [
"/Users/user/development/repo/lib/plugin"
],
"runner": "jest-runner",
"setupFiles": [],
"setupFilesAfterEnv": [],
"skipFilter": false,
"snapshotSerializers": [],
"testEnvironment": "/Users/user/development/repo/lib/node_modules/jest-environment-jsdom/build/index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"**/__tests__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[tj]s?(x)"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": [],
"testRunner": "/Users/user/development/repo/lib/node_modules/jest-jasmine2/build/index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"^.+\\.jsx?$",
"/Users/user/development/repo/lib/node_modules/jest-config/node_modules/babel-jest/build/index.js"
]
],
"transformIgnorePatterns": [
"/node_modules/"
],
"watchPathIgnorePatterns": []
}
],
"globalConfig": {
"bail": 0,
"changedFilesWithAncestor": false,
"collectCoverage": false,
"collectCoverageFrom": null,
"coverageDirectory": "/Users/user/development/repo/lib/plugin/coverage",
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"coverageThreshold": null,
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"expand": false,
"filter": null,
"globalSetup": null,
"globalTeardown": null,
"listTests": false,
"maxConcurrency": 5,
"maxWorkers": 7,
"noStackTrace": false,
"nonFlagArgs": [],
"notify": false,
"notifyMode": "failure-change",
"passWithNoTests": false,
"projects": null,
"rootDir": "/Users/user/development/repo/lib/plugin/",
"runTestsByPath": false,
"skipFilter": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testResultsProcessor": null,
"updateSnapshot": "new",
"useStderr": false,
"verbose": null,
"watch": false,
"watchman": true
},
"version": "24.1.0"
}
The error itself:
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/Users/user/development/repo/lib/plugin/test/SystemDataService.spec.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { example } from './helpers';
^
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (../../node_modules/jest-runtime/build/ScriptTransformer.js:440:17)

I am not able to use jhipster microservice without registry. .yo-rc.json file

`{
"generator-jhipster": {
"promptValues": {
"packageName": "com.xyz.service",
"nativeLanguage": "en"
},
"jhipsterVersion": "5.0.0-beta.3",
"applicationType": "microservice",
"baseName": "MicroServiceStarterKit",
"packageName": "com.xyz.service",
"packageFolder": "com/xyz/service",
"serverPort": "8082",
"authenticationType": "jwt",
"cacheProvider": "hazelcast",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "postgresql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSwaggerCodegen": false,
"jwtSecretKey": "token",
"enableTranslation": false,
"testFrameworks": [],
"jhiPrefix": "jhi",
"nativeLanguage": "en",
"languages": [
"en"
],
"clientPackageManager": "yarn",
"skipClient": true,
"skipUserManagement": true
}
}`
when I run ./mvnw command it shows application is running. The url http://localhost:8082 is not accessible and throws 404 error. When I use serviceDiscoveryType property as eureka it works fine and index.html open
When disabling service discovery in a microservice, the microservice uses a context-path. In your case, the microservice will be available at:
http://localhost:8082/MicroServiceStarterKit

Unable to login on my jhipster 4 project with uaa, a microservice and a gateway and running with consul

I've generated a jhipster 4 project with uaa, a microservice and a gateway and running with consul. All start well but i'm unable to login
Error:
Filter: Access Control: allowing access for /uaa/api/account, as no access control policy has been set up for service: uaa
Error during filtering
/uaa/api/account [HTTP/1.1 401 Unauthorized
...
com.netflix.zuul.exception.ZuulException: Forwarding error
Caused by: java.net.SocketTimeoutException: Read timed out
Here .yo-rc.json file for uaa server
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp",
"nativeLanguage": "fr"
},
"jhipsterVersion": "4.3.0",
"baseName": "uaa",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "9999",
"authenticationType": "uaa",
"hibernateCache": "hazelcast",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "consul",
"buildTool": "maven",
"enableSocialSignIn": false,
"enableTranslation": true,
"applicationType": "uaa",
"testFrameworks": [
"gatling",
"cucumber"
],
"jhiPrefix": "jhi",
"skipClient": true,
"nativeLanguage": "fr",
"languages": [
"fr"
],
"clientPackageManager": "yarn"
}
}
Here .yo-rc.json file for my microservice
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp",
"nativeLanguage": "fr"
},
"jhipsterVersion": "4.3.0",
"baseName": "resource",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8081",
"authenticationType": "uaa",
"uaaBaseName": "uaa",
"hibernateCache": "hazelcast",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "consul",
"buildTool": "maven",
"enableSocialSignIn": false,
"jwtSecretKey": "1eada7e399535cfc724344c47d3dae65e47455a1",
"enableTranslation": true,
"applicationType": "microservice",
"testFrameworks": [
"gatling",
"cucumber"
],
"jhiPrefix": "jhi",
"skipClient": true,
"skipUserManagement": true,
"nativeLanguage": "fr",
"languages": [
"fr",
"en"
],
"clientPackageManager": "yarn"
}
}
Here .yo-rc.json file for my gateway
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp",
"nativeLanguage": "fr"
},
"jhipsterVersion": "4.3.0",
"baseName": "gateway",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8080",
"authenticationType": "uaa",
"uaaBaseName": "uaa",
"hibernateCache": "hazelcast",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"serviceDiscoveryType": "consul",
"buildTool": "maven",
"enableSocialSignIn": false,
"clientFramework": "angular2",
"useSass": true,
"clientPackageManager": "yarn",
"applicationType": "gateway",
"testFrameworks": [
"gatling",
"cucumber",
"protractor"
],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "fr",
"languages": [
"fr",
"en"
]
}
}

I have to create same Jhipster yo.rc.json as in my old project

I am working on rebuild the same jhipster application as previous one bcoz old project are having some problems.
The problem is that, project was created in version 2.1.27 and I have to create the same kind of project in 3.8.0. So, jhipster question and answer pattern is changed and I am confused what to answer to that question.
For Example : I had xauth authentication in my previous app. but while building new jhipster app I dont see any such kind of authentication there are three options: HTTP,OAUTH2 and JWT. what should I have to select. Further more I will share my old yo.rc.JSON can anybuddy guild me correct answer to build new jhipster yo.rc file
{
"generator-jhipster": {
"baseName": "myApp",
"packageName": "com.myApp.app",
"packageFolder": "com/myApp/app",
"authenticationType": "xauth",
"hibernateCache": "no",
"clusteredHttpSession": "no",
"websocket": "no",
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": "no",
"useSass": false,
"buildTool": "maven",
"frontendBuilder": "grunt",
"javaVersion": "7",
"enableTranslation": false,
"rememberMeKey": "c1a3776920bbeb376eeecd42e91cccdeaoada010"
}
}
You should use JWT authentication. This was changed in 3.0 https://github.com/jhipster/generator-jhipster/commit/2f017636700790aa5b38554da71fc27801b67cd3
Regarding migration of your full yo-rc.json, you have to try by yourself by generating new projects.
Few hints:
"frontendBuilder": "grunt", <-- we only support gulp now
"javaVersion": "7", <-- we only support java 8
"enableTranslation": false, <-- probably need to list languages
"rememberMeKey": "c1a3776920bbeb376eeecd42e91cccdeaoada010" <-- secret key maybe
{
"generator-jhipster": {
"jhipsterVersion": "3.8.0",
"baseName": "myApp",
"packageName": "com.myApp.app",
"packageFolder": "com/myApp/app",
"serverPort": "8081",
"authenticationType": "JWT",
"hibernateCache": "no",
"clusteredHttpSession": false,
"websocket": "spring-websocket",
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"buildTool": "maven",
"enableSocialSignIn": false,
"useSass": false,
"applicationType": "monolith",
"testFrameworks": [
"gatling"
],
"jhiPrefix": "jhi",
"enableTranslation": false
}
}
{
"generator-jhipster": {
"jhipsterVersion": "3.8.0",
"baseName": "myApp",
"packageName": "com.myApp.app",
"packageFolder": "com/myApp/app",
"serverPort": "8081",
"authenticationType": "JWT",
"hibernateCache": "no",
"clusteredHttpSession": false,
"websocket": "spring-websocket",
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"buildTool": "maven",
"enableSocialSignIn": false,
"useSass": false,
"applicationType": "monolith",
"testFrameworks": [
"gatling"
],
"jhiPrefix": "jhi",
"enableTranslation": false
}
}

Resources