dev@glassfish.java.net

Re: How to use the embedded glassfish maven plugin for a fast and homogeneous deployment of my JSF application?

From: Ed Burns <edward.burns_at_oracle.com>
Date: Fri, 2 Sep 2011 11:05:16 -0700

>>>>> On Tue, 16 Aug 2011 19:14:23 -0400, Laird Nelson <ljnelson_at_gmail.com> said:

LN> http://embedded-glassfish.java.net/nonav/plugindocs/3.1/plugin-info.html
LN> I hope that gets you started in the right direction.

Yes, it does, and it works pretty well, but I ran into a problem when
trying to make an archetype that is a simple JSF 2.1 app that uses the
maven-embedded-glassfish-plugin version 3.1.1. I have published the
archetype to the maven.java.net SNAPSHOT repo and you may use it with
the following mvn invocation.

mvn archetype:generate -DarchetypeGroupId=javax.faces -DarchetypeArtifactId=javax.faces-war-embedded-glassfish-archetype -DarchetypeVersion=2.1-SNAPSHOT -DarchetypeRepository=https://maven.java.net/content/repositories/snapshots/

You may also get a look at the generated pom using this Sonatype Nexus
artifact browser link. [1]

When you create a project using that archetype, and "mvn install" the
project, it should build the app and run it using the
maven-embedded-glassfish-plugin. Unfortunately, I get this exception
when the embedded glassfish instance starts to run:

java.lang.NoClassDefFoundError: org/osgi/framework/ServiceException

I have attached the complete output from maven to this email.

Should I file a bug? If so, what issuetracker/component/version should
I use?

Thanks,

Ed

[1] https://maven.java.net/service/local/repositories/snapshots/archive/javax/faces/javax.faces-war-embedded-glassfish-archetype/2.1-SNAPSHOT/javax.faces-war-embedded-glassfish-archetype-2.1-20110902.105934-1.jar/!/archetype-resources/pom.xml

-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/
| 15 business days until JSF 2.2 Early Draft Review
| 19 business days until JavaOne 2011


Rhombus:tmp edburns$ mkdir 20110902-1353
Rhombus:tmp edburns$ cd 20110902-1353
Rhombus:20110902-1353 edburns$ mvn archetype:generate -DarchetypeGroupId=javax.faces -DarchetypeArtifactId=javax.faces-war-embedded-glassfish-archetype -DarchetypeVersion=2.1-SNAPSHOT -DarchetypeRepository=https://maven.java.net/content/repositories/snapshots/
M2_HOME /usr/share/java/maven-2.2.1
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] [archetype:generate {execution: default-cli}]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
[INFO] snapshot javax.faces:javax.faces-war-embedded-glassfish-archetype:2.1-SNAPSHOT: checking for updates from javax.faces-war-embedded-glassfish-archetype-repo
Define value for property 'groupId': : foo
Define value for property 'artifactId': : bar
Define value for property 'version': 1.0-SNAPSHOT: 1.0
Define value for property 'package': foo:
Confirm properties configuration:
groupId: foo
artifactId: bar
version: 1.0
package: foo
Y: y
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11 seconds
[INFO] Finished at: Fri Sep 02 13:54:22 EDT 2011
[INFO] Final Memory: 14M/81M
[INFO] ------------------------------------------------------------------------
Rhombus:20110902-1353 edburns$ cd bar/
Rhombus:bar edburns$ ls
move-to-parent-directory-or-delete-build.xml
pom.xml
src
Rhombus:bar edburns$ mvn install
M2_HOME /usr/share/java/maven-2.2.1
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building bar
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /private/tmp/20110902-1353/bar/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to /private/tmp/20110902-1353/bar/target/classes
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /private/tmp/20110902-1353/bar/src/test/resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] [war:war {execution: default-war}]
[INFO] Packaging webapp
[INFO] Assembling webapp[bar] in [/private/tmp/20110902-1353/bar/target/bar]
[INFO] Processing war project
[INFO] Copying webapp resources[/private/tmp/20110902-1353/bar/src/main/webapp]
[INFO] Webapp assembled in[68 msecs]
[INFO] Building war: /private/tmp/20110902-1353/bar/target/bar.war
[INFO] [embedded-glassfish:start {execution: default}]
Created New Bootstrap ClassLoader. ServerId = maven, ClassPaths =
ClassPath Element : file:/Users/edburns/.m2/repository/org/glassfish/extras/glassfish-embedded-all/3.1.1/glassfish-embedded-all-3.1.1.jar
ClassPath Element : file:/Users/edburns/.m2/repository/org/glassfish/maven-embedded-glassfish-plugin/3.1.1/maven-embedded-glassfish-plugin-3.1.1.jar
ClassPath Element : file:/Users/edburns/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
ClassPath Element : file:/Users/edburns/.m2/repository/org/glassfish/simple-glassfish-api/3.1.1/simple-glassfish-api-3.1.1.jar
Sep 2, 2011 1:54:36 PM com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.
Sep 2, 2011 1:54:36 PM org.hibernate.validator.util.Version <clinit>
INFO: Hibernate Validator null
Sep 2, 2011 1:54:36 PM org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
Sep 2, 2011 1:54:36 PM PluginUtil getGlassFish
INFO: Created GlassFish ServerId = maven, BootstrapProperties = {GlassFish_Platform=Static}, GlassFishRuntime = com.sun.enterprise.glassfish.bootstrap.StaticGlassFishRuntime_at_1d91eb90, GlassFishProperties = {embedded-glassfish-config.server.network-config.network-listeners.network-listener.http-listener.enabled=true, embedded-glassfish-config.server.network-config.network-listeners.network-listener.https-listener.port=8181, embedded-glassfish-config.server.network-config.network-listeners.network-listener.https-listener.enabled=true, embedded-glassfish-config.server.network-config.network-listeners.network-listener.http-listener.port=8080}, GlassFish = com.sun.enterprise.glassfish.bootstrap.StaticGlassFishRuntime$1_at_57004a1a, GlassFish Status = INIT, TimeTaken = 2,421 ms
Sep 2, 2011 1:54:37 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy$2$1 onReady
INFO: Grizzly Framework 1.9.36 started in: 89ms - bound to [0.0.0.0:8181]
Sep 2, 2011 1:54:37 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy$2$1 onReady
INFO: Grizzly Framework 1.9.36 started in: 134ms - bound to [0.0.0.0:8080]
Sep 2, 2011 1:54:37 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: GlassFish Server Open Source Edition 3.1.1 (12) startup time : Embedded (1,934ms), startup services(1,179ms), total(3,113ms)
Sep 2, 2011 1:54:38 PM org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread run
INFO: JMXStartupService: JMXConnector system is disabled, skipping.
Sep 2, 2011 1:54:38 PM PluginUtil startGlassFish
INFO: Started GlassFish ServerId = maven, GlassFish = com.sun.enterprise.glassfish.bootstrap.StaticGlassFishRuntime$1_at_57004a1a, TimeTaken = 1,596 ms
[INFO] [embedded-glassfish:deploy {execution: default}]
Sep 2, 2011 1:54:38 PM com.sun.enterprise.security.SecurityLifecycle <init>
INFO: SEC1002: Security Manager is OFF.
Sep 2, 2011 1:54:38 PM com.sun.enterprise.security.SecurityLifecycle onInitialization
INFO: SEC1010: Entering Security Startup Service
Sep 2, 2011 1:54:38 PM com.sun.enterprise.security.PolicyLoader loadPolicy
INFO: SEC1143: Loading policy provider com.sun.enterprise.security.jacc.provider.SimplePolicyProvider.
Sep 2, 2011 1:54:38 PM com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
Sep 2, 2011 1:54:38 PM com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
Sep 2, 2011 1:54:38 PM com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
Sep 2, 2011 1:54:38 PM com.sun.enterprise.security.SecurityLifecycle onInitialization
INFO: SEC1011: Security Service(s) Started Successfully
Sep 2, 2011 1:54:39 PM com.sun.enterprise.web.WebContainer createHttpListener
INFO: WEB0169: Created HTTP listener [http-listener] on host/port [0.0.0.0:8080]
Sep 2, 2011 1:54:39 PM com.sun.enterprise.web.WebContainer createHttpListener
INFO: WEB0169: Created HTTP listener [https-listener] on host/port [0.0.0.0:8181]
Sep 2, 2011 1:54:39 PM com.sun.enterprise.web.WebContainer createHosts
INFO: WEB0171: Created virtual server [server]
Sep 2, 2011 1:54:39 PM com.sun.enterprise.web.WebContainer loadSystemDefaultWebModules
INFO: WEB0172: Virtual server [server] loaded default web module []
classLoader = WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)
SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7_at_3c891d76
Sep 2, 2011 1:54:41 PM org.jboss.weld.bootstrap.WeldBootstrap <clinit>
INFO: WELD-000900 SNAPSHOT
Sep 2, 2011 1:54:41 PM org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
Sep 2, 2011 1:54:41 PM org.jboss.weld.util.ServiceLoader prepareInstance
WARNING: Could not instantiate service class org.glassfish.osgicdi.impl.OSGiServiceExtension
java.lang.NoClassDefFoundError: org/osgi/framework/ServiceException
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
        at java.lang.Class.getConstructor0(Class.java:2699)
        at java.lang.Class.getDeclaredConstructor(Class.java:1985)
        at org.jboss.weld.util.ServiceLoader.prepareInstance(ServiceLoader.java:271)
        at org.jboss.weld.util.ServiceLoader.loadService(ServiceLoader.java:238)
        at org.jboss.weld.util.ServiceLoader.loadServiceFile(ServiceLoader.java:194)
        at org.jboss.weld.util.ServiceLoader.reload(ServiceLoader.java:157)
        at org.jboss.weld.util.ServiceLoader.iterator(ServiceLoader.java:346)
        at org.jboss.weld.bootstrap.ExtensionBeanDeployer.addExtensions(ExtensionBeanDeployer.java:93)
        at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:340)
        at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:168)
        at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
        at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:270)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
        at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:129)
        at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:105)
        at org.glassfish.maven.PluginUtil.doDeploy(PluginUtil.java:106)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.glassfish.maven.AbstractDeployMojo.doDeploy(AbstractDeployMojo.java:239)
        at org.glassfish.maven.DeployMojo.execute(DeployMojo.java:69)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.lang.ClassNotFoundException: org.osgi.framework.ServiceException
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        ... 62 more
Sep 2, 2011 1:54:42 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.1.3 (FCS b02) for context '/bar'
Sep 2, 2011 1:54:44 PM org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
Sep 2, 2011 1:54:45 PM com.sun.enterprise.web.WebApplication start
INFO: WEB0671: Loading application [bar] at [/bar]
Sep 2, 2011 1:54:45 PM org.glassfish.deployment.admin.DeployCommand execute
INFO: bar was successfully deployed in 7,218 milliseconds.
PlainTextActionReporterSUCCESSDescription: deploy AdminCommandApplication deployed with name bar.
    [name=bar
Sep 2, 2011 1:54:45 PM PluginUtil doDeploy
INFO: Deployed bar
[INFO] [embedded-glassfish:undeploy {execution: default}]
Sep 2, 2011 1:54:45 PM PluginUtil doUndeploy
INFO: Deployer = com.sun.enterprise.admin.cli.embeddable.DeployerImpl_at_6e5d8897
classLoader = WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)
SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7_at_3c891d76
PlainTextActionReporterSUCCESSNo monitoring data to report.
Sep 2, 2011 1:54:45 PM PluginUtil doUndeploy
INFO: Undeployed bar
[INFO] [embedded-glassfish:stop {execution: default}]
Sep 2, 2011 1:54:46 PM org.glassfish.admin.mbeanserver.JMXStartupService shutdown
INFO: JMXStartupService and JMXConnectors have been shut down.
Sep 2, 2011 1:54:46 PM com.sun.enterprise.v3.server.AppServerStartup stop
INFO: Shutdown procedure finished
Sep 2, 2011 1:54:46 PM AppServerStartup run
INFO: [Thread[GlassFish Kernel Main Thread,5,main]] exiting
Sep 2, 2011 1:54:46 PM PluginUtil stopGlassFish
INFO: Stopped GlassFish ServerId = maven, GlassFish = com.sun.enterprise.glassfish.bootstrap.StaticGlassFishRuntime$1_at_57004a1a
[INFO] [install:install {execution: default-install}]
[INFO] Installing /private/tmp/20110902-1353/bar/target/bar.war to /Users/edburns/.m2/repository/foo/bar/1.0/bar-1.0.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17 seconds
[INFO] Finished at: Fri Sep 02 13:54:46 EDT 2011
[INFO] Final Memory: 36M/81M
[INFO] ------------------------------------------------------------------------