ClassNotFoundException when I put PrettyFaces jar into my classpath

Splash Forums PrettyFaces Users ClassNotFoundException when I put PrettyFaces jar into my classpath

Tagged: ,

This topic contains 7 replies, has 3 voices, and was last updated by  Christian Kaltepoth 7 years, 2 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #17762

    Mincel
    Participant

    Hi,

    I have a very strange problem with PrettyFaces jar. I have an EJB 3.1 + JSF 2.0 application contained in an EAR file. Currently, EJB is in the WAR lib directory and it works. I access the EJB from the backed beans by @EJB annotation.

    In the project I want to use PrettyFaces, however as soon as I include the pretty faces jar in the classpath I start getting java.lang.ClassNotFoundException: foo.service.TestService where TestService is an EJB. I tried both 3.0.1 and 3.0.2-SNAPSHOT versions from the maven repository.

    PS: I tried to put the jar file both into WAR lib directory and EAR lib directory, but got the same error

    @Stateless
    public class TestService {
    public void foo() {
    //...
    }
    }

    @ManagedBean
    @ViewScoped
    public class TestBean implements Serializable {

    private static final long serialVersionUID = 1L;

    @EJB
    private TestService testService;

    ....
    }

    pom.xml
    ...
    <dependency>
    <groupId>com.ocpsoft</groupId>
    <artifactId>prettyfaces-jsf2</artifactId>
    <version>3.0.1</version>
    </dependency>

    Does anybody have any suggestion?

    #20039

    What application server and version are you running on?

    #20040

    Mincel
    Participant

    It is GlassFish 3.0.1

    #20041

    Do you have all of the required dependencies for PrettyFaces? commons-logging, commons-beanutils, commons-digester, and commons-collections?

    #20042

    And could you please post the complete stacktrace of the ClassNotFoundException?

    #20043

    Mincel
    Participant

    Yes, I have all the dependencies.

    INFO: Portable JNDI names for EJB TestService : [java:global/bipoz-ear/bipoz-web/TestService, java:global/bipoz-ear/bipoz-web/TestService!com.innobil.bipoz.service.TestService]

    INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
    SEVERE: Exception while loading the app
    org.glassfish.deployment.common.DeploymentException: by java.lang.NoClassDefFoundError: com/innobil/bipoz/service/TestService
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:167)
    at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:125)
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:224)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:338)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:272)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:305)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:365)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:204)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.RuntimeException: by java.lang.NoClassDefFoundError: com/innobil/bipoz/service/TestService
    at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:344)
    at javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:314)
    at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:273)
    at org.jboss.weld.util.Proxies.createProxyClass(Proxies.java:187)
    at org.jboss.weld.util.Proxies.createProxyClass(Proxies.java:168)
    at org.jboss.weld.bean.SessionBean.initProxyClass(SessionBean.java:221)
    at org.jboss.weld.bean.SessionBean.initialize(SessionBean.java:143)
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.deploy(AbstractBeanDeployer.java:110)
    at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:151)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:377)
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:165)
    ... 30 more
    Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError: com/innobil/bipoz/service/TestService
    at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:169)
    at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:339)
    ... 40 more
    Caused by: java.lang.NoClassDefFoundError: com/innobil/bipoz/service/TestService
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    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 javassist.util.proxy.FactoryHelper.toClass2(FactoryHelper.java:181)
    at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:163)
    ... 41 more
    Caused by: java.lang.ClassNotFoundException: com.innobil.bipoz.service.TestService
    at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:713)
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:626)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    ... 50 more

    #20044

    Hmm.. odd. I’ve seen something like this before. Try the latest PrettyFaces 3.0.2-SNAPSHOT. It may have an update that resolves this problem. Sorry for the inconvenience.

    @chkal — are we doing any strange classloader stuff in the new annotation scanning, that might break classloading in the appserver itself?

    I read recently that you should avoid ClassLoader.loadClass() and should instead use Class.forName(..., classLoader). Thoughts?

    #20045

    @lincoln: No, there is nothing special about the annotation scanning that could lead to something like that. Effectively I’m just using ServletContext.getResource() and JarInputStreams to find .class files and then load them by name via ClassLoader.loadClass(). This should not be problematic.

    Do you have any details about the ClassLoader.loadClass() vs Class.forName(..., classLoader) thing? I thought ClassLoader.loadClass() is the way to go and therefore also use it in the PrettyFaces code. I would be very interested in learning about the advantage of Class.forName(..., classLoader)!

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

Comments are closed.