[英]Tomcat not deploying new version of files at all - linux / eclipse
I am having issue with the way tomcat deploys my files to the server. 我对tomcat将我的文件部署到服务器的方式有疑问。
I have installed Tomcat 7 to /opt/tomcat7
. 我已将Tomcat 7安装到
/opt/tomcat7
。
In my eclipse i have specified this path as my tomcat server. 在我的eclipse中,我已将此路径指定为我的tomcat服务器。
my workspace directory is /home/maciej/workspace/<projects here>
我的工作区目录是
/home/maciej/workspace/<projects here>
now if I edit a class file and i add simply log statement 现在,如果我编辑一个类文件,我只添加日志语句
log.info("blabla");
and then deploy 'NEW' version of the file via - run on server, i do not see this 'blabla'
in my output. 然后通过 - 运行在服务器上部署'NEW'版本的文件,我在输出中看不到这个
'blabla'
。 It seems like although i have modified the class file, it was not properly deployed into tomcat. 虽然我已经修改了类文件,但它似乎没有正确部署到tomcat中。 Tomcat is reading god knows what but certainly not the file it should read.
Tomcat正在阅读上帝知道什么,但肯定不是它应该阅读的文件。
EDIT: I have recofnigured my tomcat in eclipse and now: 编辑:我已经在eclipse中重新配置了我的tomcat,现在:
Server Path = /opt/tomcat7
Deploy Path = /opt/tomcat7/webapps <- used to be .metadata/blablabla default
eclipse tomcat location
When I open 'Open Lunch Configuration' under arguments/working directory the default option is ticket with greyed out path /home/maciej/Desktop
当我在参数/工作目录下打开“打开午餐配置”时,默认选项是带有灰色路径的票证
/home/maciej/Desktop
Should this also be changed? 这应该改变吗?
Isn't tomcat working directory /opt/tomcat7/work
? 是不是tomcat工作目录
/opt/tomcat7/work
?
Any suggestions / ideas? 有什么建议/想法吗? As this issue is slightly getting on my nerves as i can not develop the app.
由于我无法开发应用程序,因此这个问题稍微让我感到紧张。
The Server Path
is the same as the Tomcat installation directory
in the modal you see in Window
> Preferences
> Server
> Runtime Environments
after hitting Edit
. Server Path
与您在点击Edit
后在Window
> Preferences
> Server
> Runtime Environments
看到的模式中的Tomcat installation directory
相同。 That should be set to /opt/tomcat7
or wherever the root of your Tomcat installation lives. 应该设置为
/opt/tomcat7
或Tomcat安装的根目录。
The Deploy Path
is relative to the Server Path
. Deploy Path
相对于Server Path
。 It should be webapps
, unless you already have stuff there and you want a separate directory. 它应该是
webapps
,除非你已经有东西,你想要一个单独的目录。 You will not be able to edit this until you shut down Tomcat and remove all webapps underneath it through the Servers
view. 在关闭Tomcat并通过
Servers
视图删除其下的所有Web应用程序之前,您将无法对其进行编辑。
Try unchecking Modules auto reload by default
if you trust the JDK hot-swapping, which you should if you're using JDK 1.7 or 1.8 and just want to see a log statement inserted. 如果您信任JDK热交换,请尝试取消选中
Modules auto reload by default
如果您使用的是JDK 1.7或1.8,并且只想查看插入的日志语句,则应该这样做。
The working directory you mentioned is just the root directory that Tomcat uses to spit out thread dumps on crashes and the like. 您提到的工作目录只是Tomcat用于在崩溃等情况下吐出线程转储的根目录。 It has nothing to do with the Tomcat "work" directory.
它与Tomcat“work”目录无关。
Open server view: Window->Show view->Other->Servers. 打开服务器视图:Window-> Show view-> Other-> Servers。 The select correct server, right click, select "Clean" and then restart tomcat.
选择正确的服务器,右键单击,选择“清理”,然后重新启动tomcat。 It should help.
它应该有所帮助。
If you change something in the project then Eclipse will build automatically and "deploy" the files to the location you have specified. 如果您在项目中更改了某些内容,那么Eclipse将自动构建并将文件“部署”到您指定的位置。 By default, Eclipe's work stops there and the rest is up to tomcat.
默认情况下,Eclipe的工作在那里停止,其余的由tomcat决定。
Tomcat, like any Java web server, detects changes in JSPs and recompiles them. 与任何Java Web服务器一样,Tomcat检测JSP中的更改并重新编译它们。 Nevertheless, changes in classes have no effect because of the way Java class loading works.
然而,由于Java类加载的工作方式,类中的更改不起作用。 For the new version of a class to be used by tomcat you need to:
对于tomcat使用的新版本,您需要:
The easiest way to reload an application, by default, is to make a change to web.xml
. 默认情况下,重新加载应用程序的最简单方法是对
web.xml
进行更改。 If you look into tomcat's configuration conf/context.xml
you can see that WEB-INF/web.xml
is monitored. 如果查看tomcat的配置
conf/context.xml
,可以看到WEB-INF/web.xml
受到监视。 Any change will trigger a reload of the context. 任何更改都将触发上下文的重新加载。 So you can either make an artificial change in the file or add a resource like
WEB-INF/version.properties
and generate a different version.properties
with any build. 因此,您可以在文件中进行人为更改,也可以添加
WEB-INF/version.properties
等资源,并在任何WEB-INF/version.properties
生成不同的version.properties
。
In any case, reloading a complex application takes time. 无论如何,重新加载复杂的应用程序需要时间。 That is why there are plugins like JRebel.
这就是为什么有像JRebel这样的插件。 But before you go down that path (which adds another moving piece to your setup) you can also try to use Eclipe's support for hot code replacement.
但在你沿着这条路走下去之前(这会给你的设置添加另一个移动部件),你也可以尝试使用Eclipe支持热代码替换。 You start tomcat in debug, connect to it with Eclipse, and then change some class.
你在debug中启动tomcat,用Eclipse连接它,然后更改一些类。 Eclipse will try to recompile the class and upload the new definition to tomcat .
Eclipse将尝试重新编译该类并将新定义上载到tomcat 。 If it fails it will tell you.
如果它失败了,它会告诉你。 As a general rule it will fail when you change the structure of the program and succeed when you just change method's implementations.
作为一般规则,当您更改程序的结构时它将失败,并且当您更改方法的实现时会成功。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.