我正在关注this教程,在Openshift应用程序上安装Geoserver。问题是,要运行Geoserver(.war),我必须从应用程序中删除src文件夹和pom.xml,但我也需要在那里开发一个应用程序。
那么,在运行WAR时我如何保存pom.xml和src文件夹(我真的需要删除这些东西才能让战争运行)?它甚至可能吗?
使用src文件夹和pom.xml我从Openshift收到此响应:
remote: [INFO] ---------- --------------------------------------------------------------
remote: [INFO] Building test 1.0
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO]
remote: [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ test ---
remote: [INFO]
remote: [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ test ---
remote: [debug] execute contextualize
remote: [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote: [INFO] Copying 1 resource
remote: [INFO]
remote: [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ test ---
remote: [INFO] Nothing to compile - all classes are up to date
remote: [INFO]
remote: [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ test ---
remote: [debug] execute contextualize
remote: [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote: [INFO] skip non existing resourceDirectory /var/lib/openshift/56f18c457628e1639500003d/app-root/runtime/repo/src/test/resources
remote: [INFO]
remote: [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ test ---
remote: [INFO] No sources to compile
remote: [INFO]
remote: [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ test ---
remote: [INFO] Tests are skipped.
remote: [INFO]
remote: [INFO] --- maven-war-plugin:2.1.1:war (default-war) @ test ---
remote: [INFO] Packaging webapp
remote: [INFO] Assembling webapp [test] in [/var/lib/openshift/56f18c457628e1639500003d/app-root/runtime/repo/target/test]
remote: [INFO] Processing war project
remote: [INFO] Copying webapp resources [/var/lib/openshift/56f18c457628e1639500003d/app-root/runtime/repo/src/main/webapp]
remote: [INFO] Webapp assembled in [93 msecs]
remote: [INFO] Building war: /var/lib/openshift/56f18c457628e1639500003d/app-root/runtime/repo/webapps/ROOT.war
remote: [INFO] WEB-INF/web.xml already added, skipping
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] BUILD SUCCESS
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Total time: 4.278s
remote: [INFO] Finished at: Tue Mar 22 14:31:40 EDT 2016
remote: [INFO] Final Memory: 8M/111M
remote: [INFO] ------------------------------------------------------------------------
remote: Preparing build for deployment
remote: Deployment id is a3cec3f4
remote: Activating deployment
remote: Starting Postgres cartridge
remote: Postgres started
remote: Emptying tmp dir: /var/lib/openshift/56f18c457628e1639500003d/jbossews//tmp/Geotools
remote: Starting jbossews cartridge
remote: Found 127.3.185.129:8080 listening port
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
我的pom.xml是Openshift提供的默认pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>test</name>
<repositories>
<repository>
<id>eap</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>eap</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1003-jdbc4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when
invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app
will need. -->
<!-- By default that is to put the resulting archive into the 'webapps'
folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<finalName>test</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<outputDirectory>webapps</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Posdata:我知道如何让战争在自己的背景下运行(例如http://test-testdomain.rhcloud.com/war/)。
更新:这是我的rhc tail -a geoserver
==> app-root/logs/postgresql.log <==
2016-03-23 12:51:43 GMT LOG: shutting down
2016-03-23 12:51:43 GMT LOG: database system is shut down
2016-03-23 12:52:01 GMT LOG: could not bind socket for statistics collector: Permission denied
2016-03-23 12:52:01 GMT LOG: trying another address for the statistics collector
2016-03-23 12:52:01 GMT LOG: could not bind socket for statistics collector: Cannot assign requested address
2016-03-23 12:52:01 GMT LOG: disabling statistics collector for lack of working socket
2016-03-23 12:52:01 GMT WARNING: autovacuum not started because of misconfiguration
2016-03-23 12:52:01 GMT HINT: Enable the "track_counts" option.
2016-03-23 12:52:01 GMT LOG: database system was shut down at 2016-03-23 12:51:43 GMT
2016-03-23 12:52:01 GMT LOG: database system is ready to accept connections
==> app-root/logs/jbossews.log <==
Mar 23, 2016 8:52:49 AM org.geoserver.GeoserverInitStartupListener contextDestroyed
INFO: Cleaned up javabean caches
Mar 23, 2016 8:52:50 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/geoserver] registered the JDBC driver [org.hsqldb.jdbc.JDBCDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Mar 23, 2016 8:52:50 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/56f28b760c1e66c08b000209/app-root/runtime/dependencies/jbossews/webapps/geoserver.war has finished in 40,390 ms
Mar 23, 2016 8:52:50 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.3.223.1-8080"]
Mar 23, 2016 8:52:50 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 44333 ms
另外,我检查了$ {OPENSHIFT_JBOSSEWS_DIR}网络应用,我有geoserver.war
和ROOT.war
。
更新2 :在触摸命令后,我再次rhc til -a geoserver
得到:
==> app-root/logs/postgresql.log <==
2016-03-23 14:46:22 GMT LOG: shutting down
2016-03-23 14:46:22 GMT LOG: database system is shut down
2016-03-23 14:46:40 GMT LOG: could not bind socket for statistics collector: Permission denied
2016-03-23 14:46:40 GMT LOG: trying another address for the statistics collector
2016-03-23 14:46:40 GMT LOG: could not bind socket for statistics collector: Cannot assign requested address
2016-03-23 14:46:40 GMT LOG: disabling statistics collector for lack of working socket
2016-03-23 14:46:40 GMT WARNING: autovacuum not started because of misconfiguration
2016-03-23 14:46:40 GMT HINT: Enable the "track_counts" option.
2016-03-23 14:46:40 GMT LOG: database system was shut down at 2016-03-23 14:46:22 GMT
2016-03-23 14:46:40 GMT LOG: database system is ready to accept connections
==> app-root/logs/jbossews.log <==
Mar 23, 2016 10:47:54 AM org.geoserver.GeoserverInitStartupListener contextDestroyed
INFO: Cleaned up javabean caches
Mar 23, 2016 10:47:57 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/geoserver] registered the JDBC driver [org.hsqldb.jdbc.JDBCDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Mar 23, 2016 10:47:57 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/56f28b760c1e66c08b000209/app-root/runtime/dependencies/jbossews/webapps/geoserver.war has finished in 68,308 ms
Mar 23, 2016 10:47:57 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.3.223.1-8080"]
Mar 23, 2016 10:47:57 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 72395 ms
答案 0 :(得分:0)
Openshift应用程序包括一个git存储库,用于将源代码存储为您创建的每个应用程序中的文件夹,在您推送到存储库后,如果ssh
进入应用程序,则存储库位于{{1} }。
每次推送到应用程序的存储库时,都会运行一系列以Openshift术语命名为action hooks的脚本。包含的动作挂钩会因您选择的磁带而变化。
推送java应用程序服务器盒后发生的一件事是触发了maven构建,并使用$OPENSHIFT_REPO_DIR
(src文件夹和pom.xml)中的内容创建{ {1}}工件,它也会自动部署在所选盒式磁带中包含的应用程序服务器上。
这基本上意味着您只需要将源代码推送到repo,而Openshift将处理所有内容。您根本不需要担心删除任何内容。实际上,如果删除存储库目录的内容,则无需从中构建工件。
如果您选择了自己动手(DIY)墨盒,您负责管理所有内容,不包含任何脚本或操作挂钩。
更新:两者都可以使用相同的设备,但需要进行一些调整。
首先,您的应用程序,重要的一点是在您的pom.xml中,保留$OPENSHIFT_REPO_DIR
部分,至少保留WAR
个人资料,因为在推送事件中,它会触发具有<profile>
配置文件的maven构建,它将生成应用程序的WAR工件,并在openshift
目录中生成名为openshift
的文件。此文件将从存储库复制到tomcat部署目录。
现在关于地理服务器,在指南的存储库中,它为您提供了文件ROOT.war
作为地理服务器应用程序:
您需要将其重命名为其他内容,因为触发的maven构建将生成应用程序的ROOT.war文件,除非您修改webapps
的配置。
您需要将重命名的war文件复制到tomcat部署目录。为此,您需要使用操作挂钩。在这种情况下,ROOT.war
阶段似乎是合适的阶段。
您需要在名为maven-war-plugin
的{{1}}目录中创建一个文件并赋予其执行权限(deploy
)并将其包含在版本控制中,因此它将被推送到齿轮和你的应用程序。该文件必须包含一个脚本,其中包含将geoserver WAR文件复制到部署目录的说明,假设您将WAR重命名为geoserver.war,并且驻留在webapps目录中,此脚本将执行:
.openshift/action_hooks
更新:我已尝试按照指南重新解决问题并应用我提到的tweeks,使用spring boot应用程序作为使用根上下文的应用程序,以及Geoserver但我根本没有发现任何问题。
我遵循的步骤是:
deploy
重命名为chmod +x
#!/bin/bash
echo "Deploying Geoserver application..."
cp ${OPENSHIFT_REPO_DIR}webapps/geoserver.war ${OPENSHIFT_JBOSSEWS_DIR}/webapps/
文件(请参阅下面的来源)webapps/ROOT.war
入口点的hello world。webapps/geoserver.war
操作挂钩
<强>的pom.xml 强>
pom.xml