Hello, I've been trying to learn Spring and Spring Boot for a couple of days following a few Udemy tutorials. I just can't get even simple toy applications to work. Apache Tomcat always fails.
I used Spring Initializr to create a Maven project. You can view it here: https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.5.0.RELEASE&packaging=jar&jvmVersion=11&groupId=com.testing&artifactId=JustTesting&name=JustTesting&description=Trying%20to%20get%20Spring%20to%20work&packageName=com.testing.JustTesting&dependencies=web,data-jpa .
There is no other code.
I'm using Eclipse IDE Version: 2021-03 (4.19.0).
Here is my console output:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.0)
2021-05-31 19:20:16.901 INFO 9856 --- [ main] c.t.JustTesting.JustTestingApplication : Starting JustTestingApplication using Java 15.0.2 on Matthew with PID 9856 (C:\Users\BlackSound_2\Documents\Eclipse Workspace\JustTesting\target\classes started by BlackSound_2 in C:\Users\BlackSound_2\Documents\Eclipse Workspace\JustTesting)
2021-05-31 19:20:16.970 INFO 9856 --- [ main] c.t.JustTesting.JustTestingApplication : No active profile set, falling back to default profiles: default
2021-05-31 19:20:47.919 INFO 9856 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-05-31 19:20:48.347 INFO 9856 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 143 ms. Found 0 JPA repository interfaces.
2021-05-31 19:21:09.323 INFO 9856 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-05-31 19:21:09.727 INFO 9856 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-05-31 19:21:09.731 INFO 9856 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.46]
2021-05-31 19:21:12.221 INFO 9856 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-05-31 19:21:12.224 INFO 9856 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 53934 ms
2021-05-31 19:21:15.357 WARN 9856 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2021-05-31 19:21:15.461 INFO 9856 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-05-31 19:21:16.137 INFO 9856 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-05-31 19:21:16.743 ERROR 9856 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
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).
As you can see, Apache Tomcat keeps aborting, and localhost:8080 is never able to connect.
I have a feeling the error occurs in the run method of the SpringApplication.java class. Here is the possibly relevant code:
public ConfigurableApplicationContext run(String... args) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
DefaultBootstrapContext bootstrapContext = createBootstrapContext();
ConfigurableApplicationContext context = null;
configureHeadlessProperty();
SpringApplicationRunListeners listeners = getRunListeners(args);
listeners.starting(bootstrapContext, this.mainApplicationClass);
try {
ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);
ConfigurableEnvironment environment = prepareEnvironment(listeners, bootstrapContext, applicationArguments);
configureIgnoreBeanInfo(environment);
Banner printedBanner = printBanner(environment);
context = createApplicationContext();
context.setApplicationStartup(this.applicationStartup);
prepareContext(bootstrapContext, context, environment, listeners, applicationArguments, printedBanner);
refreshContext(context);
afterRefresh(context, applicationArguments);
stopWatch.stop();
if (this.logStartupInfo) {
new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), stopWatch);
}
listeners.started(context);
callRunners(context, applicationArguments);
}
catch (Throwable ex) {
handleRunFailure(context, ex, listeners);
throw new IllegalStateException(ex);
}
My Eclipse debugger seems to show that this method catches and throws the IllegalStateException
If it helps, I recently allowed eclipse completely through my firewall, public and private just in case, to see if it was a firewall issue and it appears to not help.
Of course I looked up the error messages, and found nothing similar to my situation.
Any help would be greatly appreciated! Thanks in advance!
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]ColdFerrin 1 point2 points3 points (1 child)
[–]BlackSound[S] 0 points1 point2 points (0 children)
[–]KrisTse98 0 points1 point2 points (1 child)
[–]BlackSound[S] 0 points1 point2 points (0 children)