Glassfish部署错误“MyProject.jar的存档类型未被识别” [英] Glassfish deploy error "Archive type of MyProject.jar was not recognized"
问题描述
我创建了一个动态Web应用程序,我想用glassfish部署它。我已经将我的源代码建立到MyProject.jar。但是当我部署它时,会显示以下错误:
I've created a dynamic web application and i'd like to deploy it with glassfish. I've successed build my sources to MyProject.jar. But when i deployed it, the following error displayed:
远程失败:归档类型/ home / davenlin / MyProject / build / MyProject。 jar没有被识别
remote failure: Archive type of /home/davenlin/MyProject/build/MyProject.jar was not recognized
我的项目只是一个正常的Restful应用程序,而不是ejb应用程序,所以我不知道我是否必须生成一个MyProject.war而不是MyProject.jar。
My project is just a normal Restful application, not ejb application, so i don't know if i must generate a MyProject.war instead of MyProject.jar.
请帮助我。谢谢!
推荐答案
好的,因为我的评论是相当无法解释的:
Web应用程序由应用程序处理服务器或servlet容器。
两者都为您安排了大量工作,Web应用程序不可比较
到
桌面或独立Java应用程序。
当您的独立应用程序部署为jar文件,然后由JVM执行时,
Web应用程序由容器(应用程序服务器/ servlet容器)执行
。
所以这要求您的应用程序提供额外的配置
,并提供归档本身具有不同的结构。
所以即使你只是暴露一些Web服务来构建一个安静的
应用程序,你的应用程序服务器会为你做些事情,如
转发请求到正确的类,翻译查询和将
参数发布到java - 可以由您自己的类访问的对象,
您自己的对象,并将您的响应返回给客户端。
有趣的是是:
网络中的附加文件 - 存档通常是xml - 文件和web -
相关文件,如html,css,js。
所以这不区分战争与jar,因为您也可以在jar中打包
其他资源。
对战争文件的基本但现在过时的要求是它包含
a部署描述符(这又是一个xml文件)
配置您的应用程序,其上下文和它使用的相对URL(更具体的:url - 模式)
,但是由于这个要求已经过时,有人仍然认为这个区别也是过时的。
Okay, because my comment was rather unexplanatory:
Web applications are handled by application servers or servlet containers.
Both do quiet a lot of work for you and web applications are not comparable
to
desktop or standalone java applications.
While your standalone applications are deployed as jar - files and then executed by the JVM,
web applications are
executed by the container (application server / servlet container).
So this does require your application to provide additional configuration
and affords the archive itself to have a different structure.
So even if you are just exposing some web services to build a restful
application, your application server will do things for you such as
forwarding requests to the right classes, translate query and post
parameters into java - objects accessable by your own classes respectivly
your own objects and returning your response to the clients.
The interesting thing about it is:
The additional files in the web - archive are usually xml - files and web -
related files such as html, css, js.
So this does not distinguish war's from jar's as you can also package
additional resources within a jar.
The basic but now obsolete requirement on a war - file is that it contains
a deployment descriptor (which is again is an xml - file)
to configure your application , its context and the relative url (more concrete : url - patterns) it uses
, but as this requirement is obsolete someone may still think that this distinguishing is obsolete, too.
这篇关于Glassfish部署错误“MyProject.jar的存档类型未被识别”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!