Friday, 15 January 2010

glassfish 3 - Maven 3 ejb-client dependency visible at compile time not visible at runtime for ejb 3.1 app client -



glassfish 3 - Maven 3 ejb-client dependency visible at compile time not visible at runtime for ejb 3.1 app client -

i have simple ejb 3.1 project uses glassfish 3.1.2 as , maven 3 dependency management. in pom.xml of ejb project set generateclient alternative true. deployed ear server , tried create simple standalone client. here pom.xml of client:

<project> <modelversion>4.0.0</modelversion> <groupid>duan</groupid> <artifactid>ejb31-app-client</artifactid> <version>1.0-snapshot</version> <name>ejb31-app-client</name> <description>my app client</description> <dependencies> <dependency> <groupid>org.glassfish.main.appclient.client</groupid> <artifactid>gf-client-module</artifactid> <version>3.1.2</version> <type>pom</type> <scope>compile</scope> <exclusions> <exclusion> <artifactid>tools</artifactid> <groupid>com.sun</groupid> </exclusion> </exclusions> </dependency> <dependency> <groupid>duan</groupid> <artifactid>ejb31</artifactid> <version>1.0-snapshot</version> <type>ejb-client</type> </dependency> </dependencies>

where ejb31 ejb project client generated.

the java class used in application client is:

public class test { private static helloworldbeanremote helloworldbean; public static void main(string[] args) { string jndipath = "java:global/ejb31-ear-1.0/ejb31-ejb/helloworldbean"; seek { context ctx = new initialcontext(); system.out.println("looking bean at: " + jndipath); helloworldbean = (helloworldbeanremote) ctx.lookup(jndipath); system.out.println("found helloworldbean:" + helloworldbean); system.out.println("calling sayhello():"); string greeting = helloworldbean.sayhello(); system.out.println("helloworldbean said:" + greeting); } grab (namingexception e) { system.err.println("could not find helloworldbeanremote!"); system.err.println("jndi path used lookup:" + jndipath); e.printstacktrace(); } }

}

the application client compiled without problem maven. if run eclipse exception:

caused by: java.lang.classnotfoundexception: ro.duan.ejb.helloworldbeanremote @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ sun.misc.launcher$appclassloader.loadclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ com.sun.ejb.ejbutils.getbusinessintfclassloader(ejbutils.java:688) @ com.sun.ejb.ejbutils.loadgeneratedremotebusinessclasses(ejbutils.java:463) @ com.sun.ejb.ejbutils.lookupremote30businessobject(ejbutils.java:414) ... 7 more

but if manually add together ejb-client.jar build path works charm. conclusion somehow ejb-client.jar available @ compile time, not @ runtime. thoughts on how solve this?

remove next line:

<scope>compile</scope>

read more dependency scope at: http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#dependency_scope

maven-3 glassfish-3 ejb-3.1

No comments:

Post a Comment