Category Archives: Error

[Solved] com.alibaba.druid.pool.DruidDataSource – create connecti

A service deployed in the server docker reported the following error when connecting to the database:

I have searched a lot of information on the Internet, but I can’t solve it by trying various ways,
ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url: jdbc:mysql://10.10.20.16:3306/acs?&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Kolkata, errorCode 0, state 08S01
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

The specific error information is as follows:

ERROR com.alibaba.druid.pool.DruidDataSource – create connection SQLException, url: jdbc:mysql ://10.10.20.16:3306/acs?& amp; useUnicode=true& characterEncoding=UTF-8& zeroDateTimeBehavior=convertToNull& allowMultiQueries=true& serverTimezone=Asia/Kolkata, errorCode 0, state 08S01
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Cause of error:

It may be due to the different versions of JDK. This error message is probably caused by the SSL protocol of MySQL

solution: I tried to remove SSLv3 from java.security in jdk-8 on my local machine and restart the service, but I still couldn’t solve it
finally, add this to the MySQL connection string in the service configuration; Usessl = false, that is, disable SSL, problem solved

[Solved] There are test failures. Please refer to D:\Java_study\springboot\springboot-sugon-3\target\surefire-reports for the individual test results.

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project springboot-sugon-3: There are test failures.
Maven error: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project springboot-sugon-3: There are test failures.
Please refer to D:\Java_study\springboot\springboot-sugon-3\target\surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.**
Solution: Add the following code to pom.xml.

<plugin>  
        <groupId>org.apache.maven.plugins</groupId>  
        <artifactId>maven-surefire-plugin</artifactId>  
        <version>2.22.2</version>  
        <configuration>  
          <skipTests>true</skipTests>  
        </configuration>  
</plugin>  

[Solved] Error getting bean using springboot: no qualifying bean of type ‘xxx’ available

Recently, I encountered a bug in my work.
the project uses springboot, and uses springcontexthloder, getBean (); No qualifying bean of type ‘xxx’ available

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.tension.web.disabledevaluate.service.DisabledEvaluateService' available

Generally, this error indicates that there is no bean available. Check the code carefully to ensure that this class exists and is injected into spring correctly

Controller:

 public Map loadForm(String round,String instanceId) {
 		//error
        DisabledEvaluateService disabledEvaluateService = SpringContextHolder.getBean(DisabledEvaluateService.class);
 }

Service:

@Service
@Transactional(readOnly = true)
public class DisabledEvaluateService extends CrudService<DisabledEvaluateDao, DisabledEvaluate> {
    public DisabledEvaluate getByBjId(Map map){
        return dao.getByBjIdOrInstanceId(map);
    }

After several hours of exploration, we finally found the information on the Internet because we used the devtools hot deployment plug-in. As a result, when the program starts, we use the classloader rewritten by the devtools hot deployment plug-in instead of the Java default classloader. As a result, some classes may not be loaded correctly, resulting in the inability to obtain beans.

Solution:
this error can be solved without using hot deployment plug-in

How to Solve Error: IncompleteElementException: Could not find result map…

Encountered such an error today, record it:

org.apache.ibatis.builder.IncompleteElementException: Could not find result map com.xxx.manager.mapper.ItemMapper.Item

    at org.apache.ibatis.builder.MapperBuilderAssistant.getStatementResultMaps(MapperBuilderAssistant.java:346)
    at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:290)
    at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:109)
    at org.apache.ibatis.session.Configuration.buildAllStatements(Configuration.java:788)
    at org.apache.ibatis.session.Configuration.hasStatement(Configuration.java:758)
    at org.apache.ibatis.session.Configuration.hasStatement(Configuration.java:753)
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.resolveMappedStatement(MapperMethod.java:247)
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:217)
    at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48)
    at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
    at com.sun.proxy.$Proxy22.select(Unknown Source)
    at com.xxxx.manager.service.impl.BaseServiceImpl.getList(BaseServiceImpl.java:97)
    at com.xxxx.manager.service.impl.BaseServiceImpl$$FastClassBySpringCGLIB$$dae8e2b1.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
    at com.xxxx.manager.service.impl.ItemServiceImpl$$EnhancerBySpringCGLIB$$5180168e.getList(<generated>)
    at com.xxxx.manager.TestMybaitsMapper.testGetList (TestMybaitsMapper.java: 30 )
    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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.xxxx.manager.mapper.ItemMapper.Item
    at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:888)
    at org.apache.ibatis.session.Configuration.getResultMap(Configuration.java:640)
    at org.apache.ibatis.builder.MapperBuilderAssistant.getStatementResultMaps(MapperBuilderAssistant.java:344)
    ... 48 more

The last finding is: write resultType as resultMap

Maven package error: [WARNING] The POM for xxx is missing, no dependency inform

When maven install or package, execute warning and error:

[WARNING] The POM for com.xx-base:jar:1.0 is missing, no dependency information available

[ERROR] Failed to execute goal on project xx-mobi: Could not resolve dependencies for project com.xx-mobi:jar:1.0: Failed to collect dependencies at xx-base:jar:1.0: Failed to read artifact descriptor for xx- base:jar:1.0: Could not find artifact xx-root:pom:1.0 in geotoolrepo…

 

This is because the sub-modules of the maven project did not execute the public modules first when performing installation and packaging related operations. That is, the project has a public module xx-base; the current module that needs to be executed is xx-mobi, then you should install xx-base first, and then perform xx-mobi related operations.

Scenes

As shown in the following figure, a multi-module project created using Maven, a wa-servicemodule, a wa-appmodule, the wa-appmodule depends on the wa-servicemodule, and they are all WebAppDemosub-modules.

Error reporting and analysis

  • Perform packaging for the wa-app module and report [WARNING] The POM for com.mxc:wa-service:jar:1.0-SNAPSHOT is missing, no dependency information available , and the packaging fails.
  • According to the above error message, the preliminary analysis is that the jar package of the dependent wa-service module is not found in the warehouse . So I thought of installing the wa-service module first , and then packaging the wa-app module, but the result is still [WARNING] The POM for com.mxc:wa-service:jar:1.0-SNAPSHOT is missing, no dependency information available , the reason is unknown.

solve

Solution: first execute the install package installation on the parent module WebAppDemo , and then package the wa-app module.
Note: Pack and install the parent module, and all the sub-modules under it will be packaged and installed at the same time. For the above project, after the parent module is packaged and installed, the files of the three modules after packaged and installed can be found in the local warehouse.

Weblogic Start Error: weblogic.management.DeploymentException: weblogic.management.DeploymentException:

After restarting the linux server once, weblogic started inexplicably reporting an error. After checking the log, it was found that a bean class in the deployed project could not be loaded.

1. Then manually delete the deployed project, first

domais/servers/AdminServer/upload

Delete the uploaded project; start an error

<Jul 13, 2016 10:01:47 AM CST> <Error> <Deployer> <BEA-149605> <Failed to create App/Comp mbeans for AppDeploymentMBean mmp. Error - weblogic.management.DeploymentException: .
weblogic.management.DeploymentException: 
    at weblogic.servlet.internal.WarDeploymentFactory.findOrCreateComponentMBeans(WarDeploymentFactory.java:69)
    at weblogic.application.internal.MBeanFactoryImpl.findOrCreateComponentMBeans(MBeanFactoryImpl.java:48)
    at weblogic.application.internal.MBeanFactoryImpl.createComponentMBeans(MBeanFactoryImpl.java:110)
    at weblogic.application.internal.MBeanFactoryImpl.initializeMBeans(MBeanFactoryImpl.java:76)
    at weblogic.management.deploy.internal.MBeanConverter.createApplicationMBean(MBeanConverter.java:89)
    Truncated. see log file for complete stacktrace
Caused By: java.util.zip.ZipException: Error opening file - /domains/borzmmp/servers/AdminServer/upload/mmp.war Message - error in opening zip file
    at weblogic.servlet.utils.WarUtils.existsInWar(WarUtils.java:87)
    at weblogic.servlet.utils.WarUtils.isWebServices(WarUtils.java:76)
    at weblogic.servlet.internal.WarDeploymentFactory.findOrCreateComponentMBeans(WarDeploymentFactory.java:61)
    at weblogic.application.internal.MBeanFactoryImpl.findOrCreateComponentMBeans(MBeanFactoryImpl.java:48)
    at weblogic.application.internal.MBeanFactoryImpl.createComponentMBeans(MBeanFactoryImpl.java:110)
    Truncated. see log file for complete stacktrace
>

2. Modify the configuration file

/soft/Oracle/Middleware/user_projects/domains/borzmmp/config 

Delete the following code in this file

  <app-deployment>
    <name>yitong-mmc</name>
    <target>AdminServer</target>
    <module-type>war</module-type>
    <source-path>servers/AdminServer/upload/yitong-mmc.war</source-path>
    <security-dd-model>DDOnly</security-dd-model>
  </app-deployment>

3. An error is reported when starting up

<Jul 13, 2016 10:05:22 AM CST> <Emergency> <Security> <BEA-090087> <Server failed to bind to the configured Admin port. The port may already be used by another process.> 
<Jul 13, 2016 10:05:22 AM CST> <Error> <Server> <BEA-002606> <Unable to create a server socket for listening on channel "Default[2]". The address 127.0.0.1 might be incorrect or another process is using port 7001: java.net.BindException: Address already in use.> 
<Jul 13, 2016 10:05:22 AM CST> <Error> <Server> <BEA-002606> <Unable to create a server socket for listening on channel "Default[3]". The address 0:0:0:0:0:0:0:1 might be incorrect or another process is using port 7001: java.net.BindException: Address already in use.> 
<Jul 13, 2016 10:05:22 AM CST> <Error> <Server> <BEA-002606> <Unable to create a server socket for listening on channel "Default[1]". The address fe80:0:0:0:20c:29ff:fe93:a0f1 might be incorrect or another process is using port 7001: java.net.BindException: Address already in use.> 
<Jul 13, 2016 10:05:22 AM CST> <Critical> <WebLogicServer> <BEA-000362> <Server failed. Reason: Server failed to bind to any usable port. See preceeding log message for details.> 
<Jul 13, 2016 10:05:22 AM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FAILED> 
<Jul 13, 2016 10:05:22 AM CST> <Error> <WebLogicServer> <BEA-000383> <A critical service failed. The server will shut itself down> 
<Jul 13, 2016 10:05:22 AM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FORCE_SHUTTING_DOWN>

Haha

It turns out that the port is occupied

4. Solve port occupation

[root @ localhost bin] # netstat - apn | grep 7001        
tcp         0       0 ::: 7001                      ::: * LISTEN       22458 / java          

I found it at a glance among thousands of people, let me take a look at what the hell it is

[root@localhost bin]# ps -aux|grep 22458
root     13517  0.0  0.0 103252   840 pts/1    S+   10:10   0:00 grep 22458
root     22458  0.0  8.7 8759556 1425968 ?     Sl   Jun27  19:09 /usr/java/jdk1.8.0_66/bin/java -Djava.util.logging.config.file=/root/.IntelliJIdea2016.1/system/tomcat/Unnamed_mmp-sdk/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:37150,suspend=y,server=n -Dcom.sun.management.jmxremote= -Dcom.sun.management.jmxremote.port=1098 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=127.0.0.1 -Djava.endorsed.dirs=/soft/apache-tomcat-7.0.67/endorsed -classpath /soft/apache-tomcat-7.0.67/bin/bootstrap.jar:/soft/apache-tomcat-7.0.67/bin/tomcat-juli.jar -Dcatalina.base=/root/.IntelliJIdea2016.1/system/tomcat/Unnamed_mmp-sdk -Dcatalina.home=/soft/apache-tomcat-7.0.67 -Djava.io.tmpdir=/soft/apache-tomcat-7.0.67/temp org.apache.catalina.startup.Bootstrap start

It turns out that Intellij was installed on the server before, and I forgot to turn it off after startup.

Anger

kill -9

Restart everything is ok

UserMapper.selectByPrimaryKey-Inline error solution

The reason for the error, and the solution:

 @Id is added to the id attribute of the entity class, and mybatis doesn’t know which is the primary key anymore.

I wrote a demo

public interface UserMapper extends Mapper<User>

Note that it inherits Mapper, which already has a selectByPrimaryKey method
Then I call

User u = userMapper.selectByPrimaryKey(1);

Gave me an error and cried

The error message is as follows

DEBUG - Fetching JDBC Connection from DataSource

DEBUG - JDBC Connection [jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8, UserName=root@localhost , MySQL Connector Java] will not be managed by Spring

DEBUG - ==>  Preparing: SELECT id,name,age FROM User WHERE (id = ? AND name = ? AND age = ? ) 

DEBUG - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3b71d667]

DEBUG - Returning JDBC Connection to DataSource

DEBUG - Resolving exception from handler [public java.lang.String com.zqws.app.trade.controller.TestController.test(org.springframework.ui.Model,com.github.pagehelper.PageInfo)]: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

### The error may exist in com/zqws/app/trade/mapper/UserMapper.java (best guess)

### The error may involve com.zqws.app.trade.mapper.UserMapper.

selectByPrimaryKeyInline

### The error occurred while setting parameters

### SQL: SELECT id,name,age FROM User WHERE

(id = ? AND name = ? AND age = ?

 )

### Cause: java.lang.ClassCastException:

java.lang.Integer cannot be cast to java.lang.String

DEBUG - Resolving exception from handler [public java.lang.String com.zqws.app.trade.controller.TestController.test(org.springframework.ui.Model,com.github.pagehelper.PageInfo)]: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

### The error may exist in com/zqws/app/trade/mapper/UserMapper.java (best guess)

### The error may involve com.zqws.app.trade.mapper.UserMapper.selectByPrimaryKey-Inline

### The error occurred while setting parameters

### SQL: SELECT id,name,age FROM User WHERE (id = ? AND name = ? AND age = ? )

### Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

DEBUG - Resolving exception from handler [public java.lang.String com.zqws.app.trade.controller.TestController.test(org.springframework.ui.Model,com.github.pagehelper.PageInfo)]: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

### The error may exist in com/zqws/app/trade/mapper/UserMapper.java (best guess)

### The error may involve com.zqws.app.trade.mapper.UserMapper.selectByPrimaryKey-Inline

### The error occurred while setting parameters

### SQL: SELECT id,name,age FROM User WHERE (id = ? AND name = ? AND age = ? )

### Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

DEBUG - Could not complete request

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

### The error may exist in com/zqws/app/trade/mapper/UserMapper.java (best guess)

### The error may involve com.zqws.app.trade.mapper.UserMapper.selectByPrimaryKey-Inline

### The error occurred while setting parameters

### SQL: SELECT id,name,age FROM User WHERE (id = ? AND name = ? AND age = ? )

### Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)

at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)

at com.sun.proxy.$Proxy86.selectOne(Unknown Source)

at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163)

at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68)

at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)

at com.sun.proxy.$Proxy92.selectByPrimaryKey(Unknown Source)

at com.zqws.app.trade.controller.TestController.test(TestController.java:25)

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:483)

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:777)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)

at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)

at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)

at org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun (NioEndpoint.java: 1736 )

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695)

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)

Caused by: org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

### The error may exist in com/zqws/app/trade/mapper/UserMapper.java (best guess)

### The error may involve com.zqws.app.trade.mapper.UserMapper.selectByPrimaryKey-Inline

### The error occurred while setting parameters

### SQL: SELECT id,name,age FROM User WHERE (id = ? AND name = ? AND age = ? )

### Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:66)

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:483)

at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)

... 52 more

Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

at org.apache.ibatis.type.StringTypeHandler.setNonNullParameter(StringTypeHandler.java:26)

at org.apache.ibatis.type.BaseTypeHandler.setParameter (BaseTypeHandler.java: 50 )

at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:81)

at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:80)

at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:61)

at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:74)

at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)

at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)

at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)

at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)

at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)

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:483)

at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)

at com.github.pagehelper.SqlUtil._processPage(SqlUtil.java:351)

at com.github.pagehelper.SqlUtil.processPage(SqlUtil.java:329)

at com.github.pagehelper.PageHelper.intercept(PageHelper.java:150)

at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:60)

at com.sun.proxy.$Proxy93.query(Unknown Source)

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:483)

at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)

at tk.mybatis.mapper.mapperhelper.MapperOnceInterceptor.intercept(MapperOnceInterceptor.java:81)

at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:60)

at com.sun.proxy.$Proxy93.query(Unknown Source)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)

... 59 more

DEBUG - Returning cached instance of singleton bean 'sqlSessionFactory'

August 01, 2015 5:02:43 PM org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet [springmvc] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

### The error may exist in com/zqws/app/trade/mapper/UserMapper.java (best guess)

### The error may involve com.zqws.app.trade.mapper.UserMapper.selectByPrimaryKey-Inline

### The error occurred while setting parameters

### SQL: SELECT id,name,age FROM User WHERE (id = ? AND name = ? AND age = ? )

### Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String] with root cause

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

at org.apache.ibatis.type.StringTypeHandler.setNonNullParameter(StringTypeHandler.java:26)

at org.apache.ibatis.type.BaseTypeHandler.setParameter (BaseTypeHandler.java: 50 )

at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:81)

at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:80)

at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:61)

at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:74)

at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)

at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)

at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)

at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)

at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)

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:483)

at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)

at com.github.pagehelper.SqlUtil._processPage(SqlUtil.java:351)

at com.github.pagehelper.SqlUtil.processPage(SqlUtil.java:329)

at com.github.pagehelper.PageHelper.intercept(PageHelper.java:150)

at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:60)

at com.sun.proxy.$Proxy93.query(Unknown Source)

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:483)

at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)

at tk.mybatis.mapper.mapperhelper.MapperOnceInterceptor.intercept(MapperOnceInterceptor.java:81)

at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:60)

at com.sun.proxy.$Proxy93.query(Unknown Source)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:66)

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:483)

at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)

at com.sun.proxy.$Proxy86.selectOne(Unknown Source)

at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163)

at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68)

at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)

at com.sun.proxy.$Proxy92.selectByPrimaryKey(Unknown Source)

at com.zqws.app.trade.controller.TestController.test(TestController.java:25)

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:483)

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:777)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)

at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)

at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)

at org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun (NioEndpoint.java: 1736 )

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.r

un (NioEndpoint.java: 1695 )

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)

[Solved] VUE Use Filters Error: [Vue warn]: Error in render: “TypeError: Cannot read property ‘toFixed’ of undefined”

When using the VUE filter, I encountered an error from the console: vue.esm.js?efeb:628 [Vue warn]: Error in render: "TypeError: Cannot read property 'toFixed' of undefined"

It is found that undefined is an error in the filtermoneyFilters.js

The reason for the error is because the filter is executed twice.

The first time is when no data is passed in the background, the filter function is executed once. And there is no data at this time, and the filter function passed into the filter function is undefined. The error is generated at this time

The second time is to pass data in the background.After rendering the data, the filter function is executed once.

The solution is to make a judgment in the filter to pass in the parameters. If the passed parameter is undefined or other values ​​that are implicitly converted to false, the function will jump out and no longer be executed.

Code

export  function  toMoney ( money ) {

    if (!money) { //A data transfer judgment is performed here. If the passed in is a null value, return its empty string. Solve its problem
        return  '' ;
    }
    return money.toFixed( 2 );
}

Report Duplicate keys detected: ‘0’. This may cause an update error in VUE and the solution

vue version: 2.x

First, Duplicate keys detected: ‘0’. This may cause an update error is an error caused by Vue finding that the key is not unique.

Translated into Chinese is probably: Duplicate key detected: ‘0’. ‘0’ may cause an update error.

There are also some other solutions found on the Internet. It is solved by manual modification :key, such as concatenating strings. Because in order to solve the problem, the data is manually modified. Personally, it should not be like this.

The last problem I found: On the same layer of DOM node, vue found that the key is not unique. It will report an error. But if you are not using the v-for loop in the same layer of DOM, you will not report an error. So, if it is not in the same layer of DOM The for loop on the above can ensure the uniqueness of the key. (The role of the key has not been touched yet.)

And the solution:

What I think of is to add an extra layer of html tags, but this will create more non-semantic tags, just to ensure the uniqueness of the key and add tags, but I prefer to do this instead of manually splicing strings.

Or manual splicing recommended on the Internet. But: the key is manually modified. If you forget: the key data is different from the original data. It is not so convenient to maintain in the later stage.

Sample Code

    < script  type = "text/javascript"  src = "./vue_localtion/vue.js" > </ script >
</ head >

< body >
    < div  id = "app" >
        < p  v-for = '(item,index) in cyclicData'  :key = 'index' > {{item}} </ p >
        < hr >
        < div > <!--If you remove this layer of div, an error will be reported. Because on the same layer of DOM node: the value of the key is repeated -->
            < p  v-for = '(item,index) in sortCyclicData'  :key = 'index' > {{item}} </ p >
        </ div >
    </ div >

    < script >
        let app = new Vue({
            el : '#app' ,
            data : {
                cyclicData : [ 1 , 8 , 3 , 7 , 5 , 6 ],
            },
            computed : {
                sortCyclicData : function () {
                    return  this .cyclicData.sort( function ( num1, num2 ) {
                        return num1-num2;
                    })
                }
            },
        })
    </ script >

 

UnknownHostException error when connecting to Mongo cluster Java

Today, a timeout error was reported when connecting to the Mongo cluster in Java, but it was able to connect when the local client was connected to a single node. The specific error reported is as follows:

Caused by: com.mongodb.MongoTimeoutException:
Timed out after 60000 ms while waiting for a server that matches
{serverSelectors=[ReadPreferenceServerSelector{readPreference=primaryPreferred}, LatencyMinimizingServerSelector{acceptableLatencyDifference=15 ms}]}.
Client view of cluster state is {type=ReplicaSet, servers=[{address=mongo.50:27017, type=Unknown,state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket},
caused by {java.net.UnknownHostException: mongo.50}},
{address=mongo.66:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket},
caused by {java.net.UnknownHostException: mongo.66}},
{address=mongo.67:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused
by {java.net.UnknownHostException: mongo.67}}]

 

I checked the IP address in the configuration file and there is no problem, but why does the error that mongo.50, mongo.66 and mongo.67 can’t resolve the three addresses appear in the error report? How did these three addresses come from? The Mongo cluster consists of 3 machines, and the last IPs are 50, 66, and 67 respectively. I guess it might be a problem with the cluster configuration.

There is a similar question on StackOverflow: (https://stackoverflow.com/questions/27607773/com-mongodb-mongotimeoutexception-when-using-mongoclient-with-list-serveraddress)

In fact, because of Mongo’s replica set method, the client decides which Mongo server to connect to. Each Mongo service listens to each other. If the main service is found to be down, it will elect a new master. The client will be notified when the new master is confirmed. The domain name is used when creating the replica set, so the primary address obtained by the client is also the domain name.
Therefore, the address configured in the mongo.50 cluster configured by the Java client cannot be resolved.
Then you only need to do one more step below to configure the hosts file of the machine. Corresponding to the corresponding IP and mongo.50 address can be resolved.

Or remove?replicaSet=rs0,The following is a summary of the main node, i.e., only the master node is connected, not the replica.