dev@glassfish.java.net

Re: 【Confirmation】About "Getting started with HK2 - Part I"

From: Tang Yong <tangyong_at_cn.fujitsu.com>
Date: Sat, 25 Feb 2012 20:37:22 +0900

Hi Andriy,

Thanks your reply quickly!

I have seen the run.sh in your github's sample and exeucted your run.sh.
The result is ok! But I have few suggestions on your run.sh.

(1) The following cp is not needed because hk2-$HK2_VERSION.jar is main
module.

cp $MAVEN_LOCAL_REP/org/glassfish/hk2/hk2/$HK2_VERSION/
hk2-$HK2_VERSION.jar lib/hk2.jar

(2) The following sentence
"
$JAVA_HOME/bin/java -jar lib/hk2.jar
com.sun.enterprise.module.bootstrap.Main"

should be modified to

"
$JAVA_HOME/bin/java -jar lib/hk2-$HK2_VERSION.jar"

because in hk2-$HK2_VERSION.jar, there is an executable entry.
"Main-Class: com.sun.enterprise.module.bootstrap.Main"

--Best Regard!
--Mike Tang

Andriy Zhdanov wrote:
> Hi Mike,
>
> I've been also recently struggling with the sample, and have not managed
> to make it work with run.sh, it appears main module is being looked for
> inside jar with Bootstrap class (in hk2-core.jar particularly), and
> setting mainModule does not work either, but it works for maven:
>
> mvn -f hello-startup/pom.xml -DmainModule=sahoo.hello-startup hk2:run
>
> So may be Sahoo will comment on this, but I believe you can work it out
> with maven too.
>
> If you'd also like, see my updated version of it here
> <https://github.com/avalez/hello-world-hk2-sample>.
>
> Thank you.
>
> On 2/24/12 3:52 PM, Tang Yong wrote:
>> Hello Dear Sahoo,HK2 DevTeam,
>>
>> About HK2's using way, I found that according to Sahoo's weblog("Getting
>> started with HK2 - Part I"), when I ran the "hello-world-hk2-sample" in
>> windows platform using the following way, I ran the following error.
>>
>> 【Running Way(according to "run.sh")】
>> (1) Copy auto-depends-$HK2_VERSION.jar,config-$HK2_VERSION.jar,
>> hk2-core-$HK2_VERSION.jar,hk2-$HK2_VERSION.jar,tiger-types-1.4.jar,
>> hello-startup-1.0-SNAPSHOT.jar to the new created "lib"
>> (2) java -jar ./lib/hk2-2.0.0-SNAPSHOT.jar
>>
>> Note:
>> Because I built hk2 from trunk, the $HK2_VERSION which I used is
>> hk2-2.0.0-SNAPSHOT.
>>
>> 【Error Info】
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> com/sun/enterprise/module/bootstrap/Main
>> Caused by: java.lang.ClassNotFoundException:
>> com.sun.enterprise.module.bootstrap.Main
>> ...
>>
>> 【Investigation】
>> Then, I investigated for a while and have the following result:
>> (1) In hk2-2.0.0-SNAPSHOT.jar's Manifest.MF, there are the following
>> descriptions(★Dependency JARs have not $HK2_VERSION):
>>
>> ”
>> Class-Path: hk2-core.jar class-model.jar config.jar auto-depends.jar j
>> avax.inject.jar asm-all-repackaged.jar hk2-api.jar osgi-resource-loca
>> tor.jar javax.inject.jar tiger-types.jar bean-validator.jar jtype.jar
>> ”
>>
>> So, I modified the [Running Way] using the following:
>>
>> Copy auto-depends.jar,config.jar,hk2-core.jar,tiger-types.jar to the new
>> created "lib" again.
>>
>> To be pity, the same error info still appeared.
>>
>> (2) Then,apart from the above jar, when I added class-model.jar,
>> asm-all-repackaged.jar,hk2-api.jar and javax.inject.jar to the new
>> created "lib" and executed the sample again, error disppeard and result
>> is OK!
>>
>> “
>> 2012/02/24 23:35:13 com.sun.enterprise.module.bootstrap.Main
>> findMainModuleName warning: No Main-Bundle module found in manifest of
>> F:\GlassfishV3\samples\hk2\sahoo\hello-world-hk2-sample\lib\hk2-core.jar
>> Hello World - My first HK2 Sample
>> ”
>> So, I wish that if Dear Sahoo has free time, you can confirm whether
>> the run.sh in the weblog is wrong or not. In addition, I want to know
>> when packaging hk2-$HK2_VERSION.jar, in the "Class-Path:"why not adding
>> the $HK2_VERSION to the dependency jars?
>>
>> --Thanks
>> --Best Regard
>> --Mike Tang(OSGi Fans)
>>
>>
>

-- 
***−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
富士通南大軟件技術有限公司(FNST)
第二ソフトウェア事業部第一開発部
湯 泳(ユ エイ)
Addr: 南京富士通南大軟件技術有限公司(FNST)
     中国南京市雨花台区文竹路6号(210012)
Mail: tangyong_at_cn.fujitsu.com
Tel: +00-86-25-86630566  内線:7998-8220            
Fax: +00-86-25-83317685                    
***−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−