如何将Web服务器指向我的Web应用程序?

时间:2015-04-20 00:10:53

标签: java web glassfish server jelastic

我已准备好将我的网络应用程序上传到在线服务器。我选择了我在youtube上打开的第一个Jelastic Cloud。

我的Web应用程序看起来像这样(更新:它添加了glassfish-web.xml,见下文)

enter image description here

我通常通过右键单击index.jsp运行它并运行在我的Web浏览器中打开index.jsp网页的内容。

在Netbeans中我去了Export - >导出为zip。然后我去确保该文件是.zip文件。

我在Jelastic中创建了一个环境。它默认设置为Java。我将设置Tomcat改为Glassfish 4.1,因为我正在使用带有netbeans的glassfish并在那里看到了那个选项。

通过单击Deploy将我的websitetest1.zip部署到环境中。

完成后,我点击“在浏览器中打开”。

打开浏览器页面并说:

HTTP Status 404 - Not Found

type Status report

messageNot Found

descriptionThe requested resource is not available.

GlassFish Server Open Source Edition 4.1

当我在Jelastic的日志中查看玻璃鱼时,它说:

[2015-04-19T23:28:15.233+0000] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=45 _ThreadName=admin-listener(5)] [timeMillis: 1429486095233] [levelValue: 800] [[
  visiting unvisited references]]

[2015-04-19T23:28:15.245+0000] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=45 _ThreadName=admin-listener(5)] [timeMillis: 1429486095245] [levelValue: 800] [[
  visiting unvisited references]]

[2015-04-19T23:28:15.250+0000] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=45 _ThreadName=admin-listener(5)] [timeMillis: 1429486095250] [levelValue: 800] [[
  visiting unvisited references]]

[2015-04-19T23:28:15.365+0000] [glassfish 4.1] [INFO] [AS-WEB-GLUE-00172] [javax.enterprise.web] [tid: _ThreadID=45 _ThreadName=admin-listener(5)] [timeMillis: 1429486095365] [levelValue: 800] [[
  Loading application [ROOT] at [/]]]

[2015-04-19T23:28:15.478+0000] [glassfish 4.1] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=45 _ThreadName=admin-listener(5)] [timeMillis: 1429486095478] [levelValue: 800] [[
  ROOT was successfully deployed in 429 milliseconds.]]

[2015-04-19T23:28:30.034+0000] [glassfish 4.1] [WARNING] [] [javax.enterprise.system.container.web.com.sun.web.security] [tid: _ThreadID=28 _ThreadName=http-listener-1(2)] [timeMillis: 1429486110034] [levelValue: 900] [[
  Context path from ServletContext:  differs from path from bundle: /]]

[2015-04-19T23:28:42.047+0000] [glassfish 4.1] [SEVERE] [] [org.apache.jasper.servlet.JspServlet] [tid: _ThreadID=29 _ThreadName=http-listener-1(3)] [timeMillis: 1429486122047] [levelValue: 1000] [[
  PWC6117: File "null" not found]]

我用谷歌搜索,人们说要设置上下文路径,所以我右键单击我的项目,转到运行设置并将上下文路径从/ g5更改为g5。这创建了一个glassfish-web.xml文件。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
  <context-root>g5</context-root>
  <class-loader delegate="true"/>
  <jsp-config>
    <property name="keepgenerated" value="true">
      <description>Keep a copy of the generated servlet class' java code.</description>
    </property>
  </jsp-config>
</glassfish-web-app>

我将我的项目重新压缩到webTEST3并将其上传到Jelastic并点击了部署。当我在浏览器中打开它时,发生了同样的事情

[2015-04-19T23:56:59.344+0000] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(3)] [timeMillis: 1429487819344] [levelValue: 800] [[
  visiting unvisited references]]

[2015-04-19T23:56:59.571+0000] [glassfish 4.1] [INFO] [AS-WEB-GLUE-00172] [javax.enterprise.web] [tid: _ThreadID=43 _ThreadName=admin-listener(3)] [timeMillis: 1429487819571] [levelValue: 800] [[
  Loading application [ROOT] at [/]]]

[2015-04-19T23:56:59.597+0000] [glassfish 4.1] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=43 _ThreadName=admin-listener(3)] [timeMillis: 1429487819597] [levelValue: 800] [[
  ROOT was successfully deployed in 430 milliseconds.]]

[2015-04-19T23:57:07.392+0000] [glassfish 4.1] [WARNING] [] [javax.enterprise.system.container.web.com.sun.web.security] [tid: _ThreadID=30 _ThreadName=http-listener-1(4)] [timeMillis: 1429487827392] [levelValue: 900] [[
  Context path from ServletContext:  differs from path from bundle: /]]

[2015-04-19T23:57:15.132+0000] [glassfish 4.1] [SEVERE] [] [org.apache.jasper.servlet.JspServlet] [tid: _ThreadID=28 _ThreadName=http-listener-1(2)] [timeMillis: 1429487835132] [levelValue: 1000] [[
  PWC6117: File "null" not found]]

[2015-04-19T23:58:26.911+0000] [glassfish 4.1] [SEVERE] [] [org.apache.jasper.servlet.JspServlet] [tid: _ThreadID=28 _ThreadName=http-listener-1(2)] [timeMillis: 1429487906911] [levelValue: 1000] [[
  PWC6117: File "null" not found]]

我的应用程序的index.jsp位于webTEST3.zip \ g5 \ src \ main \ webapp。但我猜测网络服务器会知道在哪里找到它,我不应该输入类似http://myshit/index.jsp的内容来获取它?或http://myshit/g5

zip中没有.jar文件。

谢谢你的阅读。我想我很接近,我将保持谷歌搜索

我正在尝试打包我的项目但是我没有任何Package选项。我怎样才能得到这个选项?这是我目前安装的插件。我的项目是一个maven项目。

enter image description here

1 个答案:

答案 0 :(得分:1)

用户daniel给了我一个解决方法。 我的项目是一个maven项目,所以我可以右键单击我的pom文件 - &gt;运行Maven - &gt;目标并输入“package”作为目标,然后单击go。这似乎给了我通往SNAPSHOT.jar的路径。我将其上传到我的网络服务器,部署它并且工作正常。