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 11 years, 5 months ago.

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



    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

    public class TestService {
    public void foo() {

    public class TestBean implements Serializable {

    private static final long serialVersionUID = 1L;

    private TestService testService;



    Does anybody have any suggestion?


    What application server and version are you running on?



    It is GlassFish 3.0.1


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


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



    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(
    at org.glassfish.kernel.event.EventsImpl.send(
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(
    at org.glassfish.deployment.admin.DeployCommand.execute(
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(
    at com.sun.enterprise.v3.admin.AdminAdapter.service(
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(
    at com.sun.grizzly.http.ProcessorTask.doProcess(
    at com.sun.grizzly.http.ProcessorTask.process(
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(
    at com.sun.grizzly.DefaultProtocolChain.execute(
    at com.sun.grizzly.DefaultProtocolChain.execute(
    at com.sun.grizzly.http.HttpProtocolChain.execute(
    at com.sun.grizzly.ProtocolChainContextTask.doCall(
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(
    at com.sun.grizzly.util.AbstractThreadPool$
    Caused by: java.lang.RuntimeException: by java.lang.NoClassDefFoundError: com/innobil/bipoz/service/TestService
    at javassist.util.proxy.ProxyFactory.createClass3(
    at javassist.util.proxy.ProxyFactory.createClass2(
    at javassist.util.proxy.ProxyFactory.createClass(
    at org.jboss.weld.util.Proxies.createProxyClass(
    at org.jboss.weld.util.Proxies.createProxyClass(
    at org.jboss.weld.bean.SessionBean.initProxyClass(
    at org.jboss.weld.bean.SessionBean.initialize(
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.deploy(
    at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(
    at org.glassfish.weld.WeldDeployer.event(
    ... 30 more
    Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError: com/innobil/bipoz/service/TestService
    at javassist.util.proxy.FactoryHelper.toClass(
    at javassist.util.proxy.ProxyFactory.createClass3(
    ... 40 more
    Caused by: java.lang.NoClassDefFoundError: com/innobil/bipoz/service/TestService
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(
    at java.lang.ClassLoader.defineClass(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at javassist.util.proxy.FactoryHelper.toClass2(
    at javassist.util.proxy.FactoryHelper.toClass(
    ... 41 more
    Caused by: java.lang.ClassNotFoundException: com.innobil.bipoz.service.TestService
    at com.sun.enterprise.loader.ASURLClassLoader.findClassData(
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(
    at java.lang.ClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    ... 50 more


    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?


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

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.