Jhipster application hangs on Pivotal Cloud Foundry after printing banner - jhipster

I've created a JHipster application using the following
yo jhipster
yo jhipster:cloudfoundry
However, when I push to PCF, the app starts, hangs after printing the banner and gets killed after a minute.
The only customization I've tried is changing the URLs in some properties to point to a JHipster registry deployed on cloudfoundry as described in the jhipster documentation.
This is my .yo-rc.json file:
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp"
},
"jhipsterVersion": "4.3.0",
"baseName": "test",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8081",
"authenticationType": "jwt",
"hibernateCache": "hazelcast",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "gradle",
"enableSocialSignIn": false,
"jwtSecretKey": "bec0ab8352f04338c8c1db2fd572022c1bf877fe",
"enableTranslation": false,
"applicationType": "microservice",
"testFrameworks": [],
"jhiPrefix": "jhi",
"skipClient": true,
"skipUserManagement": true,
"clientPackageManager": "yarn"
}
}

The app needed to be correctly configured to use the registry as described in JHipster Documentation: Doing Microservices.
In the bootstrap-prod.yml file, the spring.cloud.config.uri must point to http:///config/
In the application-prod.yml file, the eureka.client.serviceUrl.defaultZone must point to http:///eureka/
By default, the JHipster registry is authenticated with an admin:admin user, so the files above also need to be configured as described in the Spring Cloud docs.
spring:
cloud:
config:
uri: https://myconfig.mycompany.com
username: user
password: secret

Related

Unexpected search results from Azure Cognitive Search

I recently developed an index on Azure. I have the following index structure:
{"name": "my_index",
"fields":
[
{"name": "id", "type": "Edm.String", "filterable": true, "key": true, "searchable": true, "sortable": true, "facetable": false},
{"name": "metadata_storage_path", "type": "Edm.String", "searchable": false, "filterable": false, "retrievable": true, "sortable": false, "facetable": false},
{"name": "Name", "type": "Edm.String", "searchable": true, "retrievable": true, "filterable": true, "sortable": false, "facetable": true, "analyzer": "en.microsoft"},
{"name": "Description", "type": "Edm.String", "searchable": true, "retrievable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "en.microsoft"},
{"name": "Content", "type": "Edm.String", "searchable": true, "retrievable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "en.microsoft"}
}
When I try to search an entire phrase, for example, "cloud platform", I get some top results without any mention of "cloud platform" which is a bit strange. When I then look at the search.score, even the top results have very low score like 0.07. However, I could see the phrases appearing in the documents and I expect to have enough documents containing the phrase.
Does anyone know why that might be the case? Is it because I used the wrong analyzer?
Any potential tests I can try would also be hugely appreciated.
are you querying using REST or SDK, in both cases an example request will help to understand your issue better.
If I were doing this using REST it will be like this
https://<yourserviceName>.search.windows.net/indexes/<yourIndexName>/docs?api-version=2020-06-30&search=*&%24filter=description%20eq%20'cloud platform'
Note to make sure the exact match happens I am using filter instead of search.

Incorrect version of jest trying to run jest

I have jest tests in my angular project.
I have a package.json file specifying the version of jest I would like to use to run the test. The file includes:
"#types/jest": "^24.0.18",
"jest": "^24.9.0",
"jest-preset-angular": "^7.1.1",
The jest config also includes:
"setupFilesAfterEnv": [
"<rootDir>/setup-jest.ts"
],
This is where the issue occurs. When trying to run jest, I get the following message:
● Validation Warning:
Unknown option "setupFilesAfterEnv" with value ["<rootDir>/setup-jest.ts"] was found.
This is probably a typing mistake. Fixing it will remove this message.
Configuration Documentation:
https://jestjs.io/docs/configuration.html
I had a look at jest -h and found a flag which gives me the setup of the jest environment.
jest --showConfig
This however shows that I am running jest on version
"version": "23.6.0"
So my question lies here. How come after I do an npm i, the jest version trying to run the tests is different / old.
I tried installing jest-cli with the -g flag and the save-dev flag.
Also trying to run tests in VS Code, if thats any help.
Please help.
Thank you in advance.
Full log of npx jest --showConfig
● Validation Warning:
Unknown option "setupFilesAfterEnv" with value ["<rootDir>/setup-jest.ts"] was found.
This is probably a typing mistake. Fixing it will remove this message.
Configuration Documentation:
https://jestjs.io/docs/configuration.html
{
"configs": [
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "/var/folders/bs/wrvrgl6132df8l5ndxv40m3m0000gn/T/jest_dx",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"/node_modules/",
"setup-jest.ts"
],
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"filter": null,
"forceCoverageMatch": [],
"globals": {
"ts-jest": {
"tsConfig": "<rootDir>/tsconfig.spec.json",
"stringifyContentPathRegex": "\\.html$",
"astTransformers": [
"jest-preset-angular/InlineHtmlStripStylesTransformer"
]
}
},
"haste": {
"providesModuleNodeModules": []
},
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
"ts",
"html",
"js",
"json"
],
"moduleNameMapper": [
[
"#app/(.*)",
"/Users/name/Projects/project/src/app/$1"
],
...
],
"modulePathIgnorePatterns": [],
"name": "6caa4...",
"prettierPath": "/Users/name/Projects/project/node_modules/prettier/index.js",
"resetMocks": false,
"resetModules": false,
"resolver": null,
"restoreMocks": false,
"rootDir": "/Users/name/Projects/project",
"roots": [
"/Users/name/Projects/project"
],
"runner": "jest-runner",
"setupFiles": [],
"setupTestFrameworkScriptFile": null,
"skipFilter": false,
"snapshotSerializers": [],
"testEnvironment": "/Users/name/Projects/project/node_modules/jest-environment-jsdom-thirteen/build/index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"**/__tests__/**/*.js?(x)",
"**/?(*.)+(spec|test).js?(x)"
],
"testRegex": "",
"testRunner": "/Users/name/node_modules/jest-jasmine2/build/index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"^.+\\.(ts|js|html)$",
"/Users/name/Projects/project/node_modules/ts-jest/dist/index.js"
]
],
"watchPathIgnorePatterns": []
}
],
"globalConfig": {
"bail": false,
"changedFilesWithAncestor": false,
"collectCoverage": true,
"collectCoverageFrom": null,
"coverageDirectory": "/Users/name/Projects/project/coverage",
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"coverageThreshold": null,
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"expand": false,
"filter": null,
"globalSetup": null,
"globalTeardown": null,
"listTests": false,
"maxWorkers": 7,
"noStackTrace": false,
"nonFlagArgs": [],
"notify": false,
"notifyMode": "always",
"passWithNoTests": false,
"projects": null,
"rootDir": "/Users/name/Projects/project",
"runTestsByPath": false,
"skipFilter": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testResultsProcessor": null,
"updateSnapshot": "new",
"useStderr": false,
"verbose": null,
"watch": false,
"watchman": true
},
"version": "23.6.0"
}
Showing npm config get log here too:
; cli configs
metrics-registry = "http://.../.../npm-group/"
scope = ""
user-agent = "npm/6.9.0 node/v10.15.3 darwin x64"
; project config /Users/user/Projects/project/.npmrc
registry = "http://.../.../npm-group/"
; node bin location = /Users/user/.nvm/versions/node/v10.15.3/bin/node
; cwd = /Users/user/Projects/project
; HOME = /Users/user
; "npm config ls -l" to show all defaults.
I had the same issue, after a long search I've tried this:
type jest
Which gave me the location:
/usr/local/bin/jest
Renaming this file (or deleting it), solved the problem (note that now running jest will give command not found).

Microservice Backend project with Jhipster 4.3.0 does not create User tables

Microservice Backend project with Jhipster 4.3.0 does not create User tables (jhi_user, jhi_authotity, jhi_user_authority) only (jhi_persistent_audit-event, jhi_persistent_audit-event_data) are created
Here is the result of command: yo jhipster:info
Welcome to the JHipster Information Sub-Generator
##### **JHipster Version(s)**
```
`enter code here`D:\.....\git\dolly-ms-app-consul\dolly-backend
`-- generator-jhipster#4.3.0
### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
```yaml
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp",
"nativeLanguage": "fr"
},
"jhipsterVersion": "4.3.0",
"baseName": "dollybackend",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8081",
"authenticationType": "jwt",
"hibernateCache": "hazelcast",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "consul",
"buildTool": "maven",
"enableSocialSignIn": false,
"jwtSecretKey": "aa600103f58d769cb4077acccbf8bdfc276b0eb2",
"enableTranslation": true,
"applicationType": "microservice",
"clientPackageManager": "yarn",
"testFrameworks": [
"gatling",
"cucumber"
],
"jhiPrefix": "jhi",
"skipClient": true,
"skipUserManagement": true,
"nativeLanguage": "fr",
"languages": [
"fr",
"en"
]
}
}
```
##### **Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**
Client.json
```yaml
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "idClient",
"fieldType": "BigDecimal",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "numeroCniClient",
"fieldType": "BigDecimal",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "dateNaisClient",
"fieldType": "LocalDate",
"fieldValidateRules": [
"required"
]
},
],
"changelogDate": "20170511190126",
"javadoc": "Customer entity.\n#author The JHipster team.",
"entityTableName": "client",
"dto": "mapstruct",
"pagination": "pager",
"service": "serviceImpl"
}
CompteBancaire.json ```yaml {…}
Transaction.json ```yaml {….}
TypeCompteBancaire.json ```yaml {….}
TypeTransaction.json ```yaml {….}
```
##### **Browsers and Operating System**
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
git version 2.12.2.windows.2
node: v7.3.0
npm: 3.10.10
bower: 1.8.0
gulp:[09:46:49] CLI version 3.9.1
yarn: 0.23.4
Docker version 17.03.1-ce, build c6d412e
docker-compose version 1.11.1, build 7afaa436
With jhipster microservices, your users won't be stored in every microservices. They should be stored in one microservice and referenced loosely by identifier. Notice that your output has
"skipClient": true,
"skipUserManagement": true
This will be a backend microservice and if your microservice needs the user, its identifier can be found in the JWT that gets passed as an authorization header and (I think) gets set in your spring security principal.

Monolithic app and load balancing by F5

Can we use an F5 load balancer to scale monolithic jhipster application?
On https://jhipster.github.io/security/ it is mentioned that we can
scale application on several different servers using JWT.
Are there any tips to do this, or we can just load balance it by directing the user on different instance of the app?
Regards.
Here is the .yo-rc.json :
{
"generator-jhipster": {
"jhipsterVersion": "3.12.1",
"baseName": "app",
"packageName": "com.example.app",
"packageFolder": "com/example/app",
"serverPort": "8080",
"authenticationType": "jwt",
"hibernateCache": "ehcache",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "postgresql",
"searchEngine": false,
"messageBroker": false,
"buildTool": "maven",
"enableSocialSignIn": false,
"jwtSecretKey": "**",
"useSass": false,
"applicationType": "monolith",
"testFrameworks": [
"gatling"
],
"jhiPrefix": "jhi",
"otherModules": [
{
"name": "generator-jhipster-entity-audit",
"version": "2.2.2"
}
],
"enableTranslation": true,
"nativeLanguage": "fr",
"languages": [
"fr"
]
}
}
short answer: yes, you can simply scale your application to several instances running in parallel, and the user won't notice any difference
precise answer: the key difference between JWT and classical stateful approach, like HTTP Session with cookies, is that there is no need to store the user session server side, as the interesting information is already contained inside a JWT. When your user is logging in, the JHipster application returns a JSON Webtoken, containing all permissions and principal data of the user, signed with the secret key. Using this secret key, every instance of your application can verify the JWT is correct.

oauth not working with jhipster

after generating a jhipster application (folowing the tutorial), the application runs well but I cannot login with my 'user' or 'admin' account. I see the following in the log:
[DEBUG] com.chomnoue.jstarter2.security.UserDetailsService - Authenticating jhip
sterapp
meaning that the application is trying to authenticate "jhipsterapp" instead of "user".
Following is the content of my .yo-rc.json file
{
"generator-jhipster": {
"baseName": "jstarter",
"packageName": "com.chomnoue.jstarter",
"packageFolder": "com/chomnoue/jstarter",
"authenticationType": "token",
"hibernateCache": "hazelcast",
"clusteredHttpSession": "hazelcast",
"websocket": "atmosphere",
"databaseType": "sql",
"devDatabaseType": "h2Memory",
"prodDatabaseType": "mysql",
"useCompass": true,
"frontendBuilder": "grunt",
"javaVersion": "8"
}
}
any help please?

Resources