简体   繁体   English

Java-部署Web应用程序时出现问题

[英]Java - Problem in deploying Web Application

I have built a Java Web Application and packed it in a .war file and tested it on my local tomcat server and it is running fine. 我已经构建了一个Java Web应用程序并将其打包为.war文件,并在本地的Tomcat服务器上对其进行了测试,并且运行良好。

But when I deployed it on my client's server, it is showing an error. 但是,当我将其部署到客户端服务器上时,它显示了一个错误。 According to the remote server (my client's server), it is not finding a tld file packed in a jar file which I had placed in WEB-INF/lib directory. 根据远程服务器(我的客户端的服务器),找不到在我放置在WEB-INF/lib目录中的jar文件中的tld文件。 But when I checked the WEB-INF/lib directory for the jar file, i found that it was there. 但是,当我检查WEB-INF/lib目录中的jar文件时,发现它在那里。

The contents of META-INF/MANIFEST.MF is as follows: META-INF/MANIFEST.MF的内容如下:

Manifest-Version: 1.0
Class-Path:

I think that there is no need to explicitly mention the classpath of WEB-INF/lib directory as it is in the classpath of any web application by default. 我认为没有必要明确提及WEB-INF/lib目录的类路径,因为默认情况下它位于任何Web应用程序的类路径中。

Then, why the server can't find the jar file in the lib directory when I deployed it on a remote server and why it is working when I deployed the same application on my local server. 然后,为什么当我将其部署在远程服务器上时服务器无法在lib目录中找到jar文件,以及为什么当我在本地服务器上部署相同的应用程序时仍可以运行。

I posted a question for this at Struts 1 - struts-taglib.jar is not being found by my web application but found that the problem is unusual as nobody could answer it. 我在Struts 1上发布了一个问题-我的Web应用程序未找到struts-taglib.jar,但发现该问题很罕见,因为没人能回答。

So my questions are as follows: 所以我的问题如下:

Q1. Q1。 Is WEB-INF/lib still remains on the classpath if I leave the classpath entry blank as shown above in the MANIFEST.MF file or I should delete the classpath entry completely from the file or I should explicitly enter Class-Path: /WEB-INF/lib as the classpath entry? 如果我按照上面MANIFEST.MF文件中所示将类路径条目保留为空白,或者我应该从文件中完全删除类路径条目,或者应该显式输入Class-Path: /WEB-INF/lib路径,则WEB-INF/lib仍然保留在Class-Path: /WEB-INF/lib作为类路径条目?

Q2. Q2。 I have JSP pages, Servlet s and some helper classes in the web application. 我在Web应用程序中有JSP页面, Servlet和一些帮助程序类。 Jsp pages are located at the root. Jsp页面位于根目录。 Servlets and helper classes are located in WEB-INF/classes folder. Servlet和帮助程序类位于WEB-INF/classes文件夹中。 So Is there any problem if my helper classes are located in the WEB-INF/classes folder? 那么,如果我的助手类位于WEB-INF/classes文件夹中,是否有任何问题?

Note: Please note that this question is not same as my previous question. 注意:请注意,这个问题与我之前的问题不同。 It is a follow-up question of my previous question. 这是我上一个问题的后续问题。

Both the servers (local and remote) are tomcat servers. 这两个服务器(本地和远程)都是tomcat服务器。

Do not create an empty Class-Path entry in the manifest, just remove it! 不要在清单中创建空的Class-Path条目,只需将其删除即可! Normally you do not need any Class-Path entry in a webapp. 通常,您在Web应用程序中不需要任何Class-Path条目。 This entry is more usual for runnable jars. 对于可运行的jar,该条目更为常见。

There is no problem with you helper classes. 您的帮助程序类没有问题。 WEB-INF/classes is always the first entry of the classpath followed by the jars of WEB-INF/lib. WEB-INF / classes始终是类路径的第一个条目,其后是WEB-INF / lib的jar。 So JSPs compiled by the container should have no prblem using classes included there. 因此,使用容器中包含的类,由容器编译的JSP应该没有问题。

Do you have included your taglib in the web.xml with an appropiate taglib-location ? 您是否已将taglib包含在web.xml并带有适当的taglib-location

如果taglib位置指向Internet位置(即带有http)并且生产盒可能无法访问Internet(由于许多防火墙限制),则在生产中可能会发生这种情况

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM