Tag Archives: java

Connect to the repository by using the database resource library!

Connect to the repository by using the database resource library!

The following is a screenshot of the overall error report

The following is a screenshot of the overall error report

Since you can connect to the database locally, the first thing you think of after reporting this error is MySQL connector- java.jar Is 5.7.27 not supported?After replacing several jar packages, it’s fruitless…
Immediately added a few groups to ask, or fruitless…

In the end, I had no choice but to debug by myself… ing…

When debugging to this step, the exception appears. Then put its SQL into the tool to execute, and report an error that the table does not exist. Finally, it is found that the table name in the database is lowercase while the table name of the query statement is uppercase.
OK. Found the problem…

Solution: find [mysqld] and add a line below it: lower_ case_ table_ Names = 1, (1 means ignore case, 0 means resolve case). As shown in the figure below

Restart mysql. That’s it. I’m afraid I’ll forget this pit.

Error creating bean with name ‘sqlsessionfactory’ defined in class path resource

Today, I made an error when integrating mybatis with spring, as follows:

Caused by: org.springframework.beans . factory.BeanCreationException :

Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [config/ applicationContext.xml ]:

Cannot resolve reference to bean ‘config/ mybatis.xml ‘ while setting bean property ‘configLocation’;

nested exception is org.springframework.beans . factory.NoSuchBeanDefinitionException : No bean named ‘config/ mybatis.xml ‘ is defined

My English is not very good. I understand it in general applicationContext.xml There is an error registering configlocation in

<bean id=”sqlSessionFactory” class=” org.mybatis.spring .SqlSessionFactoryBean”>
<property name=”dataSource” ref=”dataSource”></property>
<property name=”configLocation” ref=”config/ mybatis.xml “></property>
</bean>

After a careful examination of the code, I found that there was something wrong. Alas, the correct code is as follows

<bean id=”sqlSessionFactory” class=” org.mybatis.spring .SqlSessionFactoryBean”>
<property name=”dataSource” ref=”dataSource”></property>
<property name=”configLocation” value=”config/ mybatis.xml “></property>
</bean>

Give me a fulcrum, I can pry the whole earth, give me a mistake, I can support the whole project

Idea introduces dependency and starts jar error in opening zip file

Question:

reason:

When Maven download is dependent, the jar may not be downloaded to the local normally due to network reasons. If you start the project reference, an error will be reported, and the local Maven jar cannot be used normally

terms of settlement:

There is a stupid way to find out which jars are open with errors. Find the corresponding jars in the local Maven repository and delete them, pom.xml After testing, no error will be reported

Error: could not create the Java virtual machine

Today, I suddenly encountered a very strange error report. Running Java program on the command line reported an error:

Error:Could not create the Java Virtual Machine.
Error:A Fatal exception has occurred,Program will exit.

Baidu later found that it deleted the java.exe 、 javaw.exe 、 javaws.exe These three running files can be deleted.

The specific reason is unknown.

Error:Could not create the Java Virtual Machine.
Error:A Fatal exception has occurred,Program will exit.

Start Tomcat and report error occurred during initialization of VM could not reserve enough space for object

Double click the mouse to start cattom startup.bat Flashback and operation error occurred, localhost:8080 Naturally, web pages can’t be opened.

1. Can be edited in startup.bat , add a line at the end to view the information of running error. In order to see the information in more detail, let’s change another sentence: find call% executable% “run% CMD_ LINE_ Args% replaces start with run.

pause

2. After joining, save and run startup.bat Error occurred during initialization of VM could not reserve enough space for object heap catalina.sh The Tomcat memory parameter of the file is too large, which is caused by exceeding the total available memory of the machine. You can modify it to an appropriate value.

3. Find it in the bin directory of Tomcat catalina.bat Edit and join, save and exit startup.bat That’s it.

set JAVA_OPTS=-server -Xms512m -Xmx512m  -XX:PermSize=256m -XX:MaxPermSize=256m

Springboot project: error parsing HTTP request header note: further occurrences of HTTP request parsing

There is no error reported after the spirngboot project is started, but when testing the interface with postman, it is found that there will be intermittent (one good and one bad) errors

Error parsing HTTP request header
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException : Invalid character found in method name. HTTP method names must be tokens

Simple appearance is also very normal, it is a success, a mistake, make me at a loss.

Looking up the online materials, 98% of them said that the configuration change of the maximum header value of Tomcat would be good, but springboot is built-in Tomcat,

The method of modification is as follows: sever.tomcat.max -http-header-size=8192

But this configuration has been abandoned by the boot project of higher version,

It can be changed to: sever.max -http-header-size=8192

Full of joy, thought that good, and then found No.

The other 2% said it might be related to the HTTPS protocol, so it could be changed to http.

But I started it locally. It’s always http.

After struggling for a long time, I found that the culprit actually added content length to the header when requesting and gave it a fixed value, so I would report an error. Stupid cry~~

As for the function of modifying the max HTTP header size, I set this to 1 and request again to find that the error reported is not the same as my previous one, but:

Error processing request
org.apache.coyote .http11.HeadersTooLargeException: An attempt was made to write more data to the response headers than there was room available in the buffer.

Error creating bean with name ‘xxcontroller’

Today, when we learn to integrate SSM projects to test whether the framework is available, we will report the above error as soon as we run Maven’s Tomcat,

At the beginning, I thought it was because the service layer annotation was not well written. After checking, I found that there was no error. Finally, in the web.xml It is found that the following param value is wrongly written in the file, and the application in ApplicationContext – *. XML is missing an n.

≪! — load the spring container — & gt;
& lt; context param & gt;
& lt; param name & gt; contextconfiglocation & lt; & param name & gt;
& lt; param value & gt; classpath:spring/applicationContext- *.xml</param-value>
  </context-param>

And less in the transaction aspect

< aop:config>
< aop:advisor advice-ref= “txAdvice”
pointcut=”execution(* cn.itcast .e3 mall.service ..*.*(..))” />
</ aop:config>

Spent a lot of time, finally solved, hope to help you!

Nailing dd.httpRequest report errors error:12

Record: nailing enterprise internal application dd.httpRequest report errors error:12

Error: the emulator on the PC can be accessed normally, but after it is released online, it will be prompted that error:12 Network error
the company requires the development of nailing add in program, I choose the enterprise internal program, the background is Java, the front end is e application
because I have intranet penetration, so I use it locally!
Both the background and the front end download the demo directly from the official website,
in the index.js The path of a URL in is domain + ‘/ Login’

let domain = "	http://sellzys.natapp4.cc";
let url = domain + '/login';

But in dd.httpRequest In the call of

dd.httpRequest({
                    url: url,
                    method: 'POST',
                    data:{
                      authCode:res.authCode
                    },

Cannot write URL
need to write directly

dd.httpRequest({
                    url: 'http://sellzys.natapp4.cc/login',
                    method: 'POST',
                    data:{
                      authCode:res.authCode
                    },

I don’t know the specific reason. I just changed the URL to a path and passed it

pom.xml Depending on the error report, the problem of missing artifact XXX is solved

pom.xml Depending on the error report, the problem of missing artifact XXX is solved

Possible causes pom.xml The dependency configuration format specifies that you manually download the corresponding jar and then install it to the local repository pom.xml After modification

Eclipse imports or creates a new Maven project, pom.xml An error is reported in the configuration file, missing artifact XXX jar. The problem is that the jar package is not found in the specified warehouse after Maven is started.

Possible causes

    there is no such jar package in the central warehouse or local warehouse; some jar packages are charged (for example, Oracle) ojdbc.jar In fact, there is no such resource in Maven Central Library, so it cannot be loaded; pom.xml Configuration items do not match.

pom.xml Dependency configuration format description

// pom.xml
<dependencies>
		<dependency>
			<groupId>Package1</groupId>
			<artifactId>jarName</artifactId>
			<version>versionInJar</version>
		</dependency>
		<dependency>
			<groupId>Package2</groupId>
			<artifactId>jarName2</artifactId>
			<version>1.0.0</version>
		</dependency>
		......
</dependencies>

Groupid: the relative path of the dependent jar package. The parent-child directory is marked with “.” (example: package.packageNext ); artifactid: dependent jar package name; version: dependent jar package version.

Manually download the corresponding jar, and then install it to the local warehouse

    download the corresponding version of the jar package; open the CMD, preferably in the path to be installed (the installation command is more convenient, directly in the address bar of the path to be installed, enter CMD to quickly open the command window); install here. Take Ojdbc14 as an example, after opening CMD, enter the command as follows:

    mvn install:install-file -Dpackaging=jar -DgroupId= com.oracle -DartifactId=ojdbc14 -Dversion=11.2.0.3.0 -Dfile=ojdbc14-11.2.0.3.0.jar -DgeneratePom=true

    Command explanation:
    install: compile and package the project to the local warehouse;
    install file: install file;
    – dgroupid= com.oracle : Specifies that the groupid of the current package is com.oracle ;
    – dartifactid = Ojdbc14: Specifies that the current artifact ID is Ojdbc14;
    – dversion = 11.2.0.3.0: Specifies that the current package version is 11.2.0.3.0;
    – dversion = 11.2.0.3.0 -Dfile = D: ojdbc14-11.2.0.3.0.jar: Specifies the file location of the package to be typed (the reason why you want to open CMD in the path before is to avoid entering an excessively long path);
    – dgeneratepom = true: whether to generate a POM file.

      open the Maven project in eclipse, right-click Maven – & gt; update or click open pom.xml File, right-click Maven – & gt; update for project.

    pom.xml After modification

    <dependency>
    			<groupId>com.oracle</groupId>
    			<artifactId>ojdbc14</artifactId>
    			<version>11.2.0.3.0</version>
    </dependency>
    

Springboot startup error – classnotfound Exception:EnhancerBySpringCGLIB

Error classnotfound in springboot startup Exception:EnhancerBySpringCGLIB

Error information solution

Error information

Spring boot 2.4.1 project, start to report the following error, but start will be normal, although it does not affect the use, but look very boring.

java.lang.ClassNotFoundException: cn.demo.Application$$EnhancerBySpringCGLIB$$310af73e
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at cn.demo.ocean.common.prop.core.spring.SpringConfigPropertiesHandle.handleSpringConfig(SpringConfigPropertiesHandle.java:47)
	at cn.demo.ocean.common.prop.core.spring.ConfigServerPostProcessor.doProcessProperties(ConfigServerPostProcessor.java:305)
	at cn.demo.ocean.common.prop.core.spring.ConfigServerPostProcessor.processProperties(ConfigServerPostProcessor.java:122)
	at cn.demo.ocean.common.prop.core.spring.ConfigServerPostProcessor.postProcessBeanFactory(ConfigServerPostProcessor.java:102)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:299)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:170)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:751)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:569)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
	at cn.demo.Application.main(Application.java:19)
	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.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
java.lang.ClassNotFoundException: cn.demo.config.Swagger2Config$$EnhancerBySpringCGLIB$$589bf224
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at cn.demo.ocean.common.prop.core.spring.SpringConfigPropertiesHandle.handleSpringConfig(SpringConfigPropertiesHandle.java:47)
	at cn.demo.ocean.common.prop.core.spring.ConfigServerPostProcessor.doProcessProperties(ConfigServerPostProcessor.java:305)
	at cn.demo.ocean.common.prop.core.spring.ConfigServerPostProcessor.processProperties(ConfigServerPostProcessor.java:122)
	at cn.demo.ocean.common.prop.core.spring.ConfigServerPostProcessor.postProcessBeanFactory(ConfigServerPostProcessor.java:102)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:299)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:170)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:751)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:569)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
	at cn.demo.Application.main(Application.java:19)
	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.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)

solve

Baidu has failed for many times, so we can only read the error report carefully. Last line found:

at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)

Doubt is the problem of devtools, and then pom.xml Devtools dependency removal in

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
    <optional>true</optional>
</dependency>

It’s solved (⊙ o ⊙)

Getoutputstream() has already been called for this response

java.lang.IllegalStateException: getOutputStream() has already been called for this response
        at org.apache.catalina.connector.Response.getWriter(Response.java:581)
        at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:227)
        at com.alibaba.fastjson.serializer.ASMSerializer_10_ResponseFacade.write(Unknown Source)
        at com.alibaba.fastjson.serializer.JSONSerializer.writeWithFieldName(JSONSerializer.java:333)
        at com.alibaba.fastjson.serializer.JSONSerializer.writeWithFieldName(JSONSerializer.java:311)
        at com.alibaba.fastjson.serializer.ObjectArrayCodec.write(ObjectArrayCodec.java:118)
        at com.alibaba.fastjson.serializer.JSONSerializer.write(JSONSerializer.java:285)
        at com.alibaba.fastjson.JSON.toJSONString(JSON.java:740)
        at com.alibaba.fastjson.JSON.toJSONString(JSON.java:678)
        at com.alibaba.fastjson.JSON.toJSONString(JSON.java:643)

Problem scenario: block the print request parameters in the class, and use jsonobject to convert httpservletresponse to a string.

private Object printLog(ProceedingJoinPoint joinPoint) throws Throwable {
   String ipAddress = IpAddressUtil.getIpAddress(request);
   String url = request.getRequestURL().toString();
   String params = JSON.toJSONString(joinPoint.getArgs());
   Object proceed = joinPoint.proceed();
   String result = JSON.toJSONString(proceed);
   log.info("\n-----------------------------------------------------------------------------------------------" +
          "\n<> IP:{} " +
          "\n<> url:{} " +
          "\n<> params:{} " +
          "\n<> result:{}" +
          "\n-----------------------------------------------------------------------------------------------" , ipAddress, url, params, result);
   return proceed;
}

Cause problem: the interface has two parameters, one of which is httpservletresponse

At this time, the interceptor will report an error when printing parameters.
When checking the debug, it is found that there is an error in calling getwriter after getting the object through reflection, which leads to an exception in JSON transformation
Alibaba JSON is getting the object serializer class asmserializer_ 1_ Resposefacade called ResponseFacade.getWriter ()
write javaBean error, fastjson version 1.2.58, class com.sun.proxy .$Proxy128, method : getWriter

Error usage code:

HttpServletResponse response;
JSON.toJSONString (response);
to sum up, jsonobject is unable to serialize httpservletresponse, thus reporting the above exception