Not able to run my application : com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server - spring-boot

ISSUE WITH THE EUREKA SERVER
NOT ABLE TO RUN MY APPLICATION
Dependency ?
application.properties ?
APPLICATION.PROPERTIES
server.port=9866
eureka.client.service-url.default-zone=http://localhost:8761/eureka
eureka.client.fetch-registry=true
eureka.client.register-with-eureka=true
eureka.instance.prefer-ip-address=true
spring.datasource.url=jdbc:mysql://localhost:3306/ACC_ECOM_SCHEMA?useSSL=false
spring.datasource.username=root
spring.datasource.password=admin123
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
logging.level.root=warn
logging.level.org.springframework=error
logging.level.com.acc.ecom.user=error
logging.file.name=/tmp/logs/userservice.log
logging.file.max-size=10MB
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} - %msg%n
Scenario 1
when Eureka Server is Running
see the below Console image
Scenario 2
When Eureka Server is NOT Running
see the below Console image

Related

how to connect mysql server ubuntu spring boot?

phpmyadmin : http://streamloli.xyz:90/phpmyadmin/
Database :movie
my application.properties
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/movie
spring.datasource.username=root
spring.datasource.password=******
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
it is not working please show me how to connect to mysql server. Thank you

i implement spring security in apiGateway .The problem that zuul proxy allow all requests from other microservices

for example it allows all request form annoce-service.
this is application.properties API_Gate way (zuul proxy)
server.port=6039
spring.data.mongodb.uri=mongodb://localhost:27017/AccessRefreshToken
spring.data.mongodb.auto-index-creation=true
spring.application.name=API_GATEWAY
eureka.instance.prefer-ip-address=true
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=true
eureka.client.service-url.defaultZone=http://localhost:8761/eureka
spring.main.allow-circular-references=true
management.endpoints.routes.enabled=true
management.endpoints.web.exposure.include=*
zuul.routes.middleware.path=/ANNONCE_SERVICE/**
this application.properties of eureka
server.port= 8761
eureka.client.register-with-eureka= false
eureka.client.fetch-registry= false
and this is application.properties of an other to test the zuul
it is annoce service and this is his application.properties
server.port=6040
spring.application.name=ANNONCE_SERVICE
eureka.instance.prefer-ip-address=true
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/
what am'i making wrong ??

Unable to connect non stop SQL from Spring boot applivcation

My project uses non stop SQL/MX as RDBMS database, a product from HP.I am not able to connect to the data source using Spring Boot's standard practice of defining JDBC URL, user, password inside application.properties file.
spring.datasource.driverClassName = com.tandem.sqlmx.SQLMXDriver
spring.datasource.url = jdbc:sqlmx:
spring.datasource.username=
spring.datasource.password=
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SqlmxDialect
spring.datasource.hikari.connection-test-query=SELECT 1 FROM $USER1.TLFM3SQL.IF09CSTB
This is the error:
com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for
connections. (com.tandem.sqlmx.SQLMXConnection.getNetworkTimeout()I)
JdbcEnvironmentInitiator: could not obtain connection to query metadata: Unable to resolve name
[org.hibernate.dialect.SqlmxDialect ] as strategy [org.hibernate.dialect.Dialect]
I had not included SQLMX hibernate jar in project.
It worked after I included that jar in my pom.

Problem with port determination using spring cloud

I have created 2 instances of a microservice named InfyGo_Flights. I have put a yaml file in git hub with
server.port 9004. My properties file in MS is empty apart from application name. These 2 instances have 2 diff issues:
1.First I overrode in the config itself to take server.port as 9010. But still ran on 9004. I deleted the server.port in yaml in github. But this caused it to run into error. So replaced it with 9004 again. But now it has started running on 9010. Removing the overridden property causes it to run into error.
2.Second config I created after the first one was causing issue. But despite the yaml file in cloud config it runs on default 8080 port.
application.properties:
spring.application.name=InfyGo_Flights
bootstrap.properties
spring.cloud.config.uri=http://localhost:1111
management.endpoints.web.exposure.include
InfyGo_Flights.yml
spring:
application:
name: InfyGo_Flights
mvc:
view:
prefix: /WEB-INF/pages/
suffix: .jsp
datasource:
username: root
password:
url: jdbc:mysql://localhost:3307/mydb?serverTimezone=UTC
jpa:
show-sql: true
hibernate:
ddl-auto: update
properties:
hibernate:
dialect:
logging:
file: Errorlog.log
level:
root: info
com.infoys.ars: info
pattern:
file: "%d{yyyy-MM-dd HH:mm:ss,SSS} %5p [%t] %c [%M] - %m%n"
server:
port:9004
You will need to put a Whitespace between the port & 9004 so it get recognizable by the yaml file:
//wrong
port:9004
//right
port: 9004

RestController test fails with h2 database

I am trying to run a test to my RestController in my Spring boot application with h2 database.
Here is some code:
#RunWith(SpringRunner.class)
#SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
#ActiveProfiles("test")
public class E2E_EconomicOperatorAPIControllerTest {
#Autowired
private TestRestTemplate restTemplate;
#Test public void test_newEconomicOperator() {
//staff
}
}
But when I run it, i get this error:
2018-04-03 12:16:57.084 WARN 14332 --- [ Thread-7] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-196]
And here is my properties file:
spring.datasource.url=jdbc:h2:mem:testdb;MODE=Oracle;DB_CLOSE_DELAY=-1
logging.level.org.gso.admin=DEBUG
logging.level.gso.gd.client=INFO
logging.level.org.springframework.web.client=WARN
logging.level.org.springframework=WARN
logging.level.org.thymeleaf=WARN
logging.level.root=WARN
Actually, you shouldn't need to set any property for an embedded h2 database, as boot configures that for you (additionally, I think you should leave out the MODE=Oracle flag). Here's what I did:
Put the following dependendy in your .pom:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
Note the scope. This will load the dependency on your classpath during test (and nothing else). You should then make sure, that you have an application.properties file per environment, where you set the database wehnever you need a real one.
As an example from my app:
application-dev.properties: (note: I wanted a real db for dev, so i put in prostgres...)
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=validate
spring.database.driverClassname=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://192.168.1.100:5432/winecellar
spring.datasource.username=winecellar
spring.datasource.password=winecellar
application-test.properties:
spring.jpa.database=H2
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=none
spring.database.driverClassname=org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.datasource.username=sa
spring.datasource.password=
And I have a similar file for production settings (using postgres as well...)
Then, as long as you annotate it as you have done with #ActiveProfiles("test"), you should be fine.

Resources