dev@glassfish.java.net

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

From: Andriy Zhdanov <andriy.zhdanov_at_oracle.com>
Date: Fri, 24 Feb 2012 16:48:30 +0100

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)
>
>