Spring Boot War文件Tomcat 9部署帮助状态500错误

huangapple go评论75阅读模式
英文:

Spring Boot War File Tomcat 9 Deployment Help Status 500 Error

问题

UPDATE 8/12/2020 approx. 11:00 AM - 我检查了位于tomcat9 ($CATALINA_BASE)文件夹中的logs文件夹catalina.2020-08-12.log日志,并发现了三个异常:“org.apache.catalina.LifecycleException: Protocol handler intialization failed”,“java.net.BindException: Address already in use (bind failed)”,“java.lang.IllegalArgumentException: Invalid character found in the HTTP protocol [HTTP/1.10x0aHost:]”。完整的错误日志在这里:链接链接

UPDATE 8/12/2020 approx. 11:30 AM - 通过检查localhost.2020-08-12.log日志,我发现重新启动tomcat并尝试再次访问我的API时有两个servlet分发器在运行:链接

UPDATE 8/12/2020 approx. 11:35 AM - HA HAAAA,我查看了catalina.out日志(最后有些人可能一直在屏幕前大声喊“检查Catalina.out文件”)。我检查了它,并发现异常:“java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required”:链接。现在,如果我进入我的PostgresDataSource类,这是我的Hikari配置所在的地方:链接,然后我回顾一下之前的application.yaml文件:链接,jdbc url是存在的,因为它与我用于开发的相同。现在,Postgres已经设置好了,我手动在Ubuntu droplet上创建了所有的表格。我还没有下载Tomcat的jdbc postgresql驱动程序。

UPDATE 8/12/2020 approx. 1:20 PM - 设置了jdbc驱动程序后,现在从catalina.out日志中出现以下错误:“Failed to get driver instance for jdbcUrl=java:/comp/env/jdbc:postgresql://localhost:5432/****”,然后出现“Caused by: java.sql.SQLException: No suitable driver”。我使用了这个链接的PostgreSQL部分进行设置:链接

嗨,我正在使用Digital Ocean和Apache Tomcat 9部署使用IntelliJ生成的war文件。当我在端口8080上访问Droplet IP地址时,我得到默认的Tomcat页面。我不确定为什么我会得到一个500错误,而且没有堆栈跟踪信息,即使当我在IntelliJ中运行我的Spring Boot应用程序时,它也可以正常工作。当我访问我的托管应用程序时,我的CSS样式也没有显示出来。我尝试在application.yml文件中配置了一些东西,但仍然无法解决问题。我认为这可能与Spring安全性的CORS问题有关,但我对这个领域的了解还不足以确定。我通过使用sudo $CATALINA_HOME/bin/startup.sh来启动我的服务器,它说Tomcat已经启动,并且当我在浏览器中访问时显示默认的Tomcat页面。我使用了目标文件夹中的hobynapi.war文件,可以在这里查看我的目标文件夹目录的图片:链接。我将使用mvn clean install生成的war文件复制到/var/lib/tomcat9/webapps文件夹中。然后我再次运行了sudo $CATALINA_HOME/bin/startup.sh,它再次成功运行了Tomcat。然后,当我尝试使用Spring安全基本身份验证登录时,发生了错误,出现500错误。项目结构设置的artifact部分也没有任何内容,如果这意味着什么的话。

UPDATE 8/12/2020 approx. 10:00 AM - 我已经从pom.xml文件中删除了exclusions标签以及文件底部的profiles标签。这是因为我在这里阅读到,使用spring-boot-starter-tomcat依赖项会为您删除嵌入式服务器:链接

这是没有CSS样式的屏幕:

链接

这是我得到的没有堆栈跟踪的错误:

链接

这些是我的pom.xml文件的图片:

链接
链接
[链接](https://drive.google.com/file/d/11NDIwA9g02zkCKnsmYSLSNF5R-BrFpgt/view?usp=sharing

英文:

UPDATE 8/12/2020 approx. 11:00 AM - I checked my logs folder catalina.2020-08-12.log log in the tomcat9 ($CATALINA_BASE) folder and I found three exceptions "org.apache.catalina.LifecycleException: Protocol handler intialization failed", "java.net.BindException: Address already in use (bind failed)","java.lang.IllegalArgumentException: Invalid character found in the HTTP protocol [HTTP/1.10x0aHost:]".
Here is the full error log here: https://drive.google.com/file/d/1pSk5ESHLIRP5Srxwr4R1Tp_1TTcYMf2Y/view?usp=sharing and https://drive.google.com/file/d/1C-RALR3066_hYKeoo4dIJqTKwNDOQ0R0/view?usp=sharing.

UPDATE 8/12/2020 approx. 11:30 AM - I found that there are two servlet dispatchers running by checking the localhost.2020-08-12.log log when I restarted tomcat and tried to access my api again: https://drive.google.com/file/d/1GFKUIDLtZrAraHyMjyyWV9kXK33gQ-Mu/view?usp=sharing.

UPDATE 8/12/2020 approx. 11:35 AM - HA HAAAA I looked in the catalina.out log (finally some of you guys were probably yelling at the screen like "CHECK THE CATALINA.OUT FILE"). I checked it and I found the exception: "java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required": https://drive.google.com/file/d/1A7ZLh70IHOmWXfQ56bgtq951EE_AX68P/view?usp=sharing. Now if I go to my PostgresDataSource class which is where my Hikari config is: https://drive.google.com/file/d/1lYN1dTqiAM4ZqliRGC5J5_VWhNeN-k2d/view?usp=sharing, and I review my application.yaml file from earlier: https://drive.google.com/file/d/1xvPhPneVjMU4BoN6F0Q63l2wCnF20BYq/view?usp=sharing, the jdbc url is present because it is the same one I used for developing. Now postgres is already set up and I manually made all of the tables on the ubuntu droplet. I did not download the jdbc postgresql driver for tomcat yet.

UPDATE 8/12/2020 approx. 1:20 PM - After setting up the jdbc driver now I get this error from catalina.out logs: " Failed to get driver instance for jdbcUrl=java:/comp/env/jdbc:postgresql://localhost:5432/****" and then I get "Caused by: java.sql.SQLException: No suitable driver". I used the postgresql section of this link to set it up: https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html.

Hi I am using Digital Ocean with apache tomcat 9 to deploy a war file that is generated using IntelliJ. I have the war file generated using mvn clean install and I get the default tomcat page when I go to the droplet IP address on port 8080. I am not sure why I get a 500 error with no stack trace information even though my spring boot application works fine when I run it in IntelliJ. My CSS styling also does not show up when I go to my hosted application I have tried to configure a few things in my application.yml file and it still does not work. I figured it might have to do with a spring security issue with CORS, but I am not knowledgeable enough in that area to know for sure. I started my server by using sudo $CATALINA_HOME/bin/startup.sh and it said tomcat started and it showed the default tomcat page when I went there in the browser. I used the hobynapi.war file in my target folder a picture of my target folder directory can be viewed here https://drive.google.com/file/d/1XXga1Bgf5-_81gceuWjpvVIX6J0jiNgQ/view?usp=sharing. I copied the war file that was generated after using mvn clean install to the /var/lib/tomcat9/webapps folder. I then ran sudo $CATALINA_HOME/bin/startup.sh again and it ran tomcat successfully again. Then the error happened as I tried to log in with the admin account with spring security basic authentication where I get the 500 error. I also have no artifacts in the artifact section of the project structure settings if that means anything.

UPDATE 8/12/2020 approx. 10:00 AM - I've removed the exclusions tag in the pom.xml file as well as the profiles tag at the bottom of the file. This is because I read here that using the spring-boot-starter-tomcat dependency removes the embedded server for you: https://developer.okta.com/blog/2019/04/16/spring-boot-tomcat.

This is the screen without the CSS styling that should be there:

https://drive.google.com/file/d/1CEKuB556ek8pTZspvprNTa9M5XCI7qtT/view?usp=sharing

This is the error I get without a stack trace:

https://drive.google.com/file/d/19gYGQFhZdZ_4IwwGE5tQzb4dTqlBpg9L/view?usp=sharing

These are pictures of my pom.xml file:

https://drive.google.com/file/d/1ir5uBuBuJqCb_U8Jarly9mraO468QA_y/view?usp=sharing
https://drive.google.com/file/d/1ma1_EPro4NvJiOy8lWPrAmGLMrVWHZPS/view?usp=sharing
https://drive.google.com/file/d/11NDIwA9g02zkCKnsmYSLSNF5R-BrFpgt/view?usp=sharing
https://drive.google.com/file/d/1p6T9-oOwyfj7NUsLxTRLtqXKHU4qHrZx/view?usp=sharing
https://drive.google.com/file/d/1spD7KT-3WBo7KFF0Hb_WgJ5dVKRHF-un/view?usp=sharing
https://drive.google.com/file/d/16QtJQtT9zaU7nGcpnm2KXJ6jiLywNt5s/view?usp=sharing
https://drive.google.com/file/d/1cnZJshFS5xW-HbeaH_C_e6KcDo9xYRdY/view?usp=sharing

This is my application.yml file:

https://drive.google.com/file/d/1xvPhPneVjMU4BoN6F0Q63l2wCnF20BYq/view?usp=sharing
https://drive.google.com/file/d/1B9_5WueRvqQv4ODsJAfbUzGIm-xaaSYV/view?usp=sharing

This is my main application java file:

https://drive.google.com/file/d/1K9lzzlzIKT8irqXsPY1WeiBvN-9vsoWT/view?usp=sharing

This is my web config file in my config package:

https://drive.google.com/file/d/19EYa2kkqqPu9Wh8nN-U02szSVBT30lOP/view?usp=sharing
https://drive.google.com/file/d/11Zw8dLrAu6c_OI29j0NsljvXdeDam0-t/view?usp=sharing

This is my spring security config file in my config package:

https://drive.google.com/file/d/1inqlTjfxahcF6ZeJ_xkJM18UgsDu119n/view?usp=sharing
https://drive.google.com/file/d/1nTeYiKhiNOH71Km-s_T4IT1BKRyJG4mS/view?usp=sharing

I hope that these pictures help for diagnosing the issue.

答案1

得分: 0

I figured it out. First I changed the postgres jdbc url back to the original one that I had and then I altered my data source config file to the following: link. One important thing I also messed up on was not setting a password for the default user "postgres" when downloading postgresql. I did this my calling "ALTER USER postgres PASSWORD 'myPassword';" in the postgresql command line. Also make sure that you use systemctl restart postgresql after any changes are made to postgresql in the postgresql command line.

英文:

I figured it out. First I changed the postgres jdbc url back to the original one that I had and then I altered my data source config file to the following: https://drive.google.com/file/d/1Zmv8cfnVzW8NcQfjNxN14D4aKFaXpdfU/view?usp=sharing. One important thing I also messed up on was not setting a password for the default user "postgres" when downloading postgresql. I did this my calling "ALTER USER postgres PASSWORD 'myPassword';" in the postgresql command line. Also make sure that you use systemctl restart postgresql after any changes are made to postgresql in the postgresql command line.

huangapple
  • 本文由 发表于 2020年8月12日 01:19:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63363263.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定