Tag Archives: java

[Solved] Error building SqlSession.The error may exist in XXXXXMapper/xml

 

Problem description

describe the problems encountered in the project here:
caused by: org.apache.ibatis.exceptions.PersistenceException:

Error building SqlSession.

The error may exist in XXXXXMapper/xml

Cause analysis:

1. Cannot find mapper file associated with; Error in mapper’s fully qualified name (primary cause)


Solution:

1. Check whether the corresponding mapper file name is correct
2. Check whether the fully qualified name corresponding to mapper file in the configuration file is correct. The fully qualified name is separated by “/”
quick copy file fully qualified name:
right click the target file as follows

[Solved] RabbitMQ Error: Error creating bean with name ‘rabbitConnectionFactory‘ defined in class path resource

1. Error Messages:

Error creating bean with name 'rabbitConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.CachingConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Address 192.168.74.128:5672:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
2. Reason
Address 192.168.74.128:5672:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
Identified as ipv6, rabbitmq should also support IPV6
3. Solution
application.yml File

 rabbitmq:
  #host: 192.168.74.128:5672//去掉端口
  host: 192.168.74.128
  username: admin
  password: 123123
  virtual-host: /

[Solved] jvm 1 Error occurred during initialization of VM Could not reserve enough space for object heap

When I double click activemq.bat to start MQ and reports the following error,

The reason is caused by insufficient memory. You can use Ctrl + Alt + Del –> Task manager, close some process tasks to make room, and then start again

 

Solution:

Method 1:

There may be other similar situations, which may also be caused by the non rent of memory

For example, the error of starting Kafka package in the following figure: Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c0000000, 1073741824, 0) failed; error=’The page file is too small and it can be operated.’ (DOS error/errno=1455)

Through the method agreed above, you can start successfully

 

Method 2:

  1. Open the idea location and select the idea64.exe.vmoptions file.

  1. Open this file as a text document
  2. Modify the parameters to be larger

 

Notice:

  1. Restart the idea and project after making changes
  2. If it does not take effect, modify the other one under the same folder as shown in Figure 1 below
  3. If it does not take effect yet, modify the file in this path in the C drive, as shown in Figure 2 below

[Solved] seata Error: io.seata.rm.datasource.exec.LockConflictException: get global lock fail, xid:xxx, lockKeys:xxx

io.seata.rm.datasource.exec.LockConflictException: get global lock fail, xid:xxx, lockKeys:xxx
the error here shows that the global lock acquisition failed
in fact, it may not be the problem of global lock. Here, you can directly check the detailed error in the log file of Seata server

determine the error information

the error of Seata here is because the table field of Seata database is smaller by default and longer_ the table_name will be OK.

Idea2022 automatic generate poji error [How to Solve]

Error Messages:
Generate POJOs. groovy: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script6. groovy: 29: unable to resolve class FileDemo @ line 29, column 3.  new FileDemo(dir, className + ".java"). withPrintWriter { out -> generate(out, className,  fields) } ^ 1 error at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:295) at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:914) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:627) at  groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389) at groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332) at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163) at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154) at  groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:314) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:257) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:336) at  org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:153) at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) in IdeScriptEngineManagerImpl$EngineImpl.lambda$eval$1(IdeScriptEngineManagerImpl.java:246)

 

Solution: Delete the old script and create a new one as below:
import com.intellij.database.model.DasTable
import com.intellij.database.util.Case
import com.intellij.database.util.DasUtil

/*
 * Available context bindings:
 *   SELECTION   Iterable<DasObject>
 *   PROJECT     project
 *   FILES       files helper
 */

packageName = "com.sample;"
typeMapping = [
  (~/(?i)int/)                      : "long",
  (~/(?i)float|double|decimal|real/): "double",
  (~/(?i)datetime|timestamp/)       : "java.sql.Timestamp",
  (~/(?i)date/)                     : "java.sql.Date",
  (~/(?i)time/)                     : "java.sql.Time",
  (~/(?i)/)                         : "String"
]

FILES.chooseDirectoryAndSave("Choose directory", "Choose where to store generated files") { dir ->
  SELECTION.filter { it instanceof DasTable }.each { generate(it, dir) }
}

def generate(table, dir) {
  def className = javaName(table.getName(), true)
  def fields = calcFields(table)
  new File(dir, className + ".java").withPrintWriter { out -> generate(out, className, fields) }
}

def generate(out, className, fields) {
  out.println "package $packageName"
  out.println ""
  out.println ""
  out.println "public class $className {"
  out.println ""
  fields.each() {
    if (it.annos != "") out.println "  ${it.annos}"
    out.println "  private ${it.type} ${it.name};"
  }
  out.println ""
  fields.each() {
    out.println ""
    out.println "  public ${it.type} get${it.name.capitalize()}() {"
    out.println "    return ${it.name};"
    out.println "  }"
    out.println ""
    out.println "  public void set${it.name.capitalize()}(${it.type} ${it.name}) {"
    out.println "    this.${it.name} = ${it.name};"
    out.println "  }"
    out.println ""
  }
  out.println "}"
}

def calcFields(table) {
  DasUtil.getColumns(table).reduce([]) { fields, col ->
    def spec = Case.LOWER.apply(col.getDataType().getSpecification())
    def typeStr = typeMapping.find { p, t -> p.matcher(spec).find() }.value
    fields += [[
                 name : javaName(col.getName(), false),
                 type : typeStr,
                 annos: ""]]
  }
}

def javaName(str, capitalize) {
  def s = com.intellij.psi.codeStyle.NameUtil.splitNameIntoWords(str)
    .collect { Case.LOWER.apply(it).capitalize() }
    .join("")
    .replaceAll(/[^\p{javaJavaIdentifierPart}[_]]/, "_")
  capitalize || s.length() == 1? s : Case.LOWER.apply(s[0]) + s[1..-1]
}

[Solved] Seata Error: endpoint format should like ip:port

Abnormal scene

Failed to get available servers: endpoint format should like ip:port


Cause of error

Ensure that the versions are consistent. The server version downloaded by Seata must be consistent with the dependent version introduced by Maven

Locally installed version

I use seata1 locally Version 4.0


Maven import version

The imported version is cloud version 2.2.7, which encapsulates Seata

Correspondence between Seata and cloud


How to solve

Just keep the locally installed version of Seata consistent with the version imported by Maven. After I change the imported version of maven, I can introduce Seata version 1.4.0.

 <!-- https://mvnrepository.com/artifact/io.seata/seata-spring-boot-starter -->
 <dependency>
     <groupId>io.seata</groupId>
     <artifactId>seata-spring-boot-starter</artifactId>
     <version>1.4.0</version>
 </dependency>

Of course, you can also go to the official website of Seata to download the corresponding seata1.3 version to Maven.

[Solved] Project Startup Error: Redis health check failed:Unable to connect to localhost6379

Error reporting details

Analysis and solution

There is no connection of Redis in my project, so it’s strange to report an error. Combined with the sentence redis health check failed , I guess maybe someone introduced Redis, and then do the health check of redis.

Solution: Configurate as below in application.yml:

# Disable Actuator Monitoring of Redis Connections
management:
  health:
    redis:
      enabled: false

[Solved] MongoDB Error: Command failed with error 251 (NoSuchTransaction)

Recently, I encountered an online bug. Accessing a specific interface will cause occasional exceptions. After checking the log, it is found that an error is reported during the operation of mongodb. The error information is as follows:

error message: Command failed with error 251 (NoSuchTransaction): 'Given transaction number 115 does not match any in-progress transactions. The active transaction number is 114' on server xx.xx.xx.xx:xxxx. The full response is {"errorLabels": ["TransientTransactionError"], "ok": 0.0, "errmsg": "Given transaction number 115 does not match any in-progress transactions. The active transaction number is 114", "code": 251, "codeName": "NoSuchTransaction"}

Through searching and troubleshooting, the problem was located to be due to processing MongoDB operations where two requests in the same transaction are sent to the DB at the same time, with the probability of generating the following scenario.

1. request 1 and request 2 are sent to Mongo at the same time and start execution
2. Request 1 is still executing and request 2 has completed
3. Since request 1 is not yet completed, the transaction has not really started at DB level, so request 2 cannot end normally (that is why the error states that transaction id 115 cannot be found, because the transaction is not yet registered in DB), resulting in transaction rollback and throwing exceptions
4. request 1 execution is complete, but the transaction has been rolled back, the operation is invalid
Reviewing the code, we found that the reason why two requests are sent to DB at the same time is that the zipWith() method is used for data merging. The feature of this method is that it will request two data to be merged to the database at the same time, which will trigger the aforementioned problem when operating Mongo.

The solution is very simple, just use the zipWhen() method instead. zipWhen will block and wait for the first data requested to arrive before requesting the second data, which perfectly circumvents this problem.

[Solved] Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderA

The error information is as follows:

2022-04-21 17:43:26.473 ERROR [em-service,,,] 17272 --- [           main] org.springframework.boot.SpringApplication : Application run failed

java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:180)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:271)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:91)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:330)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
    at com.ey.fssc.em.EmApplication.main(EmApplication.java:30)
Caused by: java.lang.reflect.MalformedParameterizedTypeException: null
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:58)
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:51)
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:92)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.generics.repository.MethodRepository.getReturnType(MethodRepository.java:68)
    at java.lang.reflect.Method.getGenericReturnType(Method.java:255)
    at org.springframework.core.MethodParameter.getGenericParameterType(MethodParameter.java:419)
    at org.springframework.core.SerializableTypeWrapper$MethodParameterTypeProvider.getType(SerializableTypeWrapper.java:317)
    at org.springframework.core.SerializableTypeWrapper.forTypeProvider(SerializableTypeWrapper.java:137)
    at org.springframework.core.ResolvableType.forType(ResolvableType.java:1384)
    at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1285)
    at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1251)
    at org.springframework.core.ResolvableType.forMethodReturnType(ResolvableType.java:1194)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:779)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:659)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:627)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1489)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1012)
    at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:180)
    at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:160)
    at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanType(BeanTypeRegistry.java:153)
    at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.updateTypesIfNecessary(BeanTypeRegistry.java:215)
    at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.getNamesForType(BeanTypeRegistry.java:115)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:265)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:254)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:196)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:116)
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
    ... 17 common frames omitted

By:

at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64)

I thought the PropertyPlaceholderAutoConfiguration class didn’t match automatically. After checking, it’s not the problem.

Then by:

Caused by: java.lang.reflect.MalformedParameterizedTypeException: null
	at java.lang.reflect.Method.getGenericReturnType(Method.java:255)
	at org.springframework.core.MethodParameter.getGenericParameterType(MethodParameter.java:419)

Find the problem that may be the type mismatch, go to the breakpoint where the error occurs, and debug:

From the figure, you can see that when redis does the configuration, the type returned is GenericObjectPoolConfig<? >, search the code and find where redis configures the data source.

Defining the return type is indeed GenericObjectPoolConfig<? >, however, clicking GenericObjectPoolConfig jumps to:

I found that the referenced class, surprisingly GenericObjectPoolConfig after not with a generic, so strange!

Could it be a version problem? So, I checked the project dependency tree and found that I was right in guessing that two different versions of commons-pool jars had been introduced.

Checking the code, in version 2.8.0, GenericObjectPoolConfig<T> with generic type is used.

When the problem is found, the jar package of version 2.5.0 is excluded from the POM dependency.

Restart the project, normal.

[Solved] xxl-job Error: xxl-rpc remoting error(connect timed out)

Unable to register due to connection using local network.

 

Error reporting information:

address:  http://192.168.x.xxx:9999/ code: 500 msg: xxl-rpc remoting error(connect timed out), for url: http://192.168.x.xxx:9999/run

 

Solution:

1. Change automatic registration to manual registration
2. Use intranet penetration tool
3. Fill in the manually registered address as the address of Intranet penetration

[Solved] IDEA Add maven Project Error: Error:(3,21)java: Package javax.servletdoes not exist

1. Error in adding Maven project in idea: Java: package javax Servlet does not exist. As shown in the figure:

2. Solution

1. In file — > Project Structure –> Make changes in modules

2. Select dependencies in modules and click + — > Jars or directories to add

3. Select the local Tomcat installation path, go to the lib folder and select: jsp-api.jar and servlet-ap.jar, then click OK, we can see two more packages, click Apply OK, the following figure.

4. Redeploy the project to run successfully.

[Solved] Command line is too long. Shorten command line for XXXXXXXTest.rmLogRecordOver Error running

The following error is reported when the test case is started:

Command line is too long. Shorten command line for XXXXXXTest. or also for JUnit default configuration?
Error running ‘XXXXXXXXXX.rmLogRecordOverDue’:

Error:Command line is too long
Solution 1:
Modify workspace.xml file,  add the following in <component name="PropertiesComponent">:

<property name="dynamic.classpath" value="true" />

It is also possible that the configuration file cannot be modified and will be automatically deleted after modification, so you can see solution 2

Solution 2:

Modify the startup scheme of local test cases as jar

select

finally select jar mainfest to start