Hi i have installed jhipster 4.1.1 and im trying to create microservice and gateway applications, im using jhipster-registry, the microservice start ok, the gateway start ok, but when im trying to load localhost:8080, i obtained blank page, and no error on log.
whats happen?
Application 'clothes' is running! Access URLs:
Local: http://localhost:8080
External: http://192.168.56.1:8080
Profile(s): [swagger, dev]
----------------------------------------------------------
2017-04-06 11:15:17.186 INFO 6344 --- [ restartedMain] com.anelsoftware.clothes.ClothesApp :
----------------------------------------------------------
Config Server: Connected to the JHipster Registry config server!
----------------------------------------------------------
2017-04-06 11:19:58.930 INFO 6344 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
No entities were generated
You have to install all dependency manager, package manager and build tools for successfully run the JHipster app ( mvn, nvm, npm, bower, gulp ) before "yo jhipster" process.
If you have choose not stable version of Angular on generating process you have to change it or regenerate app.
For start JHipster app correctly you have to start 1-BackEnd mvnw or gradlew and 2-FrontEnd => yarn start.
Definitely the problem is Angular Beta, run gateway from springboot run and yarn start and works fine, now if only run springboot run does not work, any idea how to solve this?
I experience blank page when using MySQL on development.
The localhost:8080 is only for API request. With Angular, you access it on a different port.
Go to webpack.dev.js
Change the port to 9060
plugins: [
new BrowserSyncPlugin({
host: 'localhost',
port: 9060, // change this into 9060
proxy: {
target: 'http://localhost:9060'
}
}, {
reload: false
}),
and then access it on localhost:9060
I have found this with the latest JHipster (4.1.* and Angular 5).
My solution was to regenerate the application and everything worked.
Related
I have a Spring Boot application with MSSQL database. I would like to run github action and run tests for pull requests and merges to master. However I have problem with connecting to database from GA tests. My application uses YAML configuration and I have separate config file for CI tests.
Here is workflow:
name: Java CI with Maven
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
services:
mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
SA_PASSWORD: myPassword
ACCEPT_EULA: 'Y'
DBNAME: test
ports:
- 1433:1433
steps:
- uses: actions/checkout#v3
- name: Set up JDK 11
uses: actions/setup-java#v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -ntp -U clean test -P junit-ci
And junit-ci config file:
spring:
datasource:
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://mssql:1433;database=test;
username: sa
password: myPassword
And here is error:
[main] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Exception during pool initialization.
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host mssql, port 1433 has failed. Error: "mssql. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234)
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:285)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2434)
Suggest to use Testcontainers instead. This way it is the testcontainers Java library which takes care of starting a database to use it for Integration Testing. It is sooo much easier than the path you are currently on. IMHO.
Your GitHub Action YAML then becomes simpler. It will just be pure Maven actions. You also make your test code less dependent on GitHub Actions as your CI system.
Using Testcontainers has other advantages: Your test can have full control over the database (or the container in which it runs). For example you can have a test where you kill the container during the test, thereby similating the effect on your application on a database which suddenly is lost.
Btw: Strictly speaking, what you are attempting is not Unit Tests, but Integration Tests. Maven makes a distinction. It is advisable to make this distinction. Integration Tests are often quite heavy. By using Testcontainers approach the database container will only be started when you tell Maven to execute Integration Tests. In your example, the database container is always started, regardless if it is needed.
I have a Spring Boot app in Docker that runs on Heroku.
Recently, after updating Tomcat to 10.1.0-M10, I started getting this error:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within
60 seconds of launch
The immediate thought of downgrading to lower versions doesn't work due to vulnerabilities in the earlier versions. I have checked possible causes and found Tomcat binding port issue.
I cannot set up fixed config for different ports as I am deploying to Heroku and dependent on their random ports.
My Dockerfile:
FROM azul/zulu-openjdk-alpine:11
ENV PORT=$PORT
COPY /target/app.jar /app.jar
CMD java -Xms256m -Xmx512m \
-Dlog4j2.formatMsgNoLookups=true \
-Djava.security.egd=file:/dev/./urandom \
-Dserver.port=$PORT \
-jar /app.jar
What is the way to solve it? Is there anything I am missing?
UPDATE:
There are more logs from Heroku:
Feb 22 12:50:16 integration-test app/web.1 2022-02-22 20:50:16.057 [main] INFO c.g.s.z.ApplicationKt - Started ApplicationKt in 8.09 seconds (JVM running for 9.062)
Feb 22 12:50:16 integration-test app/web.1 2022-02-22 20:50:16.060 [main] DEBUG o.s.b.a.ApplicationAvailabilityBean - Application availability state LivenessState changed to CORRECT
Feb 22 12:50:16 integration-test app/web.1 2022-02-22 20:50:16.063 [main] DEBUG o.s.b.a.ApplicationAvailabilityBean - Application availability state ReadinessState changed to ACCEPTING_TRAFFIC
Feb 22 12:51:06 integration-test heroku/web.1 Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
I found a solution that wasn't perfect but seemed to work for me.
Downgraded Spring Boot from 2.6.3 to 2.6.1
Downgraded Tomcat from 10.X.X to 9.X.X
Removed dev tools dependencies
I think the two latest did the magic. Dev tools stopped asking for an extra port in the test/prod environment. Tomcat bound the port in the version 9.X.X but not in 10.X.X.
Even though I found the solution, I don't know why it behaved like this, and it isn't perfect security-wise.
from the error message it seems that $PORT is not resolved to any environment variable.
deploying to heroku you must use .env file to define env vars (you can't use docker run -e PORT=1234) see documentation
When you use heroku locally, you can set config vars in a .env file. When heroku local is run .env is read and each name/value pair is set in the environment. You can use this same .env file when using Docker: docker run -p 5000:5000 --env-file .env <image-name>
I'm trying to use a spring profile argument to run a jar file, the profile isn't working:
java -jar -Dspring.profiles.active="test" build/libs/moley2-0.0.1-SNAPSHOT.jar
Here is my application.yml file:
spring:
profiles: dev
server:
port:8000
---
spring:
profiles: test
server:
port:9000
The jar was created using gradle build in the projects root directory. Running the jar with the command provided starts on port 8080 so it seems like the profile isn't loading. I'm sure I'm missing something simple here as I'm new to gradle / spring. Thanks in advance for any suggestions.
The property server should be:
server:
port: 9000
Instead of:
server:
port:9000
A space is missing between the colon and the value.
Also notice that configuring the profile as:
spring:
profiles: dev
is deprecated since 2.4.0 version and should be replaced with:
spring:
config:
activate:
on-profile: dev
More info in the doc. Or a tutorial here.
I am trying to deploy a spring boot microservices application to Google App Engine from Bitbucket Pipelines. I am getting this below error after commiting the code,
INFO: Setting up environment.
echo "${KEY_FILE}" | base64 -d >> /tmp/key-file.json
gcloud auth activate-service-account --key-file /tmp/key-file.json --quiet --verbosity=warning
Activated service account credentials for: [testproject-iamserviceaccoun#testproject.iam.gserviceaccount.com]
gcloud config set project testproject --quiet --verbosity=warning
Updated property [core/project].
> *INFO: Starting deployment to GCP app engine...*
gcloud app --quiet deploy 'app.yaml' --verbosity=warning
**ERROR: (gcloud.app.deploy) [/opt/atlassian/pipelines/agent/build/app.yaml] does not exist.
✖ Deployment failed.**
Please help me to solve this issue. Build Tool used is Maven.
bitbucket-pipelines.yml:
pipelines:
default:
- step:
name: Deploy to Google cloud
deployment: test
script:
- pipe: atlassian/google-app-engine-deploy:0.7.3
variables:
KEY_FILE: $KEY_FILE
PROJECT: 'testproject'
src/main/appengine/app.yaml:
runtime: java
env: flex
handlers:
- url: /.*
script: this field is required, but ignored
You need to specify DEPLOYABLES in your bitbucket-pipelines.yml, pointing to the path of your app.yaml file.
pipelines:
default:
- step:
name: Deploy to Google cloud
deployment: test
script:
- pipe: atlassian/google-app-engine-deploy:0.7.3
variables:
KEY_FILE: $KEY_FILE
PROJECT: 'testproject'
DEPLOYABLES: src/main/appengine/app.yaml
Reference: https://bitbucket.org/atlassian/google-app-engine-deploy/src/master/
This is a Java Spring boot REST API application, using an index.html to present the UI web page to user.
When the index.html is displayed, it would trigger the logic from the Javascript/jQuery to make a REST api call(coded as below) to the backend service in the Java controller class to get 2 random generated numbers:
$.ajax({
url: "http://localhost:8080/multiplications/random"
The program is working fine when run it as a Spring Boot app in Eclipse!
However, it's not working after I used the .jar file to build a Docker image file then deployed it using Kubernetes/minikube(I'm new to Docker/Kubernetes).
here's the dockfile to build the image file using the .jar:
FROM openjdk:latest
ADD target/social-multiplication-v3-0.3.0-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar","app.jar"]
EXPOSE 8080
Here's the deployment.yaml file:
---
kind: Service
apiVersion: v1
metadata:
name: multiplicationservice
spec:
selector:
app: multiplication
ports:
- protocol: "TCP"
port: 80
targetPort: 8080
nodePort: 30001
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mdeploy
spec:
replicas: 1
selector:
matchLabels:
app: multiplication
template:
metadata:
labels:
app: multiplication
spec:
containers:
- name: multiplication
image: huxianjun/multiplication
ports:
- containerPort: 80
and the IP address of the host where the application being deployed in Kubernetes:
$ minikube ip
192.168.99.101
At the end, I can get to the index.html page from browser by folllowing URL:
http://192.168.99.101:30001/
The page is being displayed as expected - What NOT working is, the following REST api call didn't occur thus the 2 numbers not returned from the call and displayed on the page:
$.ajax({
url: "http://localhost:8080/multiplications/random"
My guess is, is it caused by the 'localhost' & the port'8080' not aligned with those port# defined in the deployment.yaml file? or even something conflict to the 'EXPOSE 8080' in the docfile?
In your case, you are calling the $.ajax command from your browser which is in your host machine, hence, those API calls will be sent from your local machine but not within your docker container.
To solve the problem, you can update the URL to be using http://192.168.99.101:30001/ like this
$.ajax({
url: "http://192.168.99.101:30001/multiplications/random"
Try run sudo lsof -i :8080, if you use linux. It'll show all your available ports. If you don't see 8080 port, your application's port aren't available and visible for your localhost. That's because Docker containers are "closed/isolated" for all external processes and files. Moreover, EXPOSE 8080 instruction in Dockerfile is not enough.
Try docker run -p 8080:8080 YOUR_CREATED_IMAGE_NAME. It will build redirection from docker container localhost:8080 to Your localhost:8080