常见报错

问题1、

Tomcat7启动时报
七月 21, 2017 11:31:36 上午 org.apache.catalina.deploy.WebXml setVersion
警告: Unknown version string [3.1]. Default version will be used.

Tomcat7支持3.0和以下的版本,3.1的话用tomcat8
换tomcat8 问题解决

web.xml的配置:

“<”?xml version="1.0" encoding="UTF-8"?">"
"<"web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1"">"

1、web.xml学名叫部署描述符文件,是在Servlet规范中定义的,是web应用的配置文件。

2、部署描述符文件就像所有XML文件一样,必须以一个XML头开始。这个头声明可以使用的XML版本并给出文件的字符编码。
每一个xml文件都有定义他书写规范的schema文件,web.xml所对应的xml Schema文件中定义了多少种标签元素,web.xml中就可以出现它所定义的标签元素,也就具备哪些特定的功能。web.xml的模式文件是由Sun 公司定义的,每个web.xml文件的根元素为<”web-app>中,必须标明这个web.xml使用的是哪个模式文件。

另外web.xml内的属性如果报错:** is not allowed here
这个也是因为web.xml版本不对导致的,只需要更改为合适的版本就可以了。
例如:

  " <"web-app xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
             version="3.0"">"

问题2、

信息: validateJarFile(D:\Program Files\apache-tomcat-7.0.78\webapps\ROOT\WEB-INF\lib\javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
七月 21, 2017 2:43:10 下午 org.apache.catalina.startup.TldConfig execute

原来,tomcat 启动后先将tomcat/lib目录下的jar包全部读入内存,如果webapps目录里的应用程序中,WEB-INF/lib目录下有相同的包,将无法加载,估计不同版本的包之间也会造成类似问题。因此建议尽量不要把jar包放入tomcat/lib目录下,应该放入WEB- INF/lib目录下。

删除掉tomcat/lib目录下的报错的jar包

七月 21, 2017 4:46:08 下午 org.apache.catalina.startup.TldConfig execute
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
七月 21, 2017 4:46:08 下午 org.apache.catalina.core.StandardContext startInternal
严重: One or more listeners failed to start. Full details will be found in the appropriate container log file
七月 21, 2017 4:46:08 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [] startup failed due to previous errors

修改tomcat\conf中logging.properties的
tomcat.util.scan.StandardJarScanFilter.jarsToSkip=*.jar

在用Java和Hbase交互的时候报空指针,提示我配置文件没有加载,最后发现时打包发布的时候配置tomcat会自动打包,图示选项去掉,修改后正常
常见报错_第1张图片


问题3、

在往Hbase里put数据的时候卡在这一步不动,也没有任何的报错,最后发现时本地hosts文件配置的不对。


问题4、

[2018-06-11 07:52:39,629] Artifact ssm:war exploded: Artifact is being deployed, please wait...
11-Jun-2018 19:52:50.579 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory D:\Program Files\apache-tomcat-8.0.36\webapps\manager
11-Jun-2018 19:53:11.942 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
11-Jun-2018 19:53:16.592 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory D:\Program Files\apache-tomcat-8.0.36\webapps\manager has finished in 25,528 ms
11-Jun-2018 19:53:21.522 INFO [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
11-Jun-2018 19:53:23.797 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
11-Jun-2018 19:53:23.797 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
[2018-06-11 07:53:23,877] Artifact ssm:war exploded: Error during artifact deployment. See server log for details.

去C:\Users\D.IntelliJIdea2018.1\system\tomcat\Unnamed_ssm\logs里查看具体的log日志,发现最终打包的时候*.xml文件没有打包进去,mvn clean然后重新编译一下 ,重新发布,问题解决。


问题5、

Loading class 'com.mysql.jdbc.Driver'. This is deprecated. The new 
driver class is 'com.mysql.cj.jdbc.Driver'. 
The driver is automatically registered via the SPI 
and manual loading of the driver class is generally unnecessary.

因为我用的是mysql-connector-java用的6.0以上的


<dependency>
    <groupId>mysqlgroupId>
    <artifactId>mysql-connector-javaartifactId>
    <version>6.0.6version>
dependency>

此时需要把com.mysql.jdbc.Driver 改为com.mysql.cj.jdbc.Driver

WARN: Establishing SSL connection without server’s identity verification is not recommended. 
According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection 
must be established by default if explicit option isn’t set. 
For compliance with existing applications not using SSL the verifyServerCertificate property is set tofalse’. 
You need either to explicitly disable SSL by setting useSSL=false, 
or set useSSL=true and provide truststore for server certificate verification.

不推荐不使用服务器身份验证来建立SSL连接。
如果未明确设置,MySQL 5.5.45+, 5.6.26+ and 5.7.6+版本默认要求建立SSL连接,
如果你不需要使用SSL连接,你需要通过设置useSSL=false来显式禁用SSL连接。
如果你需要用SSL连接,就要为服务器证书验证提供信任库,并设置useSSL=true。
SSL – Secure Sockets Layer(安全套接层)

org.apache.ibatis.exceptions.PersistenceException: 
Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
The error may exist in file [F:\github\ssm\target\ssm\WEB-INF\classes\mapper\CategoryMapper.xml]
The error may involve com.di.dao.ICategoryDao.list
The error occurred while executing a query
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

JDBC连接Mysql6 com.mysql.cj.jdbc.Driver, 需要指定时区serverTimezone:
在设定时区的时候,如果设定serverTimezone=UTC,会比中国时间早8个小时,如果在中国,可以选择Asia/Shanghai或者Asia/Hongkong,例如:

#MySql 数据库配置文件
jdbc.mysql.driver=com.mysql.cj.jdbc.Driver
jdbc.mysql.url=jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false
jdbc.mysql.username=root
jdbc.mysql.password=root

问题6、

spring、springMVC、Mybatis配置事务不生效
使用xml配置文件的方式,在具体的切入点上要跑出RuntimeException,而不是Exception,具体的配置如下:

  
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="mysqldateSource"/>
    bean>

    <tx:advice id="txAdvice" transaction-manager= "transactionManager">
        <tx:attributes>
            
            <tx:method name="deleteAll" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
        tx:attributes>
    tx:advice>

    <aop:config>
        
        <aop:pointcut id="serviceMethodPoint" expression="execution(* com.di.service.*.*(..))"/>
        <aop:advisor advice-ref="txAdvice"  pointcut-ref="serviceMethodPoint" />
    aop:config>

你可能感兴趣的:(java)