Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法使用Singleton方法初始化类_Java_Spring_Jdbc - Fatal编程技术网

Java 无法使用Singleton方法初始化类

Java 无法使用Singleton方法初始化类,java,spring,jdbc,Java,Spring,Jdbc,我创建了一个获取数据库连接实例的类。但是,我得到一个错误,说调用类为null。我将在下面发布我的错误 现在我有了这个代码的工作版本和非工作版本。我首先把所有的东西都塞进一个类,让它启动并运行,然后开始清理它,这就是我遇到问题的时候 此类“createJobTicket”调用DataBaseConnectionDAO的实例 public class createJobTicket { //private java.sql.Connection conn = null; //pri

我创建了一个获取数据库连接实例的类。但是,我得到一个错误,说调用类为null。我将在下面发布我的错误

现在我有了这个代码的工作版本和非工作版本。我首先把所有的东西都塞进一个类,让它启动并运行,然后开始清理它,这就是我遇到问题的时候

此类“createJobTicket”调用DataBaseConnectionDAO的实例

public class createJobTicket {

    //private java.sql.Connection conn = null;
    //private java.sql.Statement stmt = null;
    private static DataBaseConnectionDAO databaseConnection = DataBaseConnectionDAO.getInstance();

    public static HSSFWorkbook getWorkbook(HSSFWorkbook workbook, Long id, Environment env){

     try{

         java.sql.Connection conn =  databaseConnection.getConnection();
         java.sql.Statement stmt = conn.createStatement();
          String sql;
          sql = "SELECT"
                    +" hillcresttooldie.T_PO.id po_id,"
                    +" hillcresttooldie.T_PO.DUE_DATE due_date,"
                    +" hillcresttooldie.T_CUSTOMER.CUSTOMER_NAME customer_name,"
                    +" hillcresttooldie.T_PART.ID part_id,"
                    +" hillcresttooldie.T_PO_PART.PART_QUANTITY part_quantity,"
                    +" hillcresttooldie.T_PART.PART_NUMBER part_number,"
                    +" hillcresttooldie.T_PART.PART_DESCRIPTION part_description,"
                    +" hillcresttooldie.T_PART.PLASMA_HRS_PER_PART plasma_hrs,"
                    +" hillcresttooldie.T_PART.GRIND_HRS_PER_PART grind_hrs,"
                    +" hillcresttooldie.T_PART.MILL_HRS_PER_PART mill_hrs,"
                    +" hillcresttooldie.T_PART.BRAKEPRESS_HRS_PER_PART brakepress_hrs,"
                    +" hillcresttooldie.T_PART.LASER_HRS_PER_PART laser_hrs,"
                    +" hillcresttooldie.T_MATERIAL.MATERIAL_THICKNESS material_thickness"
                    +" FROM hillcresttooldie.T_PO"
                    +" join hillcresttooldie.T_PO_PART"
                    +" on hillcresttooldie.T_PO_PART.PO_ID = hillcresttooldie.T_PO.ID"
                    +" join hillcresttooldie.T_PART"
                    +" on hillcresttooldie.T_PART.ID = hillcresttooldie.T_PO_PART.PART_ID"
                    +" join hillcresttooldie.T_CUSTOMER"
                    +" on hillcresttooldie.T_PO.CUSTOMER_ID = hillcresttooldie.T_CUSTOMER.ID"
                    +" join hillcresttooldie.T_PART_MATERIAL"
                    +" on hillcresttooldie.T_PART.ID = hillcresttooldie.T_PART_MATERIAL.PARTS_ID"
                    +" join hillcresttooldie.T_MATERIAL"
                    +" on hillcresttooldie.T_PART_MATERIAL.materials_id = hillcresttooldie.T_MATERIAL.id"
                    +" where T_PO.id = '"+id+"'";

         ResultSet rs = stmt.executeQuery(sql);

         int index = 0;

         //STEP 5: Extract data from result set
          while(rs.next()){
             int po_id = rs.getInt("po_id");
             String due_date = rs.getString("due_date");
             String customer_name = rs.getString("customer_name");
             int part_id  = rs.getInt("part_id");
             int part_quantity = rs.getInt("part_quantity");
             String part_number = rs.getString("part_number");
             String part_description = rs.getString("part_description");
             BigDecimal plasma_hrs = rs.getBigDecimal("plasma_hrs");
             BigDecimal grind_hrs = rs.getBigDecimal("grind_hrs");
             BigDecimal mill_hrs = rs.getBigDecimal("mill_hrs");
             BigDecimal brakepress_hrs = rs.getBigDecimal("brakepress_hrs");
             BigDecimal laser_hrs = rs.getBigDecimal("laser_hrs");
             double material_thickness = rs.getDouble("material_thickness");


             //Create the Sheet
             String sheetName = index + "-" + customer_name + "-" + part_number;
             HSSFSheet sheet = workbook.createSheet(sheetName);
             //Apply Template to the sheet
             generateTemplate.applyTemplate(workbook, sheet);


             sheet.getRow(1).createCell(1).setCellValue(po_id);
             sheet.getRow(5).getCell(3).setCellValue(customer_name);
             sheet.getRow(5).createCell(8).setCellValue(due_date);
             sheet.getRow(6).getCell(3).setCellValue(part_number);
             sheet.getRow(6).createCell(8).setCellValue(part_quantity);
             sheet.getRow(7).createCell(4).setCellValue(part_description);
             sheet.getRow(7).createCell(8).setCellValue(material_thickness);


             index++;
          }
          //STEP 6: Clean-up environment
          rs.close();
          stmt.close();
          conn.close();

       }catch(SQLException se){
         se.printStackTrace();
         System.out.println("SQL Exeception thrown");
       }catch(Exception e){
          e.printStackTrace();

       }//end try
    return workbook;

    }
您可以注意到以下内容已被注释掉:

//private java.sql.Connection conn = null;
//private java.sql.Statement stmt = null;
这是因为如果我的IDE说:

 Cannot make a static reference to the non-static field conn
 Cannot make a static reference to the non-static field stmt
我的数据库连接DAO如下所示:

public class DataBaseConnectionDAO {

    @Inject
    private static Environment env;

    private static DataBaseConnectionDAO instance;

    // Step 1: JDBC props
     String DB_URL = env.getProperty("spring.datasource.url");
     String USER = env.getProperty("spring.datasource.username");
     String PASS = env.getProperty("spring.datasource.password");
     java.sql.Connection conn = null;
     java.sql.Statement stmt = null;

    private DataBaseConnectionDAO() { }

    public static DataBaseConnectionDAO getInstance() {

        if (instance == null) {
            synchronized (DataBaseConnectionDAO.class) {
                if (instance == null) {
                    instance = new DataBaseConnectionDAO();
                }
            }
        }
        return instance;
    }

    public java.sql.Connection getConnection() throws ClassNotFoundException,
            SQLException {

        Class.forName("com.mysql.jdbc.Driver");

        if (conn == null) {

            conn = DriverManager.getConnection(DB_URL, USER, PASS);

        }

        return conn;
    }

}


[DEBUG] com.htd.aop.logging.LoggingAspect - Enter: com.htd.web.rest.PoResource.generateJobTicket() with argument[s] = [16, com.codahale.metrics.servlet.AbstractInstrumentedFilter$StatusExposingServletResponse@1424a144]
[ERROR] com.htd.aop.logging.LoggingAspect - Exception in com.htd.web.rest.PoResource.generateJobTicket() with cause = null
java.lang.NoClassDefFoundError: Could not initialize class com.htd.web.rest.util.createJobTicket
    at com.htd.web.rest.PoResource.generateJobTicket(PoResource.java:332) ~[classes/:na]
    at com.htd.web.rest.PoResource$$FastClassBySpringCGLIB$$cfcd338a.invoke(<generated>) ~[spring-core-4.1.6.RELEASE.jar:na]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at com.htd.aop.logging.LoggingAspect.logAround(LoggingAspect.java:49) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_31]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_31]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_31]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_31]
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:58) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at com.htd.web.rest.PoResource$$EnhancerBySpringCGLIB$$4795e29.generateJobTicket(<generated>) [spring-core-4.1.6.RELEASE.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_31]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_31]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_31]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_31]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at com.codahale.metrics.servlet.AbstractInstrumentedFilter.doFilter(AbstractInstrumentedFilter.java:104) [metrics-servlet-3.1.1.jar:3.1.1]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:291) [spring-boot-actuator-1.2.3.RELEASE.jar:1.2.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:157) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:168) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at com.htd.web.filter.CsrfCookieGeneratorFilter.doFilterInternal(CsrfCookieGeneratorFilter.java:34) [classes/:na]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:96) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176) [spring-security-web-4.0.0.RELEASE.jar:na]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:102) [spring-boot-actuator-1.2.3.RELEASE.jar:1.2.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_31]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_31]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.20.jar:8.0.20]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_31]
公共类数据库连接DAO{
@注入
私人静态环境;
私有静态数据库连接DAO实例;
//步骤1:JDBC道具
字符串DB_URL=env.getProperty(“spring.datasource.URL”);
字符串USER=env.getProperty(“spring.datasource.username”);
字符串PASS=env.getProperty(“spring.datasource.password”);
java.sql.Connection conn=null;
java.sql.Statement stmt=null;
专用数据库ConnectionDao(){}
公共静态数据库ConnectionDao getInstance(){
if(实例==null){
已同步(DataBaseConnectionDAO.class){
if(实例==null){
实例=新数据库ConnectionDao();
}
}
}
返回实例;
}
public java.sql.Connection getConnection()抛出ClassNotFoundException,
SQLException{
Class.forName(“com.mysql.jdbc.Driver”);
如果(conn==null){
conn=DriverManager.getConnection(DB_URL,USER,PASS);
}
返回连接;
}
}
[DEBUG]com.htd.aop.logging.LoggingAspect-输入:com.htd.web.rest.PoResource.generateJobuticket(),参数[s]=[16,com.codahale.metrics.servlet.AbstractInstrumentedFilter$StatusExposingServletResponse@1424a144]
[错误]com.htd.aop.logging.LoggingAspect-com.htd.web.rest.PoResource.generateJobicket()中的异常,原因为null
java.lang.NoClassDefFoundError:无法初始化类com.htd.web.rest.util.createJobTicket
在com.htd.web.rest.PoResource.generateJobTicket(PoResource.java:332)~[classes/:na]
在com.htd.web.rest.PoResource$$FastClassBySpringCGLIB$$cfcd338a.invoke()~[spring-core-4.1.6.RELEASE.jar:na]
在org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.aop.framework.ReflectiveMethodInvocation.procedue(ReflectiveMethodInvocation.java:157)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.procedue(MethodInvocationProceedingJoinPoint.java:85)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在com.htd.aop.logging.LoggingAspect.logAround(LoggingAspect.java:49)~[classes/:na]
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)~[na:1.8.0\u 31]
在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)~[na:1.8.0\u 31]
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)~[na:1.8.031]
在java.lang.reflect.Method.invoke(Method.java:483)~[na:1.8.0\u 31]
在org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.aop.framework.ReflectiveMethodInvocation.procedue(ReflectiveMethodInvocation.java:179)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.aop.aspectj.aspectjafthrowingadvice.invoke(aspectjafthrowingadvice.java:58)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.aop.framework.ReflectiveMethodInvocation.procedue(ReflectiveMethodInvocation.java:179)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.aop.framework.ReflectiveMethodInvocation.procedue(ReflectiveMethodInvocation.java:179)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在com.htd.web.rest.PoResource$$EnhancerBySpringCGLIB$$4795e29.generateJobTicket()[spring-core-4.1.6.RELEASE.jar:na]
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)~[na:1.8.0\u 31]
在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)~[na:1.8.0\u 31]
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)~[na:1.8.031]
在java.lang.reflect.Method.invoke(Method.java:483)~[na:1.8.0\u 31]
在org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
在org.springframework.web.servlet.mvc.method.annotation.ServletinInvocableHandlerMethod.invokeAndHandle(ServletinInvocableHandlerMethod.java:110)[spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
位于org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMapp
[DEBUG] com.htd.aop.logging.LoggingAspect - Enter: com.htd.web.rest.PoResource.generateJobTicket() with argument[s] = [16, com.codahale.metrics.servlet.AbstractInstrumentedFilter$StatusExposingServletResponse@613cf2e]
[ERROR] com.htd.aop.logging.LoggingAspect - Exception in com.htd.web.rest.PoResource.generateJobTicket() with cause = null
java.lang.NoClassDefFoundError: Could not initialize class com.htd.web.rest.util.createJobTicket
    at com.htd.web.rest.PoResource.generateJobTicket(PoResource.java:332) ~[classes/:na]
    at com.htd.web.rest.PoResource$$FastClassBySpringCGLIB$$cfcd338a.invoke(<generated>) ~[spring-core-4.1.6.RELEASE.jar:na]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    private static DataBaseConnectionDAO databaseConnection = DataBaseConnectionDAO.getInstance();
    private static DataBaseConnectionDAO databaseConnection;

    private static java.sql.Connection getDatabaseConnection() {
        if (databaseConnection == null) {
            databaseConnection = DataBaseConnectionDAO.getInstance();
        }
        return databaseConnection.getConnection();
    }

    public static HSSFWorkbook getWorkbook(HSSFWorkbook workbook, Long id, Environment env){

     try{

         java.sql.Connection conn = getDatabaseConnection();
         // ...
@Inject
private static Environment env;