Как перейти от комбинации jar-Jetty к развертыванию war-JBoss с проектом maven?

#java #maven #jboss #jetty

#java #maven #jboss #причал

Вопрос:

У меня есть проект maven (созданный не мной), который использует jetty для развертывания веб-приложения. Текущая упаковка проекта maven — jar. Итак, после завершения этапа сборки у меня есть целевой каталог со следующим веб-приложением (среди прочего):

target/server-dir/web-engine/WEB-INF/web.xml

Возможно ли развернуть перенос этого приложения с jetty на JBoss?

Спасибо.

PS: Вот web.xml содержание :

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5">

  <!-- Cometd -->
  <servlet>
      <servlet-name>cometd</servlet-name>
      <servlet-class>org.cometd.server.CometdServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
      <servlet-name>cometd</servlet-name>
      <url-pattern>/cometd/*</url-pattern>
  </servlet-mapping>
  <filter>
      <filter-name>cross-origin</filter-name>
      <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
  </filter>
  <filter-mapping>
      <filter-name>cross-origin</filter-name>
      <url-pattern>/cometd/*</url-pattern>
  </filter-mapping>

  <!-- Jersey - JAXRS support -->
  <servlet>
    <servlet-name>jersey-spring</servlet-name>
    <servlet-class>com.opengamma.component.rest.OpenGammaServlet</servlet-class>
    <!--for creating subscriptions to entity updates-->
    <init-param>
      <param-name>com.sun.jersey.spi.container.ResourceFilters</param-name>
      <param-value>com.opengamma.web.analytics.rest.SubscribingFilterFactory</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>jersey-spring</servlet-name>
    <url-pattern>/jax/*</url-pattern>
  </servlet-mapping>

  <!--HTTP push support-->
  <servlet>
    <servlet-name>handshake</servlet-name>
    <servlet-class>com.opengamma.web.analytics.push.HandshakeServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>handshake</servlet-name>
    <url-pattern>/handshake</url-pattern>
  </servlet-mapping>

  <servlet>
    <servlet-name>updates</servlet-name>
    <servlet-class>com.opengamma.web.analytics.push.LongPollingServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>updates</servlet-name>
    <url-pattern>/updates/*</url-pattern>
  </servlet-mapping>
  <!--end of HTTP push support-->

  <!-- Ehcache shutdown hook -->
  <listener>
    <listener-class>net.sf.ehcache.constructs.web.ShutdownListener</listener-class>
  </listener>
  <!-- Bind CometD/Bayeux to Web analytics -->
  <listener>
    <listener-class>com.opengamma.web.server.WebAnalyticsBayeuxInitializer</listener-class>
  </listener>

  <!-- Disable Jetty's locking of static files -->
  <servlet>
    <servlet-name>default</servlet-name>
    <init-param>
      <param-name>useFileMappedBuffer</param-name>
      <param-value>false</param-value>
    </init-param>
  </servlet>

</web-app>
 

PS 2: pom.xml из проекта (часть величайшего проекта … если вы хотите опубликовать родительский pom-файл, просто скажите мне об этом):

 <?xml version="1.0" encoding="UTF-8"?>
<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>

  <parent>
    <groupId>com.opengamma.platform</groupId>
    <artifactId>examples</artifactId>
    <version>2.1.0</version>
    <relativePath>..</relativePath>
  </parent>
  <artifactId>examples-simulated</artifactId>
  <packaging>jar</packaging>
  <name>Examples-Simulated</name>
  <description>OpenGamma Platform examples and server with simulated market data</description>

  <scm>
    <url>https://github.com/OpenGamma/OG-Platform/tree/master/examples/examples-simulated</url>
  </scm>

  <!-- ==================================================================== -->
  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <directory>config</directory>
      </resource>
    </resources>
    <plugins>
      <!-- include classpath in jar files -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/*logback.xml</exclude>
          </excludes>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <useUniqueVersions>false</useUniqueVersions>
            </manifest>
          </archive>
        </configuration>
      </plugin>
      <!-- generate scripts -->
      <plugin>
        <groupId>com.opengamma.tools</groupId>
        <artifactId>opengamma-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>generate-scripts</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- unpack web zips -->
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.opengamma.platform</groupId>
                  <artifactId>og-web</artifactId>
                  <version>${project.version}</version>
                  <type>zip</type>
                  <classifier>web-engine</classifier>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}/assembly/web-engine</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- generate deployment bundle -->
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>dir</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>src/main/assembly/assembly-server-dir.xml</descriptor>
              </descriptors>
              <finalName>server-dir</finalName>
              <appendAssemblyId>false</appendAssemblyId>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <!-- ==================================================================== -->
  <dependencies>
    <dependency>
      <groupId>com.opengamma.platform</groupId>
      <artifactId>og-server</artifactId>
      <type>pom</type>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>activemq-pool</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.xbean</groupId>
      <artifactId>xbean-spring</artifactId>
    </dependency>
  </dependencies>

  <!-- ==================================================================== -->
  <profiles>
    <!-- src zip file, activated with -Ddist -->
    <profile>
      <id>dist</id>
      <activation>
        <property>
          <name>dist</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <id>packages</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <descriptors>
                    <descriptor>src/main/assembly/assembly-server-unix.xml</descriptor>
                    <descriptor>src/main/assembly/assembly-server-windows.xml</descriptor>
                  </descriptors>
                  <tarLongFileMode>gnu</tarLongFileMode>
                </configuration>
              </execution>
            </executions>
      </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <!-- ==================================================================== -->
  <properties>
    <!-- Properties for OpenGamma plugin -->
    <opengamma.generate.scripts.type>tool</opengamma.generate.scripts.type>
  </properties>

</project>
 

Обновление: assembly-server-dir.xml

 <assembly
  xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

  <id>server-dir</id>
  <formats>
    <format>dir</format>
    <format>war</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>

  <!-- website resources -->
  <dependencySets>
    <dependencySet>
      <outputDirectory>/lib</outputDirectory>
      <directoryMode>755</directoryMode>
      <fileMode>644</fileMode>
      <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
      <useStrictFiltering>true</useStrictFiltering>
    </dependencySet>
  </dependencySets>
  <fileSets>
    <!-- config -->
    <fileSet>
      <directory>config</directory>
      <outputDirectory>/config</outputDirectory>
      <directoryMode>755</directoryMode>
      <fileMode>644</fileMode>
      <lineEnding>unix</lineEnding>
    </fileSet>
    <!-- scripts -->
    <fileSet>
      <directory>${project.build.directory}/scripts</directory>
      <outputDirectory>/scripts</outputDirectory>
      <directoryMode>755</directoryMode>
      <fileMode>755</fileMode>
      <lineEnding>unix</lineEnding>
      <includes>
        <include>*.sh</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>${project.build.directory}/scripts</directory>
      <outputDirectory>/scripts</outputDirectory>
      <directoryMode>755</directoryMode>
      <fileMode>755</fileMode>
      <lineEnding>windows</lineEnding>
      <includes>
        <include>*.bat</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>scripts</directory>
      <outputDirectory>/scripts</outputDirectory>
      <directoryMode>755</directoryMode>
      <fileMode>755</fileMode>
      <lineEnding>unix</lineEnding>
      <includes>
        <include>*.sh</include>
        <include>README*.txt</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>scripts</directory>
      <outputDirectory>/scripts</outputDirectory>
      <directoryMode>755</directoryMode>
      <fileMode>755</fileMode>
      <lineEnding>windows</lineEnding>
      <includes>
        <include>*.bat</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>src/main/assembly</directory>
      <outputDirectory></outputDirectory>
      <directoryMode>755</directoryMode>
      <fileMode>755</fileMode>
      <lineEnding>unix</lineEnding>
      <includes>
        <include>*.txt</include>
      </includes>
    </fileSet>
    <!-- web directory -->
    <fileSet>
      <directory>${project.build.directory}/assembly/web-engine</directory>
      <outputDirectory>/web-engine</outputDirectory>
      <directoryMode>755</directoryMode>
      <fileMode>644</fileMode>
    </fileSet>
    <!-- directory for data and logs -->
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>/data</outputDirectory>
      <directoryMode>755</directoryMode>
      <excludes>
        <exclude>**/*</exclude>
      </excludes>
    </fileSet>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>/logs</outputDirectory>
      <directoryMode>755</directoryMode>
      <excludes>
        <exclude>**/*</exclude>
      </excludes>
    </fileSet>
  </fileSets>

</assembly>
 

И это структура целевого каталога после создания проекта :

 .
├── archive-tmp
│   ├── fileSetFormatter.1049935384.tmp
│   ├── fileSetFormatter.1154083062.tmp
│   ├── fileSetFormatter.1286537410.tmp
│   ├── fileSetFormatter.1355017322.tmp
│   ├── fileSetFormatter.1586511715.tmp
│   ├── fileSetFormatter.1610171729.tmp
│   ├── fileSetFormatter.1696974810.tmp
│   ├── fileSetFormatter.1708681422.tmp
│   ├── fileSetFormatter.2049465563.tmp
│   ├── fileSetFormatter.736244598.tmp
│   ├── fileSetFormatter.962763299.tmp
│   └── fileSetFormatter.990522819.tmp
├── assembly
│   └── web-engine
├── checkstyle-cachefile
├── checkstyle-checker.xml
├── checkstyle-header-run-checkstyle.txt
├── checkstyle-header.txt
├── checkstyle-result.xml
├── classes
│   ├── META-INF
│   ├── analyticservice
│   ├── com
│   ├── default-ehcache.xml
│   ├── ehcache.xml
│   ├── fullstack
│   ├── jetty-logback.xml
│   ├── toolcontext
│   └── toolcontext-remote
├── dependency-maven-plugin-markers
│   └── com.opengamma.platform-og-web-zip-web-engine-2.1.0.marker
├── examples-simulated-2.1.0-sources.jar
├── examples-simulated-2.1.0-tests.jar
├── examples-simulated-2.1.0.jar
├── generated-sources
│   └── annotations
├── generated-test-sources
│   └── test-annotations
├── maven-archiver
│   └── pom.properties
├── maven-status
│   └── maven-compiler-plugin
├── scripts
│   ├── bloomberg-hts-master-updater-tool.bat
│   ├── bloomberg-hts-master-updater-tool.sh
│   ├── bloomberg-security-type-definition-tool.bat
│   ├── bloomberg-security-type-definition-tool.sh
│   ├── cds-strike-fixer.bat
│   ├── cds-strike-fixer.sh
│   ├── componentserver-init-utils.sh
│   ├── config-import-export-tool.bat
│   ├── config-import-export-tool.sh
│   ├── copp-clark-exchange-file-tool.bat
│   ├── copp-clark-exchange-file-tool.sh
│   ├── copp-clark-holiday-file-tool.bat
│   ├── copp-clark-holiday-file-tool.sh
│   ├── currency-pairs-config-document-tool.bat
│   ├── currency-pairs-config-document-tool.sh
│   ├── curve-future-security-loader-tool.bat
│   ├── curve-future-security-loader-tool.sh
│   ├── curve-hts-resolver-tool.bat
│   ├── curve-hts-resolver-tool.sh
│   ├── db-create-tool.bat
│   ├── db-create-tool.sh
│   ├── db-upgrade-tool.bat
│   ├── db-upgrade-tool.sh
│   ├── engine-debugger.bat
│   ├── engine-debugger.sh
│   ├── example-analytic-service-usage.bat
│   ├── example-analytic-service-usage.sh
│   ├── example-currency-configuration-loader.bat
│   ├── example-currency-configuration-loader.sh
│   ├── example-curve-and-surface-definition-loader.bat
│   ├── example-curve-and-surface-definition-loader.sh
│   ├── example-database-creator.bat
│   ├── example-database-creator.sh
│   ├── example-database-populator.bat
│   ├── example-database-populator.sh
│   ├── example-equity-portfolio-loader.bat
│   ├── example-equity-portfolio-loader.sh
│   ├── example-exchange-loader.bat
│   ├── example-exchange-loader.sh
│   ├── example-function-configuration-populator.bat
│   ├── example-function-configuration-populator.sh
│   ├── example-historical-data-generator-tool.bat
│   ├── example-historical-data-generator-tool.sh
│   ├── example-holiday-loader.bat
│   ├── example-holiday-loader.sh
│   ├── example-multi-asset-portfolio-loader.bat
│   ├── example-multi-asset-portfolio-loader.sh
│   ├── example-time-series-rating-loader.bat
│   ├── example-time-series-rating-loader.sh
│   ├── example-views-populator.bat
│   ├── example-views-populator.sh
│   ├── external-id-order-config-document-tool.bat
│   ├── external-id-order-config-document-tool.sh
│   ├── future-price-curve-creator.bat
│   ├── future-price-curve-creator.sh
│   ├── holiday-query-tool.bat
│   ├── holiday-query-tool.sh
│   ├── hts-sync-tool.bat
│   ├── hts-sync-tool.sh
│   ├── java-utils.sh
│   ├── market-data-snapshot-export-tool.bat
│   ├── market-data-snapshot-export-tool.sh
│   ├── market-data-snapshot-import-tool.bat
│   ├── market-data-snapshot-import-tool.sh
│   ├── market-data-snapshot-tool.bat
│   ├── market-data-snapshot-tool.sh
│   ├── orphaned-position-delete-tool.bat
│   ├── orphaned-position-delete-tool.sh
│   ├── periodic-live-data-time-series-storage-tool.bat
│   ├── periodic-live-data-time-series-storage-tool.sh
│   ├── portfolio-aggregation-tool.bat
│   ├── portfolio-aggregation-tool.sh
│   ├── portfolio-copy-move-tool.bat
│   ├── portfolio-copy-move-tool.sh
│   ├── portfolio-hts-resolver-tool.bat
│   ├── portfolio-hts-resolver-tool.sh
│   ├── portfolio-info-tool.bat
│   ├── portfolio-info-tool.sh
│   ├── portfolio-loader-tool.bat
│   ├── portfolio-loader-tool.sh
│   ├── portfolio-saver-tool.bat
│   ├── portfolio-saver-tool.sh
│   ├── portfolio-template-creation-tool.bat
│   ├── portfolio-template-creation-tool.sh
│   ├── portfolio-zip-format-examples-generator.bat
│   ├── portfolio-zip-format-examples-generator.sh
│   ├── project-utils.bat
│   ├── project-utils.sh
│   ├── redis-simulation-series-loader-tool.bat
│   ├── redis-simulation-series-loader-tool.sh
│   ├── resolving-portfolio-loader-tool.bat
│   ├── resolving-portfolio-loader-tool.sh
│   ├── run-tool-noexe.bat
│   ├── run-tool.bat
│   ├── run-tool.sh
│   ├── save-scenario.bat
│   ├── save-scenario.sh
│   ├── security-delete-tool.bat
│   ├── security-delete-tool.sh
│   ├── security-field-mapping-template-generator.bat
│   ├── security-field-mapping-template-generator.sh
│   ├── server-database-creator.bat
│   ├── server-database-creator.sh
│   ├── server-database-populator.bat
│   ├── server-database-populator.sh
│   ├── simulated-historical-data-updater.bat
│   ├── simulated-historical-data-updater.sh
│   ├── simulation-tool.bat
│   ├── simulation-tool.sh
│   ├── time-series-data-provider-replace-tool.bat
│   ├── time-series-data-provider-replace-tool.sh
│   ├── time-series-loader-tool.bat
│   ├── time-series-loader-tool.sh
│   ├── view-definition-editor.bat
│   ├── view-definition-editor.sh
│   ├── view-status-tool.bat
│   ├── view-status-tool.sh
│   ├── volatility-surface-creator.bat
│   └── volatility-surface-creator.sh
├── server-dir
│   ├── LICENSE.txt
│   ├── README.txt
│   ├── config
│   ├── data
│   ├── lib
│   ├── logs
│   ├── scripts
│   ├── temp
│   └── web-engine
├── server-dir.war
├── site
│   ├── checkstyle.html
│   └── images
├── target_directory_structure.txt
├── test-classes
│   └── com
└── tree.txt

43 directories, 138 files
 

Комментарии:

1. Каталог src / main содержит только три каталога: assembly, java, resources

2. Мне удалось создать файл war, используя существующий assembly-server-dir.xml файл (он содержит настройки проекта для использования плагина сборки maven для создания настраиваемой структуры каталогов для созданного файла jar), добавив формат war. Проблема в том, что, хотя он может быть развернут на jboss (теперь проект создает war вместе с jar), он не распознается jboss как веб-приложение (вероятно, из-за отсутствия файлов или неправильной структуры). Я обновил post как с файлом xml, так и с окончательной структурой целевого каталога после завершения сборки проекта.