3 Replies Latest reply on Oct 27, 2009 7:27 PM by Dan Allen

    Weld Wicket NumberGuess example

    Paul Mooney Newbie

      I've been trying to start my own sample Wicket Weld application, as well as just run the Weld numberguess wicket example (using jetty:run goal with jetty profile activated), and I run into the following exception:


      org.apache.wicket.WicketRuntimeException: There is no application attached to current thread main
              at org.apache.wicket.Application.get(Application.java:179)
              at org.jboss.weld.wicket.BeanManagerLookup.getBeanManager(BeanManagerLookup.java:76)
              at org.jboss.weld.wicket.WeldApplication.<init>(WeldApplication.java:39)
              at org.jboss.weld.examples.wicket.SampleApplication.<init>(SampleApplication.java:5)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
              at java.lang.Class.newInstance0(Class.java:355)
              at java.lang.Class.newInstance(Class.java:308)
              at org.apache.wicket.protocol.http.ContextParamWebApplicationFactory.createApplication(ContextParamWebApplicationFactory.java:72)
              at org.apache.wicket.protocol.http.ContextParamWebApplicationFactory.createApplication(ContextParamWebApplicationFactory.java:49)
              at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:678)
              at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
              at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
              at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)
              at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
              at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
              at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
              at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
              at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:115)
              at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
              at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
              at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
              at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
              at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
              at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
              at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
              at org.mortbay.jetty.Server.doStart(Server.java:224)
              at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
              at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
              at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
              at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
              at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
              at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
              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.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
              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)
      


      It seems the org.jboss.weld.wicket.WeldApplication wants to lookup the Wicket application before it is set on the threadlocal variable (or maybe its happening in a different thread?)


      Has anybody got the numberguess wicket example running (in an non-jndi environment), or is this just an issue in Weld 1.0 CR1?


      I've also tried modifying web.xml to add a weld listener, and resource-env-ref



       <listener>
            <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
         </listener>
       <resource-env-ref>
                <description>Object factory for the CDI Bean Manager</description>
                <resource-env-ref-name>BeanManager</resource-env-ref-name>
                <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
           </resource-env-ref>



      and adding jetty-env.xml ala My Link but get no love there either (though I'm sure this is just environmental and I can figure it out on my own when I get some more time):



      java.lang.LinkageError: loader constraint violation: loader (instance of org/codehaus/classworlds/RealmClassLoader) previously initiated loading for a different type with name "javax/el/ExpressionFactory"
              at java.lang.ClassLoader.defineClass1(Native Method)
              at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
              at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
              at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
              at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
              at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
              at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
              at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
              at org.apache.jasper.runtime.JspApplicationContextImpl.getExpressionFactory(JspApplicationContextImpl.java:96)
              at org.jboss.weld.environment.servlet.Listener.contextInitialized(Listener.java:152)
              at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
              at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
              at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
              at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
              at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
              at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:115)
              at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
              at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
              at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
              at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
              at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
              at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
              at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
              at org.mortbay.jetty.Server.doStart(Server.java:224)
              at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
              at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
              at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
              at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
              at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
              at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
              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.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
              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)
      



      So yes, any insight as to why the numberguess wicket can't run in an environment without JNDI (so non-EE env) would be appreciated.