Announcement Announcement Module
Collapse
No announcement yet.
getting ClassNotFoundException: on my services in tomcat cluster Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • getting ClassNotFoundException: on my services in tomcat cluster

    Hi ,

    I facing an issue with AOP in cluster environment. Here is what I have in my spring config flie

    <bean name="proxyCreator" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="exposeProxy">
    <value type="boolean">true</value>
    </property>
    <property name="beanNames" value="*Service" />
    <property name="interceptorNames">
    <list>
    <value>serviceInterceptor</value>
    </list>
    </property>
    </bean>

    - All my services are intercepted , but when tomcat tries to replicate session it gets ClassNotFound on all the services.
    - If I stop intercepting the services then Tomcat session replication works fine and the application runs without any issues in failover situation.

    My services are simple POJos and are seriliazable.

    Am I doing anything wrong the way I am creating the proxies ?

    Bhaskar

  • #2
    When proxied your services aren't your plain services anymore they are wrapped in another layer. I wonder what is it that you are storing in the session? Probably a service...

    Can you post the whole stacktrace?

    Comment


    • #3
      Correct, There is not much I am storing in me services , one more , presently the services are injected via spring . If I do not inject them and get it from context when needed, then I do not get this Error .

      here is the stack trace

      SEVERE: Manager [localhost#/wma]: Unable to receive message through TCP channel
      java.lang.ClassNotFoundException: com.csc.fsg.life.wma.arch.service.CompanyUpdateSer vice
      at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
      at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:242)
      at java.io.ObjectInputStream.resolveProxyClass(Object InputStream.java:657)
      at java.io.ObjectInputStream.readProxyDesc(ObjectInpu tStream.java:1500)
      at java.io.ObjectInputStream.readClassDesc(ObjectInpu tStream.java:1463)
      at java.io.ObjectInputStream.readOrdinaryObject(Objec tInputStream.java:1699)
      at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1305)
      at java.io.ObjectInputStream.defaultReadFields(Object InputStream.java:1908)
      at java.io.ObjectInputStream.readSerialData(ObjectInp utStream.java:1832)
      at java.io.ObjectInputStream.readOrdinaryObject(Objec tInputStream.java:1719)
      at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1305)
      at java.io.ObjectInputStream.readArray(ObjectInputStr eam.java:1634)
      at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1299)
      at java.io.ObjectInputStream.readArray(ObjectInputStr eam.java:1634)
      at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1299)
      at java.io.ObjectInputStream.readObject(ObjectInputSt ream.java:348)
      at java.util.ArrayList.readObject(ArrayList.java:591)
      at sun.reflect.GeneratedMethodAccessor28.invoke(Unkno wn Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at java.io.ObjectStreamClass.invokeReadObject(ObjectS treamClass.java:946)
      at java.io.ObjectInputStream.readSerialData(ObjectInp utStream.java:1809)
      at java.io.ObjectInputStream.readOrdinaryObject(Objec tInputStream.java:1719)
      at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1305)
      at java.io.ObjectInputStream.readArray(ObjectInputStr eam.java:1634)
      at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1299)
      at java.io.ObjectInputStream.readArray(ObjectInputStr eam.java:1634)
      at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1299)
      at java.io.ObjectInputStream.readObject(ObjectInputSt ream.java:348)
      at java.util.HashMap.readObject(HashMap.java:1067)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at java.io.ObjectStreamClass.invokeReadObject(ObjectS treamClass.java:946)
      at java.io.ObjectInputStream.readSerialData(ObjectInp utStream.java:1809)
      at java.io.ObjectInputStream.readOrdinaryObject(Objec tInputStream.java:1719)
      at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1305)
      at java.io.ObjectInputStream.defaultReadFields(Object InputStream.java:1908)
      at java.io.ObjectInputStream.readSerialData(ObjectInp utStream.java:1832)
      at java.io.ObjectInputStream.readOrdinaryObject(Objec tInputStream.java:1719)
      at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1305)
      at java.io.ObjectInputStream.readObject(ObjectInputSt ream.java:348)
      at org.apache.catalina.session.StandardSession.readOb ject(StandardSession.java:1439)
      at org.apache.catalina.session.StandardSession.readOb jectData(StandardSession.java:942)
      at org.apache.catalina.ha.session.DeltaManager.deseri alizeSessions(DeltaManager.java:659)
      at org.apache.catalina.ha.session.DeltaManager.handle ALL_SESSION_DATA(DeltaManager.java:1435)
      at org.apache.catalina.ha.session.DeltaManager.messag eReceived(DeltaManager.java:1300)
      at org.apache.catalina.ha.session.DeltaManager.messag eDataReceived(DeltaManager.java:1083)
      at org.apache.catalina.ha.session.ClusterSessionListe ner.messageReceived(ClusterSessionListener.java:87 )
      at org.apache.catalina.ha.tcp.SimpleTcpCluster.messag eReceived(SimpleTcpCluster.java:916)
      at org.apache.catalina.ha.tcp.SimpleTcpCluster.messag eReceived(SimpleTcpCluster.java:897)
      at org.apache.catalina.tribes.group.GroupChannel.mess ageReceived(GroupChannel.java:264)
      at org.apache.catalina.tribes.group.ChannelIntercepto rBase.messageReceived(ChannelInterceptorBase.java: 79)
      at org.apache.catalina.tribes.group.interceptors.TcpF ailureDetector.messageReceived(TcpFailureDetector. java:110)
      at org.apache.catalina.tribes.group.ChannelIntercepto rBase.messageReceived(ChannelInterceptorBase.java: 79)
      at org.apache.catalina.tribes.group.ChannelIntercepto rBase.messageReceived(ChannelInterceptorBase.java: 79)
      at org.apache.catalina.tribes.group.ChannelCoordinato r.messageReceived(ChannelCoordinator.java:241)
      at org.apache.catalina.tribes.transport.ReceiverBase. messageDataReceived(ReceiverBase.java:225)
      at org.apache.catalina.tribes.transport.nio.NioReplic ationTask.drainChannel(NioReplicationTask.java:188 )
      at org.apache.catalina.tribes.transport.nio.NioReplic ationTask.run(NioReplicationTask.java:91)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:650)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:675)
      at java.lang.Thread.run(Thread.java:595)

      here is the entry for the service in spring config

      <bean id="companyUpdateService" class="com.csc.fsg.life.wma.arch.service.CompanyUp dateServiceImpl" singleton="false">
      <property name="eventId" value="WTRX" />
      </bean>

      Thanks

      Comment


      • #4
        May I ask WHY are you storing the service in the session?! Normally storing services in your session isn't a good idea. Next to that you might end up having multiple instances (no in this case that doesn't have to be a problem because it is't a singleton) but still...

        Comment


        • #5
          perfect question. Actually that is the whole other issue we are facing presently because of using savestate (Myfaces) for our backingbean(services are injected on backingBean).. So you are right The solution is not to inject services on backing bean so they will not be in session and it is my solution going forward.

          Then the question becomes if I do have a object or service is session which is proxied for AOP it will not work in clustered loadbalanced environment or there is way .I am starting to wonder is it not possible to use any proxied objects in session ? or am I missing anything here .

          Bhaskar

          Comment


          • #6
            You want to use something called a lazy proxy, that looksup the service as needed and the reference to the service is transient, so it doesn't get serialized but does a lookup when needed.

            For wicket they use a similair approach, you want to take a look at there spring integration.

            The problem with proxies is that classes are generated dynamically, which means that classes available in one jvm don't have to be available in another jvm.

            Comment


            • #7
              Thanks Marten,

              Things are much clear now. I am using lazy loading for the services. Although this is a big change in our application and we want to intercept our services , so it is worth.

              Thanks

              Comment


              • #8
                I wasn't talking about lazy loading, but about a lazy-proxy, which is actually a proxy around your (proxied) service. Lazy loading in the spring configuration is something completly different.

                Comment


                • #9
                  Mis quoted , but now I am changing our backing beans not to hold the reference of services . it is getting services from the context as needed and then are not in session any more, Clustering and session raplication is working.

                  but based on discussion , is it a correct statement that any kind of proxy object will not work in session replication that implies if you are using spring AOP on an object that requires to be in session then yr session replication will fail.

                  Thanks

                  Comment


                  • #10
                    Originally posted by Bhaskar Ravat View Post
                    but based on discussion , is it a correct statement that any kind of proxy object will not work in session replication that implies if you are using spring AOP on an object that requires to be in session then yr session replication will fail.
                    That's correct. You should not put proxies into the session since they are not serializable. Depending on the use case getting the actual target object and storing that one in the session might be a solution. I do this for example with session-scoped proxies.

                    Joerg

                    Comment

                    Working...
                    X