使用maven将Java EE应用程序部署到payara41 docker容器

我试图部署一个简单的基于Maven的Java Web应用程序到docker容器上运行的payara 41应用程序服务器。 为此,我使用Glassfish Maven插件进行以下configuration:

<plugin> <groupId>org.glassfish.maven.plugin</groupId> <artifactId>maven-glassfish-plugin</artifactId> <version>2.1</version> <executions> <execution> <goals> <goal>deploy</goal> </goals> <id>deploy</id> </execution> </executions> <configuration> <glassfishDirectory>/path/to/local/payara41/glassfish</glassfishDirectory> <user>admin</user> <adminPassword>MyPassword</adminPassword> <debug>true</debug> <echo>true</echo> <domain> <name>payaradomain</name> <adminPort>4848</adminPort> <!-- mandatory for mvn glassfish:deploy --> <httpPort>8080</httpPort> <httpsPort>8181</httpsPort> <host>DOCKER_CONTAINER_IP</host> <jvmOptions> <option>-Djava.security.auth.login.config=${project.build.testOutputDirectory}/login.conf</option> </jvmOptions> <properties> <property> <name>server.log-service.file</name> <value>${domain.log.dir}/server.log</value> </property> </properties> <resourceDescriptor>${project.build.sourceDirectory}/setup/glassfish-resources.xml</resourceDescriptor> </domain> <components> <component> <name>${project.artifactId}</name> <artifact>${project.build.directory}/${project.build.finalName}.war</artifact> </component> </components> </configuration> </plugin> 

正如你所看到的我在域configuration中使用主机属性,因为我试图部署到一个docker容器,这是一个远程域(这可能是错误的,如果是的话,你可以纠正我)。

事情是当我尝试部署应用程序,我得到以下输出:

 Domain payaradomain isn't started. Starting it for you. Domain payaradomain does not exist. Creating it for you. [/path/to/local/payara41/glassfish/bin/asadmin, create-domain, --echo=true, --terse=true, --interactive=false, --user, admin, -- passwordfile, /tmp/mgfp5897945230218013760.tmp, --domaindir, /path/to/local/payara41/glassfish/domains, --profile, developer, -- adminport, 4848, --instanceport, 8080, --domainproperties, http.ssl.port=8181, payaradomain] CLI031: Warning: Option "profile" is obsolete and will be ignored. asadmin --host localhost --port 4848 --user admin --passwordfile /tmp/mgfp5897945230218013760.tmp --interactive=false --echo=true -- terse=true create-domain --adminport 4848 --profile developer --domaindir /path/to/local/payara41/glassfish/domains --instanceport 8080 -- savemasterpassword=false --usemasterpassword=false --domainproperties http.ssl.port=8181 --savelogin=false --nopassword=false --checkports=true payaradomain CLI130: Could not create domain, payaradomain Unable to create domain "payaradomain". For more detail on what might be causing the problem try running maven with the --debug option or setting the maven-glassfish-plugin "echo" property to "true". 

正如你所看到的,maven正试图在本地部署应用程序。 我认为Maven Glassfish插件的configuration有些问题。 我正在使用Netbeans 8.0.2,Apache Maven 3.0.5和Java 8

编辑我运行maven –debug选项,但得到相同的输出。 我认为这不是系统权利的问题。 有趣的是,我觉得maven试图执行这个命令:

 asadmin --host localhost --port 4848 --user admin --passwordfile /tmp/mgfp2052757567130924436.tmp --interactive=false --echo=true -- terse=true create-domain --adminport 4848 --profile developer --domaindir /path/to/local/payara41/glassfish/domains --instanceport 8080 -- savemasterpassword=false --usemasterpassword=false --domainproperties http.ssl.port=8181 --savelogin=false --nopassword=false --checkports=true payaradomain 

其中本地主机设置为 – 主机选项,我想Maven没有拿起configuration这个选项。 也许我错过了一些东西。

事情是我的本地payara没有运行,也许这就是为什么它不能创buildpayaradomain。 但在正在运行的docker集装箱上,该域已经存在

您可能不应将Docker容器视为“远程部署”,而是将所有需要的端口发布到主机上(请参阅run命令的-p选项),并在本地部署。