Actually i'm developing a restful API
with spring boot
and I use insomnia as a client to test the modifications made on my entities.
When running the application with tomcat an error message is displayed:
FAILED TO START APPLICATION
Description:
Failed to configure a DataSource: 'url' attribute is not specified and
no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class.
I made the necessary configuration in the file "application.properties"
and I did add the dependencies for the mysql and JPA connector in the pom.xml file.
Screenshot
you can test your application.yml validity ,I also meet this problem
the question:
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Related
Following other links I have tried all configurations including enabling jndi of embedded tomcat container. (A very good detailed like is: https://www.roytuts.com/spring-boot-jndi-datasource/) But the problem is that the DataSource is looked up against JNDI and I get follwoing exception:
Please note that From Spring 2.0.x Embedded configuration classes have changed.
Get:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial.
As for the question of JNDI lookup in Embedded tomcat is rare use case I am trying to simulate and reproduce a Database Connection Pooling Error in production and for that I have to use JavaConfig settings for Resource and DataSource both.
I am trying to run a Spring Batch application to create batch jobs.
My application.properties as shown below:
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:localhost;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=admin
spring.datasource.password=p#ssw0rd
spring.datasource.schema=schema-hsqldb.sql
The error I am getting is shown below:
Caused by: org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException: Property spring.datasource.schema with value 'class path resource [schema-hsqldb.sql]' is invalid: The specified resource does not exist.
As far as I know, the schema-hsqldb.sql exists in classpath /org/springframework/batch/core/schema-hsqldb.sql.
The Spring boot application works when I commented out spring.datasource.schema=schema-hsqldb.sql. Do I have to manually import the SQL scripts? If so, how do I do that?
Your issue is that you are using the H2 driver with the schema of HSQL. H2 and HSQL are different products. You need to use the schema of H2 as well:
spring.datasource.schema=/org/springframework/batch/core/schema-h2.sql
That said, you don't really need to configure the datasource for embedded databases with Spring Boot, the datasource will be automatically configured. Here is an excerpt from the Embedded Database Support section of the reference docs:
Spring Boot can auto-configure embedded H2, HSQL, and Derby databases. You need not provide any connection URLs. You need only include a build dependency to the embedded database that you want to use.
My Spring boot application won't know the database to be connected in prior, once before application deployment, the user will select the database to be connected, and places the jar in the server webinf(or probably some other repository path), and changes the externalized properties file, so that application connects to the database, I was trying giving the database dependency scope as provided, but getting class not found. What is the preferred approach for solving the issue?
You can run your Spring Boot bootJar like this:
java -cp your-jdbc-driver.jar -jar your-boot-jar.jar --spring.datasource.url=your:jdbc:url
I have spring boot application and it's basically a gradle project, so, I have below dependency added in my gradle file:
org.springframework.boot:spring-boot-gradle-plugin:1.5.1.RELEASE
Application gets deployed in embedded jetty server. I have following set of properties in application.properties for db connection polling:
spring.datasource.driver-class-name
spring.datasource.max-active
spring.datasource.max-idle
spring.datasource.min-idle
spring.datasource.validation-query
spring.datasource.name
I was referring to below two links:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.4-Configuration-Changelog
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.5-Configuration-Changelog
I came to know that some of the datasource properties which used in application.properties file in my application are removed starting sprint boot version 1.4 but issue they haven't mentioned what are the new properties to use. Like for tomcat server they have provided all set of properties but not for jetty server. I am facing some db related errors like 'too many connections' after my application run for sometime, my assumption is that datasource props I am currently using are not correct and should be replaced with correct values, but unfortunately I am unable to find correct property names.
Jetty doesn't have its own Pooling DataSource implementation. You can include HikariCP in your project and customise using the spring.datasource.hikari.* properties. With each property matching the bean properties that can be set on Hikari's datasource implementation.
Websphere 8.5.5.2
Trying to deploy spring boot application in to websphere server. I already made sure class loader policy is parent last. Issue seems because websphere may need some additional configuration to recognize war without any web.xml? Not sure. Getting below error.
Caused by: javax.xml.bind.JAXBException: ClassCastException: attempting to cast jar:file:/usr/WebSphere850/AppServer/endorsed_apis/jaxb-api.jar!/javax/xml/bind/JAXBContext.class
to
wsjar:file:/usr/WebSphere850/AppServer/profiles/node01/installedApps/dchislwsapp020Cell01/My%20Application%20Service%20-%20Test%20Service.ear/test-plan-rest.war/WEB-INF/lib/jaxb-api-2.2.11.jar!/javax/xml/bind/JAXBContext.class.Please make sure that you are specifying the proper ClassLoader.`
You should be able to do this by adding
DisableIBMJAXWSEngine: true
to your application's META-INF/MANIFEST.MF to disable it at the application level.
To disable it at the server level follow the directions at: http://www-01.ibm.com/support/knowledgecenter/SS7JFU_6.1.0/com.ibm.websphere.express.doc/info/exp/ae/twbs_thirdparty.html?cp=SS7JFU_6.1.0%2F1-7-9-4-1-14-0 to disable at the server level.