0

Actually I'm new to spring-boot concept, my problem is when I run my program in eclipse I get the error as shown below, Problem is i dint got what the error is and how to solve this.., So some one help me to fix this error

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityFilterChainRegistration' defined in class path resource [org/springframework/boot/autoconfigure/security/SpringBootWebSecurityConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [javax.servlet.Filter]: : Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ignoredPathsWebSecurityConfigurerAdapter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping org.springframework.boot.actuate.autoconfigure.ManagementSecurityAutoConfiguration$IgnoredPathsWebSecurityConfigurerAdapter.endpointHandlerMapping; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'endpointHandlerMapping' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping]: Factory method 'endpointHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcEndpoints' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'environmentMvcEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.boot.actuate.endpoint.EnvironmentEndpoint]: : Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration.healthIndicators; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$DataSourcesHealthIndicatorConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$DataSourcesHealthIndicatorConfiguration.dataSources; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration.healthIndicators; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$DataSourcesHealthIndicatorConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$DataSourcesHealthIndicatorConfiguration.dataSources; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ignoredPathsWebSecurityConfigurerAdapter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping org.springframework.boot.actuate.autoconfigure.ManagementSecurityAutoConfiguration$IgnoredPathsWebSecurityConfigurerAdapter.endpointHandlerMapping; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'endpointHandlerMapping' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping]: Factory method 'endpointHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcEndpoints' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'environmentMvcEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.boot.actuate.endpoint.EnvironmentEndpoint]: : Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration.healthIndicators; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$DataSourcesHealthIndicatorConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$DataSourcesHealthIndicatorConfiguration.dataSources; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration.healthIndicators; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$DataSourcesHealthIndicatorConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$DataSourcesHealthIndicatorConfiguration.dataSources; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:464)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1117)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1012)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at org.springframework.boot.context.embedded.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:211)
        at org.springframework.boot.context.embedded.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:85)
        at org.springframework.boot.context.embedded.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:73)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getServletContextInitializerBeans(EmbeddedWebApplicationContext.java:233)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:220)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:84)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:205)
        at org.springframework.boot.context.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:54)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5170)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

This contain main method:- package com.tanmay;

import java.io.File;
import java.io.FileInputStream;
import java.util.Iterator;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;






//import com.javatpoint.Controller;
import com.tanmay.vo.Column;
import com.tanmay.vo.Database;
import com.tanmay.vo.Table;
import com.tanmay.vo.Column.ColType;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


@Configuration
@ComponentScan
@EnableAutoConfiguration
public class LoadExcelSheet {

    @RequestMapping("/ExcelVisualize") 
    @ResponseBody
    public void loadExcelSheet(String excelFilePath) throws Exception {
        FileInputStream inputStream = new FileInputStream(new File(
                excelFilePath));

        Database DatabaseObj = new Database();
        DatabaseObj.DatabaseName = "Tanmay";

        Workbook workbook = new XSSFWorkbook(inputStream);
        String CreationScript="";
        for (int WorksheetNum = 0; WorksheetNum < workbook.getNumberOfSheets(); WorksheetNum++) {

            Sheet firstSheet = workbook.getSheetAt(WorksheetNum);

            Table TableObj = new Table();
            TableObj.TableName = firstSheet.getSheetName();
            int lrow = firstSheet.getPhysicalNumberOfRows();
            Row ColumnRow = firstSheet.getRow(0);
            Row DataTypeRow = firstSheet.getRow(1);
            for (int x = 2; x<lrow; x++) {
                Row DataValueRow = firstSheet.getRow(x);
                Iterator<Cell> cellIterator = ColumnRow.cellIterator();
                int columnNum = 0;
                //int rowNum=0;
                while (cellIterator.hasNext()) {
                    cellIterator.next();
                    Column ColumnObj = new Column();
                    Row RowObj = null;


                    Cell ColCell = ColumnRow.getCell(columnNum);
                    Cell DataTypeCell = DataTypeRow.getCell(columnNum);

                    Cell DataValueCell = DataValueRow.getCell(columnNum);

                    switch (ColCell.getCellType()) {
                    case Cell.CELL_TYPE_STRING:
                        ColumnObj.ColumnName = ColCell.getStringCellValue();
                        break;
                    }

                    // values

                    try{
                        switch (DataValueCell.getCellType()) {
                    case Cell.CELL_TYPE_STRING:
                        ColumnObj.ColumnValues = DataValueCell
                                .getStringCellValue();
                        break;
                    case Cell.CELL_TYPE_NUMERIC:
                        ColumnObj.numColumnValues = (int)DataValueCell.getNumericCellValue();
                        break;
                    /*
                     * case Cell.CELL_TYPE_BOOLEAN: ColumnObj.num1ColumnValues =
                     * (DataValueCell .getBooleanCellValue());
                     */
                    default:
                        break;
                    }

                    ColumnObj.ColLocationNumber = columnNum;

                    switch (DataTypeCell.getCellType()) {
                    case Cell.CELL_TYPE_STRING:
                        String DataType = DataTypeCell.getStringCellValue();
                        if (DataType.toLowerCase().startsWith("pk.")) {
                            // PK.string
                            ColumnObj.isPrimaryKey = true;
                            ColumnObj.ColumnType = getDataType(DataType.split(
                                    "\\.", 2)[1]);
                        } else if (DataType.toLowerCase().startsWith("fk.")) {
                            // fk.string.tablename.columnname
                            ColumnObj.isForeignKey = true;
                            ColumnObj.ColumnType = getDataType(DataType.split(
                                    "\\.", 4)[1]);
                            ColumnObj.ForeignKey_Table = DataType.split("\\.",
                                    4)[2];
                            ColumnObj.ForeignKey_Column = DataType.split("\\.",
                                    4)[3];
                        } else {
                            ColumnObj.ColumnType = getDataType(DataType);
                        }
                        break;
                    }

                    if (!ColumnObj.ColumnName.equals(""))
                        TableObj.Columns.put(ColumnObj.ColumnName, ColumnObj);
                    columnNum++;
                    }catch(Exception e){}
                }


                if(x>1)
                {
                    CreationScript += TableObj.getInsertScript()+"\n";

                }

            }
            DatabaseObj.Tables.put(TableObj.TableName, TableObj);

        }
        System.out.println(DatabaseObj.getCreationScript());
        System.out.println(CreationScript);

        // Prepared statement

        workbook.close();
        inputStream.close();
    }


    private ColType getDataType(String DataType) {
        if (DataType.toLowerCase().equals("string")) {
            return ColType.STRING;
        } else if (DataType.toLowerCase().equals("int")) {
            return ColType.INTEGER;
        } else if (DataType.toLowerCase().equals("date")) {
            return ColType.DATE;
        }
        return ColType.NONE;
    }

    public static void main(String[] args) throws Exception {
        new LoadExcelSheet().loadExcelSheet("c:\\Userdetails.xlsx");
    }
}

ExcelVisualizeApplication:-

package com.tanmay;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ExcelVisualizeApplication {

    public static void main(String[] args) {
        SpringApplication.run(ExcelVisualizeApplication.class, args);
    }
}
Tanu Tanmay
  • 31
  • 1
  • 1
  • 5

1 Answers1

0

There's a lot of stack trace there to look at and no code to debug. But the one part that stands out to me is the part that says "If you want an embedded database please put a supported one on the classpath.".

Because you've only shared a stack trace and no code, I can only speculate what's going on, but it appears as if a data source is needed, but can't be created because there's no suitable embedded database library (such as H2, Hypersonic, or Derby) on the classpath. I can't say for sure, but I believe that the part about setting up the Spring Security filters is just a side effect of not having that data source.

But again, without knowing what, if any beans you've configured (is Boot doing all of the autoconfig or have you explicitly configured any beans?) I'm only able to point out the datasource error.

Craig Walls
  • 2,080
  • 1
  • 12
  • 13
  • Just now I had uploaded the code. Please once go through it @Craig Walls – Tanu Tanmay Jan 24 '16 at 08:26
  • I'm a bit confused by your code. ExcelVisualizeApplication is a typical Spring Boot bootstrapping class, whereas LoadExcelSheet appears to be a Spring MVC controller. But rather than annotate it with `@Controller`, it is annotated with `@Configuration`, `@ComponentScan`, `@EnableAutoConfiguration` (which, FWIW, is the same as using `@SpringBootApplication`). And, LoadExcelSpreadsheet has its own main() method. Which one are you running when you get that stack trace? And what are the dependencies in the build? Deps are usually good clues as to what is being auto-configured. – Craig Walls Jan 25 '16 at 14:49