Tag Archives: servlet

Failed to instantiate [org.springframework.web.servlet.HandlerMapping] Factory method ‘resourceHandl

Introduction

I wrote this project four months ago. Today, I suddenly started to test whether the next project can run, and It reports an error.

Problems encountered

I originally wanted to test whether the database could be connected in the test package, but an error was reported when running, which led me to find the error for a long time

   @Autowired
    private DataSource dataSource;

    @Test
    public void test01() throws SQLException {
        System.out.println("进入了sql判断方法");
        System.out.println(dataSource.getConnection());
    }

Error message:

java.lang.IllegalStateException: Failed to load ApplicationContext
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
	at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resourceHandlerMapping' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; nested exception is java.lang.IllegalStateException: No ServletContext set
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:127)
	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:275)
	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:243)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
	... 25 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; nested exception is java.lang.IllegalStateException: No ServletContext set
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
	... 43 common frames omitted
Caused by: java.lang.IllegalStateException: No ServletContext set
	at org.springframework.util.Assert.state(Assert.java:76)
	at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.resourceHandlerMapping(WebMvcConfigurationSupport.java:591)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 44 common frames omitted

java.lang.IllegalStateException: Failed to load ApplicationContext

	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
	at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resourceHandlerMapping' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; nested exception is java.lang.IllegalStateException: No ServletContext set
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:127)
	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:275)
	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:243)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
	... 25 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; nested exception is java.lang.IllegalStateException: No ServletContext set
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
	... 43 more
Caused by: java.lang.IllegalStateException: No ServletContext set
	at org.springframework.util.Assert.state(Assert.java:76)
	at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.resourceHandlerMapping(WebMvcConfigurationSupport.java:591)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 44 more

Reason

The problem is caused by the use of the @EnableWebMvc annotation in my project. The specific reason is not clear to me

How to solve

Delete the@EnableWebMvc annotation to start normally.

[2022 New Solution] Error:java: Compilation failed: internal java compiler error

Error Reason

The reason for this error is mainly because of the jdk version problem, There are two reasons here, One is that the compiled version does not match, The other is that the current project jdk version does not support.

1:mac select Preferences

windows find Setting

Find Java Compiler

Select 1.8 on the right

2: Find File ->Project Structure->Project Settings

Choose 8

Choose 8

[Solved] Axis Failed to Import webService: No support for attachments

The client generated by Axis, Error when importing webService:

AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.lang.RuntimeException: No support for attachments
 faultActor:
 faultNode:
 faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.lang.RuntimeException: No support for attachments
at org.apache.axis.Message.setup(Message.java:372)
at org.apache.axis.Message.<init>(Message.java:235)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:779)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)

Problem Reason

Missing jars: mail.jar and activation.jar

Solution

Introduce dependencies



    javax.mail
    mail
    1.4.7



    javax.activation
    activation
    1.1.1

[Solved] JNI Error: Fatal signal 11 (SIGSEGV)

2022-09-14 09:19:01.092 3562-3580/com.derry.opengl A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x24 in tid 3580 (GLThread 103) 

I often encounter this kind of error report, making me very bummed.

I tried a solution (rooted phone or emulator, otherwise the error log file can not be found): 1.

1. find the file where the logs are located: data/tombstones

2. Find the file with this latest date

3. save the file to the desktop (I did not encounter problems with permissions using the emulator, so I can export directly) If you encounter insufficient permissions, you need to use su superuser permissions (chmod 777 xxxxx)

4. open the log file: there are error logs inside (this point is not enough permissions for me) specific analysis of the problem, this point is mainly to explain how to view this log file

--------- log main 09-14 09:18:58.184 3562 3562 D : houdini no need remount 09-14 09:18:58.201 3562 3562 I art : Late-enabling -Xcheck:jni 09-14 09:18:58.236 3562 3562 E libnb : load libnb 09-14 09:18:58.252 3562 3562 D houdini : [3562] Initialize library(version: 7.1.1b_x.49852 RELEASE)... successfully. 09-14 09:18:58.254 3562 3562 W art : Unexpected CPU variant for X86 using defaults: x86 09-14 09:18:58.719 3562 3562 W art : Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 09-14 09:18:58.782 3562 3562 I art : Rejecting re-init on previously-failed class java.lang.Class: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener; 09-14 09:18:58.783 3562 3562 I art : at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.widget.ActionBarContainer.(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance0!( java.lang.Object[]) (Constructor.java:-2) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflate(org.xmlpull.v1. XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1. XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1. XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377) 09-14 09:18:58.783 3562 3562 I art : at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140) 09-14 09:18:58.783 3562 3562 I art : at void com.derry.opengl.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:19) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6692) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118) 09-14 09:18:58.783 3562 3562 I art : at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2621) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2729) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1480) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Looper.loop() (Looper.java:154) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6176) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Method.invoke!( java.lang.Object, java.lang.Object[]) (Method.java:-2) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:893) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:783) 09-14 09:18:58.783 3562 3562 I art : Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.derry.opengl-1/base.apk"],nativeLibraryDirectories=[/data/app/com.derry.opengl-1/lib/arm, /data/app/com.derry.opengl-1/base.apk! /lib/armeabi-v7a, /system/lib, /vendor/lib]] 09-14 09:18:58.783 3562 3562 I art : at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312) 09-14 09:18:58.783 3562 3562 I art : at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.widget.ActionBarContainer.(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance0!( java.lang.Object[]) (Constructor.java:-2) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflate(org.xmlpull.v1. XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1. XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1. XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377) 09-14 09:18:58.783 3562 3562 I art : at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140) 09-14 09:18:58.783 3562 3562 I art : at void com.derry.opengl.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:19) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6692) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118) 09-14 09:18:58.783 3562 3562 I art : at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2621) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2729) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1480) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Looper.loop() (Looper.java:154) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6176) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Method.invoke!( java.lang.Object, java.lang.Object[]) (Method.java:-2) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:893) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:783) 09-14 09:18:58.783 3562 3562 I art : 09-14 09:18:58.843 3562 3562 W System.err: java.io.FileNotFoundException: /sdcard/lbpcascade_frontalface.xml (Permission denied) 09-14 09:18:58.844 3562 3562 W System.err: at java.io.FileOutputStream.open(Native Method) 09-14 09:18:58.844 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:221) 09-14 09:18:58.844 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:169) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.utils.FileUtil.copyAssets2SDCard(FileUtil.java:16) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MyGLRenderer.(MyGLRenderer.java:43) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.init(MyGLSurfaceView.java:29) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.(MyGLSurfaceView.java:21) 09-14 09:18:58.844 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance0(Native Method) 09-14 09:18:58.844 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.createView(LayoutInflater.java:645) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 09-14 09:18:58.844 3562 3562 W System.err: at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 09-14 09:18:58.844 3562 3562 W System.err: at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MainActivity.onCreate(MainActivity.java:19) 09-14 09:18:58.844 3562 3562 W System.err: at android.app.Activity.performCreate(Activity.java:6692) 09-14 09:18:58.845 3562 3562 W System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 09-14 09:18:58.846 3562 3562 W System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621) 09-14 09:18:58.846 3562 3562 W System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2729) 09-14 09:18:58.846 3562 3562 W System.err: at android.app.ActivityThread.-wrap12(ActivityThread.java) 09-14 09:18:58.847 3562 3562 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1480) 09-14 09:18:58.848 3562 3562 W System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 09-14 09:18:58.848 3562 3562 W System.err: at android.os.Looper.loop(Looper.java:154) 09-14 09:18:58.848 3562 3562 W System.err: at android.app.ActivityThread.main(ActivityThread.java:6176) 09-14 09:18:58.848 3562 3562 W System.err: at java.lang.reflect.Method.invoke(Native Method) 09-14 09:18:58.848 3562 3562 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893) 09-14 09:18:58.848 3562 3562 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783) 09-14 09:18:58.857 3562 3562 W System.err: java.io.FileNotFoundException: /sdcard/seeta_fa_v1.1.bin (Permission denied) 09-14 09:18:58.862 3562 3562 W System.err: at java.io.FileOutputStream.open(Native Method) 09-14 09:18:58.862 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:221) 09-14 09:18:58.862 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:169) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.utils.FileUtil.copyAssets2SDCard(FileUtil.java:16) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.MyGLRenderer.(MyGLRenderer.java:45) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.init(MyGLSurfaceView.java:29) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.(MyGLSurfaceView.java:21) 09-14 09:18:58.862 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance0(Native Method) 09-14 09:18:58.862 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 09-14 09:18:58.862 3562 3562 W System.err: at android.view.LayoutInflater.createView(LayoutInflater.java:645) 09-14 09:18:58.862 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) 09-14 09:18:58.862 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 09-14 09:18:58.863 3562 3562 W System.err: at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 09-14 09:18:58.863 3562 3562 W System.err: at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 09-14 09:18:58.863 3562 3562 W System.err: at com.derry.opengl.MainActivity.onCreate(MainActivity.java:19) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.Activity.performCreate(Activity.java:6692) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2729) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.-wrap12(ActivityThread.java) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1480) 09-14 09:18:58.863 3562 3562 W System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 09-14 09:18:58.863 3562 3562 W System.err: at android.os.Looper.loop(Looper.java:154) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.main(ActivityThread.java:6176) 09-14 09:18:58.863 3562 3562 W System.err: at java.lang.reflect.Method.invoke(Native Method) 09-14 09:18:58.863 3562 3562 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893) 09-14 09:18:58.863 3562 3562 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783) 09-14 09:18:58.998 3562 3562 D : static HostConnection *HostConnection::createUnique(): call 09-14 09:18:58.999 3562 3562 D : HostConnection::get() New Host Connection established 0xd2dfcd30, tid 3562 09-14 09:18:59.103 3562 3586 I OpenGLRenderer: Initialized EGL, version 1.4 09-14 09:18:59.103 3562 3586 D OpenGLRenderer: Swap behavior 1 09-14 09:18:59.105 3562 3586 D : HostConnection::get() New Host Connection established 0xd2dfcf10, tid 3586 09-14 09:18:59.416 3562 3580 D : HostConnection::get() New Host Connection established 0xd7012480, tid 3580 09-14 09:18:59.794 3562 3580 E EGL_emulation: eglQueryContext 32c0 EGL_BAD_ATTRIBUTE 09-14 09:18:59.794 3562 3580 E EGL_emulation: tid 3580: eglQueryContext(1413): error 0x3004 (EGL_BAD_ATTRIBUTE)

Uncaught URIError: URI malformed [How to Solve]

Uncaught URIError: URI malformed

  • url, pass the value, if the key has Chinese characters inside, the browser will be encoded off by default, so this page needs to be decoded first when calling the query interface), the above error occurs.
  • Because the url contains the “%” character, the browser will give an error when it executes decodeURIComponent on “%”.

Repeat the problem

The browser url on the splice on (?q=%好的);

https://www.baidu.com/?q=%好的

Enter the code;

location.search
'?q=%%E5%A5%BD%E7%9A%84'
decodeURIComponent('%%E5%A5%BD%E7%9A%84');

Solution

urlStr.replace(/%/g, '%25');

Fundamentally solve the problem: encode the URL before uploading the value

encodeURIComponent('%好的');
'%25%E5%A5%BD%E7%9A%84'
https://www.baidu.com/?q=%25%E5%A5%BD%E7%9A%84

[Solved] java Internal error in the mapping processor java.lang.NullPointerException

Error:

java: Internal error in the mapping processor: java.lang.NullPointerException  	
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.createManifestUrl(DefaultVersionInformation.java:182)  	
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.openManifest(DefaultVersionInformation.java:153)  	
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.getLibraryName(DefaultVersionInformation.java:129)  	
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.getCompiler(DefaultVersionInformation.java:122)  	
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.fromProcessingEnvironment(DefaultVersionInformation.java:95)  	
at org.mapstruct.ap.internal.processor.DefaultModelElementProcessorContext.<init>(DefaultModelElementProcessorContext.java:50)  
at org.mapstruct.ap.MappingProcessor.processMapperElements(MappingProcessor.java:218)  	
at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:156)  	
at org.jetbrains.jps.javac.APIWrappers$ProcessorWrapper.process(APIWrappers.java:109)  	
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  	
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)  	
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  	
at java.lang.reflect.Method.invoke(Method.java:498)  	
at org.jetbrains.jps.javac.APIWrappers$1.invoke(APIWrappers.java:213)  	
at org.mapstruct.ap.MappingProcessor.process(Unknown Source)  	
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)  	
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)  
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)  	
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)  	
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)  	
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)  	
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)  	
at com.sun.tools.javac.main.Main.compile(Main.java:523)  	
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)  	
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)  	
at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:231)  	
at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:501)  	
at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:353)  	
at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:277)  	
at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:231)  	
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1441)  	
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1100)  	at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1224)  	at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1066)  	at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:832)  	at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:419)  	at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:183)  	at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:132)  	at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)  	at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:132)  	at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:219)  	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)  	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)  	at java.lang.Thread.run(Thread.java:748)  

When using MapStruct, idea version 2020.3, an error occurs when building the project: java: Internal error in the mapping processor: java.lang.NullPointerException

Solution:
Setting –>Build,Execution,Deployment –>Compiler –>User-local build add the parameter
-Djps.track.ap.dependencies=false

[Solved] ant-design a-date-picker Error: date.locale is not a function

The error reporting contents are as follows:

date.locale is not a function

Original code:

<a-form-item label="Time From:" name="signTime">
                <a-date-picker placeholder="Please Select"  v-model:value="formState.signTime" style="width:100%" />
              </a-form-item>

Correct code:

<a-form-item label="Time From:" name="signTime">
                <a-date-picker placeholder="Please Select" format="YYYY-MM-DD" valueFormat="YYYY-MM-DD" v-model:value="formState.signTime" style="width:100%" />
              </a-form-item>

Summary: you need to add the time display format attribute and the final value format valueFormat attribute.

[Solved] Tomcat Error: Failed to start componen

I make a crud project of servlet + JSP, and start Tomcat with an error:

org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/oa3]]

It was found that the path was not added ‘/’

//@WebServlet("dept/list")
//Add slash!
@WebServlet("/dept/list")
public class DeptServlet extends HttpServlet {

 

Mat Failed to Open a Memory Dump Error [How to Solve]

1. When mat opens a memory dump file, the following error is reported:

An internal error occurred durina: “Parsing heap dump from

2. At the same time, the size of the dump file is relatively large, which indicates that the memory of the mat software is small, and it is not enough to open the analysis

Big problem. The configuration needs to be adjusted.

3. Solution: adjust the configuration by installing

1) right click display package content

2) Click to open this folder

3) Continue to click to open this folder

4) Right-click to open this profile

5) Change this configuration to 5120m and save the configuration. Just reopen MAT.

4. Done!

[Solved] SpringMVC Shiro Error: org.apache.shiro.UnavailableSecurityManagerException No SecurityManager

The configuration is as follows:

    <!-- shiro -->
    <filter>
        <filter-name>shiroFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <init-param>
            <param-name>targetFilterLifecycle</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>shiroFilter</filter-name>
        <url-pattern>/</url-pattern>
    </filter-mapping>

The error is reported as follows:

SEVERE: Servlet.service() for servlet [springMVC] in context with path [/myweb] threw exception [Request processing failed; nested exception is org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton.  This is an invalid application configuration.] with root cause
org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton.  This is an invalid application configuration.
    at org.apache.shiro.SecurityUtils.getSecurityManager(SecurityUtils.java:123)
    at org.apache.shiro.subject.Subject$Builder.<init>(Subject.java:627)
    at org.apache.shiro.SecurityUtils.getSubject(SecurityUtils.java:56)
    at com.myweb.controller.UserController.login(UserController.java:136)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:151)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:722)

Solution:

Replace “/” to “/*” in url-pattern

    <!-- shiro -->
    <filter>
        <filter-name>shiroFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <init-param>
            <param-name>targetFilterLifecycle</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>shiroFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

Maven Project Right-Click -update project Error [How to Solve]

Maven project, right-click -update project after the error reported the following solution:

1.Description ResourcePathLocationType

Java compiler level does not match the version of the installed Java project facet.SSMDemo Maven WebUnknownFaceted Project Problem (Java Version Mismatch)

2.Description ResourcePathLocationType

JAX-RS (REST Web Services) 2.0 requires Java 1.7 or newer.SSMDemo Maven Webline 1Maven Java EE Configuration Problem

3.Description ResourcePathLocationType

One or more constraints have not been satisfied.SSMDemo Maven Web line 1Maven Java EE Configuration Problem

 

Solution: Add the following codes in pom.xml

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7(Modify to your own JDK version)</source>
<target>1.7(Modify to your own JDK version)</target>
</configuration>
</plugin>
</plugins>

 

[Solved] Error resolving template [x] template might not exist or might not be accessible by any of the con

1. Recurrence problem

Today, after configuring Shiro + jwt , you can start spring boot normally. However, when calling the auth/login login method, the following error is reported:

2022-08-21 12:35:18.205 [ http-nio-8081-exec-1 ] - [ ERROR ] [ org.thymeleaf.TemplateEngine : 1136 ] - [THYMELEAF][http-nio-8081-exec-1] Exception processing template "auth/login": Error resolving template [auth/login], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [auth/login], template might not exist or might not be accessible by any of the configured Template Resolvers
	at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
	at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
	at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
	at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
	at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:366)
	at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:190)
	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1396)
	at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1141)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1080)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:114)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:112)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:450)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:204)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

Why did this error occur?Let me analyze it step by step.

2. Analyze problems

2.1 check pom dependency

I have configured the following dependencies in the .pom file

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

This dependency is to configure the thymeleaf template engine, which we can use to design the template mail sent.

The above error message is sent by this dependency. Let’s see what the thymeleaf the template engine is?

2.2 detailed explanation of thymeleaf engine

thymeleaf Template Engine
thymeleaf is a modern server-side Java templating engine for web and standalone environments.
The main goal of thymeleaf is to bring elegant, natural templates to your development workflow – HTML that displays correctly in the browser and works as a static prototype, allowing for enhanced collaboration in development teams.
With modules for the Spring Framework, extensive integration with your favorite tools and the ability to plug in your own features, thymeleaf is ideal for modern HTML5 JVM web development – although it still has a lot of work to do.
thymeleaf has the following features.
thymeleaf runs with or without a network, so it can be opened directly in a browser to view static page effects. It supports HTML prototypes and can add other attributes inside HTML tags to enable data rendering.
thymeleaf has an out-of-the-box feature. thymeleaf is the recommended template engine for Spring boot and is displayed directly in html, so the front and back ends can be well separated.
It has the following references in spring boot.
internationalization : rendering different countries’ languages
common page display : such as unified exception page handling, common page handling

2.2 check YML configuration

I found that there is no configuration information of thymeleaf in application.yml. The problem may occur here. Therefore, the following configuration is performed in application.yml

spring:
  thymeleaf:
    cache: false 
    prefix: classpath:/templates 
    encoding: UTF-8 
    suffix: .html 
    mode: HTML 

Configuration Description:

  1. The cache line is to turn off the cache of the page, otherwise we may not see the changes in time after changing the page, the default is true.
  2. prefix is to configure the location of the thymeleaf template.
  3. encoding is to configure the encoding of the thymeleaf document.

In many cases, if thymeleaf dependency is introduced, the problem can be solved by configuring the above information in the YML file. If this cannot solve your problem, you can continue to read my analysis

But after I configured the above information in the application.yml file and spring boot is successfully started, calling the /auth/login method still reported the above error, so where does the problem lie?

3. Solve problems

After repeated breakpoint debugging, I found out where the problem was. Originally, it was in my unified exception handling. My source code is written as follows:

/**
 * @author baoya
 * @datetime 2022/8/10 21:50
 * @desc 
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(value = AuthenticationException.class)
    public ReturnResult incorrectCredentialsException(HttpServletRequest request, AuthenticationException e) {
        log.error("Incorrect username or password: {}, request interface: {}", e, request.getRequestURI());
        return ReturnResult.error(USER_CREDENTIALS_ERROR);
    }
}

Restart spring boot and call the /auth/login method and test with postman as follows.

/**
 * @author baoya
 * @datetime 2022/8/10 21:50
 * @desc 
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(value = AuthenticationException.class)
    public ResponseEntity<ReturnResult> incorrectCredentialsException(HttpServletRequest request, AuthenticationException e) {
        log.error("Incorrect username or password: {}, request interface: {}", e, request.getRequestURI());
        return buildResponseEntity(ReturnResult.error(USER_CREDENTIALS_ERROR));
    }

    /**
     * 
     */
    private ResponseEntity<ReturnResult> buildResponseEntity(ReturnResult apiError) {
        return new ResponseEntity<>(apiError, HttpStatus.valueOf(HttpStatus.BAD_REQUEST.value()));
    }
}

Restart the spring boot and call the /auth/login method. Use the postman test, as shown in the following figure: