Tag Archives: Exception

[Solved] logback ERROR SizeAndTimeBasedFNATP & DefaultTimeBasedFileNamingAndTriggeringPolicy

1. Description

Project started, Logback configuration error (FileNamePattern format and timeBasedFileNamingAndTriggeringPolicy did not correspond to it).

environment

IDE: 2021.3
spring boot: 2.5.6 (spring-boot-starter-logging: 2.5.6 --- logback-classic: 1.2.6)

Configuration 1:

	<FileNamePattern>${LOG_HOME}/info${LOG_NAME}_%d{yyyy-MM-dd}.part_%i.log</FileNamePattern>
    <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy" />

Configuration 2:

	<FileNamePattern>${LOG_HOME}/info${LOG_NAME}_%d{yyyy-MM-dd}.log</FileNamePattern>
    <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
        <maxFileSize>10KB</maxFileSize>
    </timeBasedFileNamingAndTriggeringPolicy>

2. Problems

Question 1:

Logging system failed to initialize using configuration from 'null'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Filename pattern [/var/demo_log_logback_%d{yyyy-MM-dd}.part_%i.log] contains an integer token converter, i.e. %i, INCOMPATIBLE with this configuration. Remove it.
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
	at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)

Question 2:

Logging system failed to initialize using configuration from 'null'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@56cdfb3b - Missing integer token, that is %i, in FileNamePattern [/var/demo_log_logback_%d{yyyy-MM-dd}.log]
ERROR in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@56cdfb3b - See also http://logback.qos.ch/codes.html#sat_missing_integer_token
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
	at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)

reason:

DefaultTimeBasedFileNamingAndTriggeringPolicy: Do not Support %i
SizeAndTimeBasedFNATP: Need %i

3. Solution

Adjust the parameter value format of FileNamePattern.

4. Information

Logback manual appender label: https://logback.qos.ch/manual/appenders.html

Git Push Error: error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413

Crime scene

When using git to push the local code to the remote warehouse, the push fails (using the HTTP protocol). The error message is as follows:

$ git push 
Enumerating objects: 3383, done.
Counting objects: 100% (3383/3383), done.
Delta compression using up to 8 threads
Compressing objects: 100% (1216/1216), done.
Writing objects: 100% (3383/3383), 6.96 MiB | 81.92 MiB/s, done.
Total 3383 (delta 2303), reused 3007 (delta 2034), pack-reused 0
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
Everything up-to-date

Solution:

The data size of this push is 17m.

1. To solve the problem from the perspective of GIT, you can add the size of http.postBuffer

git config http.postBuffer 524288000

2. Because my Gitlab service is using Nginx as a domain proxy, it is possible that the client_max_body_size of nginx is limited and can be adjusted as follows.

client_max_body_size 1024m;

The authentication server Configurate NoClassDefFoundError Error (store client information in a JDBC-based database)

1. Error reported: caused by: java.lang.noclassdeffounderror: org/springframework/JDBC/core/rowmapper

Problem reason: JDBC related dependencies are missing. Add the following dependencies:

<dependency>
  <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>

The detailed error reports are as follows:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-11-17 09:54:25.841 ERROR 18008 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot configure enpdoints
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:415) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
	at oauth.QriverAuthServerApplication.main(QriverAuthServerApplication.java:14) [classes/:na]
Caused by: java.lang.IllegalStateException: Cannot configure enpdoints
	at org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration.init(AuthorizationServerEndpointsConfiguration.java:81) ~[spring-security-oauth2-2.3.4.RELEASE.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_281]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_281]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_281]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_281]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	... 19 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tokenServices' defined in class path resource [oauth/config/AuthorizationServerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices]: Factory method 'tokenServices' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbcClientDetailsService' defined in class path resource [oauth/config/AuthorizationServerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.ClientDetailsService]: Factory method 'jdbcClientDetailsService' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/core/RowMapper
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:483) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:362) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:334) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at oauth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$a1ad4a51.tokenServices(<generated>) ~[classes/:na]
	at oauth.config.AuthorizationServerConfig.configure(AuthorizationServerConfig.java:89) ~[classes/:na]
	at org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration.init(AuthorizationServerEndpointsConfiguration.java:79) ~[spring-security-oauth2-2.3.4.RELEASE.jar:na]
	... 26 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices]: Factory method 'tokenServices' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbcClientDetailsService' defined in class path resource [oauth/config/AuthorizationServerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.ClientDetailsService]: Factory method 'jdbcClientDetailsService' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/core/RowMapper
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	... 40 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbcClientDetailsService' defined in class path resource [oauth/config/AuthorizationServerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.ClientDetailsService]: Factory method 'jdbcClientDetailsService' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/core/RowMapper
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:483) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:362) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:334) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at oauth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$a1ad4a51.jdbcClientDetailsService(<generated>) ~[classes/:na]
	at oauth.config.AuthorizationServerConfig.tokenServices(AuthorizationServerConfig.java:50) ~[classes/:na]
	at oauth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$a1ad4a51.CGLIB$tokenServices$1(<generated>) ~[classes/:na]
	at oauth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$a1ad4a51$$FastClassBySpringCGLIB$$991f75cc.invoke(<generated>) ~[classes/:na]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at oauth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$a1ad4a51.tokenServices(<generated>) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_281]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_281]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_281]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_281]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	... 41 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.ClientDetailsService]: Factory method 'jdbcClientDetailsService' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/core/RowMapper
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	... 64 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/jdbc/core/RowMapper
	at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_281]
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756) ~[na:1.8.0_281]
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_281]
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) ~[na:1.8.0_281]
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74) ~[na:1.8.0_281]
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369) ~[na:1.8.0_281]
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363) ~[na:1.8.0_281]
	at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_281]
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362) ~[na:1.8.0_281]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_281]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[na:1.8.0_281]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_281]
	at org.springframework.security.oauth2.provider.client.JdbcClientDetailsService.<init>(JdbcClientDetailsService.java:83) ~[spring-security-oauth2-2.3.4.RELEASE.jar:na]
	at oauth.config.AuthorizationServerConfig.jdbcClientDetailsService(AuthorizationServerConfig.java:40) ~[classes/:na]
	at oauth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$a1ad4a51.CGLIB$jdbcClientDetailsService$0(<generated>) ~[classes/:na]
	at oauth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$a1ad4a51$$FastClassBySpringCGLIB$$991f75cc.invoke(<generated>) ~[classes/:na]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at oauth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$a1ad4a51.jdbcClientDetailsService(<generated>) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_281]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_281]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_281]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_281]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	... 65 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.core.RowMapper
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_281]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_281]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[na:1.8.0_281]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_281]
	... 89 common frames omitted

Android: Can’t create handler inside thread that has not called Looper.prepare() [Solved]

Error reason:

You can't refresh the UI thread in a subthread in Android

resolvent:

//Refresh the UI using the runOnUiThread method
runOnUiThread(new Runnable() {
    @Override
    public void run() {
        //refresh UI
    }
});

common problem:

When calling locationmanager to get the current location information and upload it in real time, the reason for this error is that locationmanager needs to be used in the main thread. The following methods are recommended:

@Override
protected void onCreate(Bundle savedInstanceState) {    
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //upload location messages
    Button btnUploadGPS = (Button)findViewById(R.id.btn_upload_gps);
    if (btnUploadGPS != null){
        btnUploadGPS .setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                uploadGPS();
            }
        });
    }
}

private void uploadGPS(){    
    final LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    locationManager.requestLocationUpdates(
            LocationManager.GPS_PROVIDER,
            2000,
            (float) 0.01,
            new LocationListener() {
                @Override
                public void onLocationChanged(Location location) {
                    asyncUploadGPS(location);
                }

                @Override
                public void onStatusChanged(String provider, int status, Bundle extras) {

                }

                @Override
                public void onProviderEnabled(String provider) {
                    asyncUploadGPS(locationManager.getLastKnownLocation(provider));
                }

                @Override
                public void onProviderDisabled(String provider) {
                    asyncUploadGPS(null);
                }
            }
    );
}

private void asyncUploadGPS(final Location currentLocation) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            //upload loacation messages
        }
    }).start();
}

Exception from HRESULT: 0x80041FE2

Installation vs community version, new project appears:

Exception from HRESULT: 0x80041FE2

Reasons for the problem:
when installing, the Linux related environment was selected. When creating the project, the visual c + + project was created, because these components were not installed, an error was reported
Creating Linux related projects will not.

Exception handling of httpmessage notwritableexception in springboot

preface:

First, post the error report log

Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class com.test.dto.ResultBean]

If the log is similar, you can continue to look down.

1. Causes and Solutions

Restore the accident scene first (only show the core problem code)

Interface layer code:

@RestController
@RequestMapping("/client")
public class ControllerTest {

    @GetMapping("/test")
    public ResultBean name() {
        return ResultBean.success();
    }
}

ResultBean Code:

public class ResultBean {

    private String code;
    private String result;

    ResultBean(String code, String result) {
        this.code = code;
        this.result = result;
    }

    public static ResultBean success() {
        return new ResultBean("200", "success");
    }

}

The error log points to this   ResultBean. The big probability is that there is a problem with this bean. After careful analysis of the log, it probably means that it is impossible to get the value, so it is impossible to write. Get the value?Get method?It seems that ResultBean is missing the get method (Lombok annotation is forgotten). With the get method, the problem is solved

Tips: be sure to add get and set methods and try to write by hand; Lombok annotations are rarely used. There are holes in them. Occasionally, the default method for generating special fields cannot be recognized by other components.

Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package

1. Problems encountered in building the springboot framework.

** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.

Warning: your application context may not be started because you added comments to the default package. There is also a sentence in the stack information below that includes this meaning.

 
 
1. Reason analysis

I didn’t use @ componentscanning annotation. Why did such an annotation pop up here?

When writing a startup class (the class where the main method is located), springboot does not use @ componentscan to indicate the object scanning range. By default, it scans the objects in the package where the current startup class is located.

(Note: I didn’t add @ componentscan annotation when writing the main method, so he will scan the objects in the package where the application is located)
if the current startup class has no package, an error will be reported when starting: your ApplicationContext is unlikely to start due to a @ componentscan of the default package.

(Note: the application class written in the Java folder does not belong to any package, so the startup class has no package.)

                                        Application is built under other packages

 
2. Solutions

Method 1: build application under other packages

Method 2: add @ componentscan annotation on the application class to specify the package to scan

 

Chrome Error: Uncaught Error: SECURITY_ERR: DOM Exception 18

Uncaught Error: SECURITY_ERR: DOM Exception 18

Question:
I get the following error in Chrome’s developer tools window when I try to set a cookie using this jQuery plugin:

Uncaught Error: SECURITY_ERR: DOM Exception 18

What does this error mean and how can I fix it? I get the same error when I use this jQuery plugin.

Answer:
You’re most likely using this on a local file over the file://URI scheme, which cannot have cookies set. Put it on a local server so you can use http://localhost.

Handling nullreference exception problems encountered in NHibernate

Recently, when using NHibernate, we encountered a very strange problem. When calling Session.SaveOrUpdate () method, an exception was thrown.

 

Look at the screenshot below. Although this exception was caught by vs in the catch line, the real problem is inside the try code block. As for how to make vs catch and prompt when problems occur, there is a detailed introduction in my other blog articles. I won’t talk about it here.

 

The code to throw an exception is as follows:

 

 

 

 

In the end, it’s the call Session.SaveOrUpdate The exception thrown when (). And I’ll go to the details of exception to see if there are any hints, but there are no valuable clues such as innerexcitation and message. Later, I kept thinking about why there was a problem, and finally found the root of the problem, which is current_ session_ context_ There’s something wrong with class.

 

The scene is like this. My project is a web project, in which NHibernate is used, and then I write the configuration in the web.config In the middle. After that, I wrote some new methods, and then set up a unittest project. Later, I need to move all the content related to NHibernate in order to test these service methods. I’ll take it web.config The content in is copied to the app.config The session context in NHibernate is still web, which is the reason for the problem.

 

 

Then I changed it to thread_ Static, the problem is solved. The reason is that the project of unittest does not have IIS. If session is still obtained from the web at this time, it will be null, so an exception is thrown.

java.lang.Error: Unresolved compilation problems

java.lang.Error : Unresolved compilation problems

java.lang.Error : Unresolved compilation problems

Environment description solution reason

environment

jdk1.8 + springboot + maven + ItelliJ IDEA

describe

When starting a project, initialize the datasource to report an error. The specific error is to say that a POJO cannot be resolved to a type , and repeatedly check that the POJO exists and has been relied on in POM .

A few days ago, it can be started normally. Other colleagues can start normally, and the code has not been modified.

Solution

The search results are generally caused by the inconsistency between the version of JDK compiled by eclipse or idea and the version of JDK required by the project. However, the configuration of any development environment has been modified recently. After careful inspection, it is found that the java complier and Project SDK versions are the same.

There is an answer on stackoverflow that is to say MVN clean once, try it and find that it can be started successfully

reason

It may be that the previous MVN clean install did not have the correct clean , resulting in some compiled codes not being updated.