5 Replies Latest reply on Dec 1, 2014 7:02 AM by valsaraj viswanathan

    JPEGCodec  ClassNotFoundException

    Balaji Rathinavel Newbie

       

      I am getting below error  when i open one of the  jsp of my application launched in Jboss7.

       

      14:49:17,538 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Example].[jsp]] (http--127.0.0.1-8080-1) Servlet.service() for servlet jsp threw exception:

      java.lang.ClassNotFoundException

       

      com.sun.image.codec.jpeg.JPEGCodec from [Module "deployment.Example.war:main" from Service Module Loader].

       

       

      But I am not getting this error in jboss 4. Any suggestion please?

        • 1. Re: JPEGCodec  ClassNotFoundException
          jaikiran pai Master

          What does the entire exception stacktrace look like? You'll have to add sun.jdk module dependency in your deployment. But looking at the sun.jdk module it doesn't list com/sun/image path in the export elements. So you'll have to update that module.xml too.

          • 2. Re: JPEGCodec  ClassNotFoundException
            Ales Justin Master

            And if even that's -- what Jaikiran mentions -- you'll need to add the path to JBOSS_MODULES_SYSTEM_PKGS in standalone.conf (-Djboss.modules.system.pkgs).

            (at least I remember I had to do that for v7.0.x ... but could be diff now with v7.1.x)

            • 3. Re: JPEGCodec  ClassNotFoundException
              Andrej Podgorsek Newbie

              I have the same problem...

               

              Can you please be more specific? Where do I have to put

               

              "sun.jdk module dependency in your deployment"

               

              - you'll need to add the path to JBOSS_MODULES_SYSTEM_PKGS in standalone.conf (-Djboss.modules.system.pkgs).

               

              Is this the /modules path?

               

              Thank you

              • 4. Re: JPEGCodec  ClassNotFoundException
                Andrej Podgorsek Newbie

                I get the following stack tracce

                 

                   Caused by: java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/JPEGCodec

                at com.qoppa.b.e.b(Unknown Source) [ImageEJBTest.jar:]

                at com.qoppa.pdfImages.PDFImages.savePageAsJPEG(Unknown Source) [ImageEJBTest.jar:]

                at *replaced*.ImageEJB.convertPDFToInternalFormat(ImageEJB.java:144) [ImageEJBTest.jar:]

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_17]

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_17]

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_17]

                at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_17]

                at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:82) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]

                ... 124 more

                Caused by: java.lang.ClassNotFoundException: com.sun.image.codec.jpeg.JPEGCodec from [Module "deployment.ImageEJBTest.jar:main" from Service Module Loader]

                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.1.GA]

                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]

                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]

                at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316) [rt.jar:1.6.0_17]

                ... 153 more

                 

                • 5. Re: JPEGCodec  ClassNotFoundException
                  valsaraj viswanathan Master

                  I had similar error with this package.

                  Caused by: java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/ImageFormatException

                   

                  This is fixed by removing usage of this package and using ImageIO.

                  Eg:

                  Code:

                              JPEGImageEncoder jpeg = JPEGCodec.createJPEGEncoder(fos);

                              jpeg.encode(bimg);

                  with:

                  Code:

                  ImageIO.write(bimg, "jpg", fos);

                   

                  Ref: http://docs.oracle.com/javase/tutorial/2d/images/saveimage.html