maven项目打成war包放入tomcat本地可运行t本地无错,发布到服务器启动访问主页面显示错误404?
项目是SSM + maven
,我用 eclipse 打成 war 包放入 tomcat,本地可以运行,并且本地tomcat 无报错!
但是,发布到 windows server 2012 服务器,tomcat 启动项目,日志居然会报错,虽然还是能启动完毕但是访问项目主页面包404错误!
tomcat用的是7
已排查,数据库用户名登入密码没问题
jdk版本本地和服务器一致
tomcat版本从7换成8也不管用
贴出服务器tomcat7日志报错信息
普通log信息:
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Server version: Apache Tomcat/7.0.75
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Jan 18 2017 20:54:42 UTC
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 7.0.75.0
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows Server 2012 R2
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 6.3
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: C:\Program Files\Java\jdk1.8.0_141\jre
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_141-b15
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: C:\Users\Administrator\Desktop\apache-tomcat-7.0.75
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: C:\Users\Administrator\Desktop\apache-tomcat-7.0.75
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.config.file=C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\conf\logging.properties
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\endorsed
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=C:\Users\Administrator\Desktop\apache-tomcat-7.0.75
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=C:\Users\Administrator\Desktop\apache-tomcat-7.0.75
十一月 10, 2017 8:43:58 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.io.tmpdir=C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\temp
十一月 10, 2017 8:43:58 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library 1.2.10 using APR version 1.5.2.
十一月 10, 2017 8:43:58 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
十一月 10, 2017 8:43:58 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized (OpenSSL 1.0.2j 26 Sep 2016)
十一月 10, 2017 8:43:59 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-apr-80"]
十一月 10, 2017 8:43:59 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
十一月 10, 2017 8:43:59 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1809 ms
十一月 10, 2017 8:43:59 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
十一月 10, 2017 8:43:59 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.75
十一月 10, 2017 8:43:59 下午 org.apache.catalina.startup.HostConfig deployWAR
信息: Deploying web application archive C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\Blog.war
十一月 10, 2017 8:43:59 下午 org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
信息: validateJarFile(C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\Blog\WEB-INF\lib\javax.servlet-api-3.1.0.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
十一月 10, 2017 8:44:04 下午 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.
十一月 10, 2017 8:44:11 下午 org.apache.catalina.core.StandardContext startInternal
严重: One or more listeners failed to start. Full details will be found in the appropriate container log file
十一月 10, 2017 8:44:11 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/Blog] startup failed due to previous errors
十一月 10, 2017 8:44:11 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
严重: The web application [/Blog] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
十一月 10, 2017 8:44:11 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
严重: The web application [/Blog] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
十一月 10, 2017 8:44:11 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
严重: The web application [/Blog] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
十一月 10, 2017 8:44:11 下午 org.apache.catalina.startup.HostConfig deployWAR
信息: Deployment of web application archive C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\Blog.war has finished in 12,703 ms
十一月 10, 2017 8:44:11 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\docs
十一月 10, 2017 8:44:12 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\docs has finished in 141 ms
十一月 10, 2017 8:44:12 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\examples
十一月 10, 2017 8:44:12 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\examples has finished in 562 ms
十一月 10, 2017 8:44:12 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\host-manager
十一月 10, 2017 8:44:12 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\host-manager has finished in 94 ms
十一月 10, 2017 8:44:12 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\manager
十一月 10, 2017 8:44:12 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\manager has finished in 94 ms
十一月 10, 2017 8:44:12 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\ROOT
十一月 10, 2017 8:44:12 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\ROOT has finished in 62 ms
十一月 10, 2017 8:44:13 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-apr-80"]
十一月 10, 2017 8:44:14 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-apr-8009"]
十一月 10, 2017 8:44:14 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 15021 ms
将日志调级后,tomcat7日志报的错误信息
十一月 10, 2017 9:10:50 下午 org.apache.catalina.core.ApplicationContext log信息: No Spring WebApplicationInitializer types detected on classpath
十一月 10, 2017 9:10:50 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
十一月 10, 2017 9:10:57 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class com.lzb.service.impl.InitComponent
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'db_blog.t2.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
### The error may exist in file [C:\Users\Administrator\Desktop\apache-tomcat-7.0.75\webapps\Blog\WEB-INF\classes\com\lzb\mappers\BlogTypeMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select t2.id,t2.typeName,count(t1.id) as blogCount from t_blog t1 right join t_blogType t2 on t1.typeId=t2.id group by t2.typeName order by t2.orderNo;
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'db_blog.t2.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'db_blog.t2.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:91)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:74)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:399)
at com.sun.proxy.$Proxy11.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:205)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:122)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:64)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
at com.sun.proxy.$Proxy20.countList(Unknown Source)
at com.lzb.service.impl.BlogTypeServieImpl.countList(BlogTypeServieImpl.java:27)
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.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
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:281)
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.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy21.countList(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:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
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:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy22.countList(Unknown Source)
at com.lzb.service.impl.InitComponent.contextInitialized(InitComponent.java:46)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5118)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'db_blog.t2.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.Util.getInstance(Util.java:387)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:941)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3870)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3806)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2470)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2617)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2550)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1192)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493)
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.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
at com.sun.proxy.$Proxy30.execute(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:62)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:78)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:303)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:154)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:102)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:120)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)
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.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:386)
... 49 more
十一月 10, 2017 9:10:57 下午 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
最后,说一下,以前服务器上部署其它项目没问题,就这个项目出问题了
求教个位大神了,大神们来帮忙吧!!!
回答:
错误应该在这里:
信息: validateJarFile(C:UsersAdministratorDesktopapache-tomcat-7.0.75webappsBlogWEB-INFlibjavax.servlet-api-3.1.0.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
你的Jar包里引用了Servlet 3.1的API,而Tomcat 7.0.x只支持Servlet 3.0,所以要么把Tomcat升级到8+,要么从war包中移除这个javax.servlet-api-3.1.0.jar
。
回答:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'db_blog.t2.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
其实这错误说得挺明白了
推测你服务器上的Mysql版本是5.7?
mysql 文档:https://dev.mysql.com/doc/ref...
解决方案一:修改Mysql
配置
通过这下面语句disable only_full_group_by
。
mysql> set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';mysql> set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
解决方案二:修改你的SQL
select t2.id,t2.typeName,count(t1.id) as blogCount from t_blog t1 right join t_blogType t2 on t1.typeId=t2.id group by t2.typeName order by t2.orderNo;
修改为
SELECT t2.id, t2.typeName,
count(t1.id) AS blogCount
FROM t_blog t1
RIGHT JOIN t_blogType t2 ON t1.typeId=t2.id
GROUP BY t2.typeName,
t2.id
ORDER BY t2.orderNo;
注意改动,在group by里加了t2.id
以上是 maven项目打成war包放入tomcat本地可运行t本地无错,发布到服务器启动访问主页面显示错误404? 的全部内容, 来源链接: utcz.com/p/174893.html