踩了J2EE第一个坑, Oracle Tutorial JavaEE 8 "hello1" Example Failure

-记从C#转战Java的第一篇。

最近在慢慢啃Oracle官方出的J2EE8教程(痛苦脸),跑了第一个示范程序就不慎踩坑。。。

按照教程上一步一步地部署Hello1到Glassfish服务器,什么情况?! 红红的error太刺眼了。

 
Error Message:

Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.4:redeploy (deploy) on project hello1: Execution deploy of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.4:redeploy failed: Cannot create configuration. There's no registered configuration for the parameters (container [id = [glassfish5x], type = [installed]], configuration type [existing]). Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it? -> [Help 1]To see the full stack trace of the errors, re-run Maven with the -e switch.Re-run Maven using the -X switch to enable full debug logging.For more information about the errors and possible solutions, please read the following articles:[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

上看下看左看右看,发现问题原来是出在POM文件里,而且是父POM里。比如当前Hello1的路径在我的机器上是C:\Users\KK\ChanDesktop\Java\java_ee_sdk-8\glassfish5\docs\javaee-tutorial\examples\web\jsf\hello1,那么父POM文件在C:\Users\KK\Desktop\Java\java_ee_sdk-8\glassfish5\docs\javaee-tutorial\examples\pom.xml. 一种可行的解决办法就是修改这个pom.xml。那问题倒底是出在哪里呢?

1. 首先我们看一下在父POM文件里定义的Glassfish Server路径:    ${glassfish.home.prefix}/glassfish5   ${glassfish.home.prefix} 又是指向哪里的呢?
且看: 
1             <properties>
2                 <glassfish.home.prefix>c:/</glassfish.home.prefix>
3                 <glassfish.executables.suffix>.bat</glassfish.executables.suffix>
4             </properties>
很显然我的Glassfish5路径不在C盘根目录下面啊,哭。。。 因此,要将这一个路径前缀的定义更新为sdk在本地机器上的实际安装路径:
1             <properties>
2                 <glassfish.home.prefix>c:/Users/KK/Desktop/Java/java_ee_sdk-8</glassfish.home.prefix>
3                 <glassfish.executables.suffix>.bat</glassfish.executables.suffix>
4             </properties>

2. 再Build一次,发现还是不对。搜了一下网上的各种解决方案,需要把cargo plugin的container id改成glassfish4x. 

也就是说把:
1         <cargo.plugin.version>1.4.4</cargo.plugin.version>
2         <glassfish.domain.name>domain1</glassfish.domain.name>
3         <glassfish.home>${glassfish.home.prefix}/glassfish5</glassfish.home>
4         <integration.container.id>glassfish5x</integration.container.id>

改为:

1         <cargo.plugin.version>1.4.4</cargo.plugin.version>
2         <glassfish.domain.name>domain1</glassfish.domain.name>
3         <glassfish.home>${glassfish.home.prefix}/glassfish5</glassfish.home>
4         <integration.container.id>glassfish4x</integration.container.id>
这又是为什么呢?查了一下cargo plugin的介绍,发现原来cargo 1.4.4的版本根本就不支持glassfish5.x.
https://codehaus-cargo.github.io/cargo/Home.html

算是解了个惑,但是还是不是很明白为啥Oracle官方教程里会把这个搞错,也许是我配置的问题,不懂。。。改了这两个地方,终于可以通过啦,大功告成!第一步迈得好不容易,鼓掌。
posted @ 2018-03-05 17:57  kkkchan  阅读(896)  评论(2)    收藏  举报