0 Replies Latest reply on Feb 5, 2020 1:46 PM by mohammedadel

    Clustered Java EE Application With Wildyfly 10.1 & Apache Http

    mohammedadel

      I'm trying to start up a cluster with 2 nodes of wildyfly 10.1 Running in standalone-ha.xml standalone mode with 3 modules deployed in each one :

      1. EJB_EAR.ear, Singleton_EJB_EAR.ear, Web_EAR.ear are deployed with the two nodes

      and I have another module called Web_Resources.war is deployed in the Apache24Http.

      UserSessionBean is not shared between the two nodes when I logout from one node another node doesn't continue to serve the user and when I drop the Web EAR from the deployment or shutdown any node I get the following exception.

      ERROR [io.undertow.request] (default task-17) UT005023: Exception handling request to /royal/underwriting/property/fire/find/edit: org.jboss.weld.exceptions.WeldException: WELD-001500: Fa
      iled to deserialize proxy object with beanId WELD%ManagedBean%Insurance_Web_EAR.ear|/D:/Servers/wildfly-10.1.0.Final_node2/bin/content/Insurance_Web_EAR.ear/Insurance_Web.war|com.asset.insurance.web.s
      ession.UserSessionBean|null|false
        at org.jboss.weld.bean.proxy.util.SerializableClientProxy.readResolve(SerializableClientProxy.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jboss.marshalling.reflect.SerializableClass.callReadResolve(SerializableClass.java:415)
        at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1286)
        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
        at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
        at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
        at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
        at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
        at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
        at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1658)
        at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
        at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:149)
        at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:135)
        at org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:53)
        at org.jboss.marshalling.river.RiverObjectInputStream.readObjectOverride(RiverObjectInputStream.java:307)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:425)
        at java.util.HashMap.readObject(HashMap.java:1412)
        at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:309)
        at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1637)
        at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
        at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:41)
        at org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValue.get(SimpleMarshalledValue.java:101)
        at org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValue.get(SimpleMarshalledValue.java:44)
        at org.wildfly.clustering.marshalling.jboss.MarshalledValueMarshaller.read(MarshalledValueMarshaller.java:45)
        at org.wildfly.clustering.marshalling.jboss.MarshalledValueMarshaller.read(MarshalledValueMarshaller.java:32)
        at org.wildfly.clustering.web.infinispan.session.coarse.CoarseSessionAttributesFactory.findValue(CoarseSessionAttributesFactory.java:79)
        at org.wildfly.clustering.web.infinispan.session.coarse.CoarseSessionAttributesFactory.findValue(CoarseSessionAttributesFactory.java:48)
        at org.wildfly.clustering.web.infinispan.session.InfinispanSessionFactory.findValue(InfinispanSessionFactory.java:61)
        at org.wildfly.clustering.web.infinispan.session.InfinispanSessionFactory.findValue(InfinispanSessionFactory.java:38)
        at org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.findSession(InfinispanSessionManager.java:233)
        at org.wildfly.clustering.web.undertow.session.DistributableSessionManager.getSession(DistributableSessionManager.java:148)
        at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:772)
        at io.undertow.servlet.spec.HttpServletRequestImpl.getSession(HttpServletRequestImpl.java:370)
        at org.jboss.weld.servlet.SessionHolder.requestInitialized(SessionHolder.java:47)
        at org.jboss.weld.servlet.HttpContextLifecycle.requestInitialized(HttpContextLifecycle.java:234)
        at org.jboss.weld.servlet.WeldInitialListener.requestInitialized(WeldInitialListener.java:152)
        at io.undertow.servlet.core.ApplicationListeners.requestInitialized(ApplicationListeners.java:246)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:291)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
      Caused by: an exception which occurred:
        in object of type org.jboss.weld.bean.proxy.util.SerializableClientProxy
        in field userSessionBean
        in object of type com.asset.insurance.web.session.UserSessionBean
        in field instance
        in object of type org.jboss.weld.context.SerializableContextualInstanceImpl
        in object of type java.util.HashMap

       

      My UserSessionBean :

      package com.asset.insurance.web.session;

      import java.io.Serializable;
      import java.util.List;
      import java.util.Locale;
      import java.util.ResourceBundle;
      import java.util.concurrent.CompletableFuture;
      import java.util.function.Supplier;

      import javax.annotation.PreDestroy;
      import javax.enterprise.context.SessionScoped;
      import javax.inject.Named;

      import com.asset.insurance.calculations.InsuranceBigDecimal;
      import com.asset.insurance.logging.Log;
      import com.asset.insurance.pojos.admin.InsuranceModule;
      import com.asset.insurance.pojos.admin.MenuItem;
      import com.asset.insurance.pojos.admin.User;
      import com.asset.insurance.vo.admin.LimitVO;
      import com.asset.insurance.vo.admin.UserAccessRightsVO;
      import com.asset.insurance.web.common.BaseBean;
      import com.asset.insurance.web.common.delegate.CommonBusinessDelegate;
      import com.asset.insurance.web.constants.WebConstants;

      @Named("userSessionBean")
      @SessionScoped
      public class UserSessionBean extends BaseBean implements Serializable {

        private static final long serialVersionUID = 1L;

        private transient ResourceBundle commonErrorsBundle;
        private transient ResourceBundle commonWarningBundle;
        private transient ResourceBundle commonSuccessBundle;

        private transient ResourceBundle moduleErrorsBundle;
        private transient ResourceBundle moduleWarningBundle;
        private transient ResourceBundle moduleSuccessBundle;

        private Locale locale = new Locale(WebConstants.DEFAULT_LANGUAGE);

        /* Menu and modules part */
        private User user;

        private Long currentMenuItemId;
        private Long currentParentMenuItemId;
        private InsuranceModule currentModule;

        private MenuItem currentMenuItem;

        private List<InsuranceModule> userModules;
        /* End of menu and modules part */

        private UserAccessRightsVO userAccessRights;

        private List<String> breadCrumb;

        private CommonBusinessDelegate commonBusinessDelegate = new CommonBusinessDelegate();

        @PreDestroy
        public void sessionDestroyed() {

        try {

        // Audit logout Asynchronous
        CompletableFuture.supplyAsync((Supplier<?>) () -> {

        try {

        commonBusinessDelegate.auditLogout(user);

        } catch (Exception e) {
        Log.error(e.toString(), e);
        }

        return null;
        });

        } catch (Exception ex) {
        Log.error(ex.toString(), ex);
        }

        }

        public InsuranceBigDecimal getLimitAmount(LimitVO limitVO) {

        return userAccessRights.getLimits().get(limitVO);
        }

        public Locale getLocale() {

        return locale;
        }

        public void setLocale(Locale locale) {

        this.locale = locale;
        }

        public ResourceBundle getCommonErrorsBundle() {

        if (commonErrorsBundle == null) {
        commonErrorsBundle = ResourceBundle.getBundle(WebConstants.ERROR_MSGS, getLocale());
        }

        return commonErrorsBundle;
        }

        public ResourceBundle getCommonWarningBundle() {

        if (commonWarningBundle == null) {
        commonWarningBundle = ResourceBundle.getBundle(WebConstants.WARNING_MSGS, getLocale());
        }

        return commonWarningBundle;
        }

        public ResourceBundle getCommonSuccessBundle() {

        if (commonSuccessBundle == null) {
        commonSuccessBundle = ResourceBundle.getBundle(WebConstants.SUCCESS_MSGS, getLocale());
        }

        return commonSuccessBundle;
        }

        public ResourceBundle getModuleErrorBundle() {

        if (moduleErrorsBundle == null) {
        loadModuleBundle(WebConstants.ERROR_BUNDLE);
        }

        return moduleErrorsBundle;
        }

        public ResourceBundle getModuleSuccessBundle() {

        if (moduleSuccessBundle == null) {
        loadModuleBundle(WebConstants.SUCCESS_BUNDLE);
        }

        return moduleSuccessBundle;
        }

        public ResourceBundle getModuleWarningBundle() {

        if (moduleWarningBundle == null) {
        loadModuleBundle(WebConstants.WARNING_BUNDLE);
        }

        return moduleWarningBundle;
        }

        /**
        * @return the currentMenuItemId
        */
        public Long getCurrentMenuItemId() {

        return currentMenuItemId;
        }

        /**
        * @param currentMenuItemId
        * the currentMenuItemId to set
        */
        public void setCurrentMenuItemId(Long currentMenuItemId) {

        this.currentMenuItemId = currentMenuItemId;
        }

        public InsuranceModule getCurrentModule() {

        return currentModule;
        }

        public void setCurrentModule(InsuranceModule currentModule) {

        this.currentModule = currentModule;

        moduleErrorsBundle = null;
        moduleSuccessBundle = null;
        moduleWarningBundle = null;
        }

        public List<InsuranceModule> getUserModules() {

        return userModules;
        }

        public void setUserModules(List<InsuranceModule> userModules) {

        this.userModules = userModules;
        }

        public User getUser() {

        return user;
        }

        public void setUser(User user) {

        this.user = user;
        }

        /**
        * @return the currentParentMenuItemId
        */
        public Long getCurrentParentMenuItemId() {

        return currentParentMenuItemId;
        }

        /**
        * @param currentParentMenuItemId
        * the currentParentMenuItemId to set
        */
        public void setCurrentParentMenuItemId(Long currentParentMenuItemId) {

        this.currentParentMenuItemId = currentParentMenuItemId;
        }

        public List<String> getBreadCrumb() {

        return breadCrumb;
        }

        public void setBreadCrumb(List<String> breadCrumb) {

        this.breadCrumb = breadCrumb;
        }

        /**
        * @return the userAccessRights
        */
        public UserAccessRightsVO getUserAccessRights() {

        return userAccessRights;
        }

        /**
        * @param userAccessRights
        * the userAccessRights to set
        */
        public void setUserAccessRights(UserAccessRightsVO userAccessRights) {

        this.userAccessRights = userAccessRights;
        }

        /**
        * @return the currentMenuItem
        */
        public MenuItem getCurrentMenuItem() {

        return currentMenuItem;
        }

        /**
        * @param currentMenuItem
        * the currentMenuItem to set
        */
        public void setCurrentMenuItem(MenuItem currentMenuItem) {

        this.currentMenuItem = currentMenuItem;
        }

        private void loadModuleBundle(String bundleType) {

        if (currentModule.getId() == InsuranceModule.UNDERWRITING_MODULE) {

        switch (bundleType) {
        case WebConstants.ERROR_BUNDLE:
        moduleErrorsBundle = ResourceBundle.getBundle(WebConstants.UNDERWRITING_ERROR_MSGS, getLocale());
        break;

        case WebConstants.SUCCESS_BUNDLE:
        moduleSuccessBundle = ResourceBundle.getBundle(WebConstants.UNDERWRITING_SUCCESS_MSGS, getLocale());
        break;

        case WebConstants.WARNING_BUNDLE:
        moduleWarningBundle = ResourceBundle.getBundle(WebConstants.UNDERWRITING_WARNING_MSGS, getLocale());
        break;

        default:
        break;
        }

        } else if (currentModule.getId() == InsuranceModule.CLAIMS_MODULE) {

        switch (bundleType) {
        case WebConstants.ERROR_BUNDLE:
        moduleErrorsBundle = ResourceBundle.getBundle(WebConstants.CLAIMS_ERROR_MSGS, getLocale());
        break;

        case WebConstants.SUCCESS_BUNDLE:
        moduleSuccessBundle = ResourceBundle.getBundle(WebConstants.CLAIMS_SUCCESS_MSGS, getLocale());
        break;

        case WebConstants.WARNING_BUNDLE:
        moduleWarningBundle = ResourceBundle.getBundle(WebConstants.CLAIMS_WARNING_MSGS, getLocale());
        break;

        default:
        break;
        }

        } else if (currentModule.getId() == InsuranceModule.Quotation_MODULE) {

        switch (bundleType) {
        case WebConstants.ERROR_BUNDLE:
        moduleErrorsBundle = ResourceBundle.getBundle(WebConstants.Quotation_ERROR_MSGS, getLocale());
        break;

        case WebConstants.SUCCESS_BUNDLE:
        moduleSuccessBundle = ResourceBundle.getBundle(WebConstants.Quotation_SUCCESS_MSGS, getLocale());
        break;

        case WebConstants.WARNING_BUNDLE:
        moduleWarningBundle = ResourceBundle.getBundle(WebConstants.Qoutation_WARNING_MSGS, getLocale());
        break;

        default:
        break;
        }

        } else if (currentModule.getId() == InsuranceModule.ACCOUNTING_MODULE) {

        switch (bundleType) {
        case WebConstants.ERROR_BUNDLE:
        moduleErrorsBundle = ResourceBundle.getBundle(WebConstants.ACCOUNTING_ERROR_MSGS, getLocale());
        break;

        case WebConstants.SUCCESS_BUNDLE:
        moduleSuccessBundle = ResourceBundle.getBundle(WebConstants.ACCOUNTING_SUCCESS_MSGS, getLocale());
        break;

        case WebConstants.WARNING_BUNDLE:
        moduleWarningBundle = ResourceBundle.getBundle(WebConstants.ACCOUNTING_WARNING_MSGS, getLocale());
        break;

        default:
        break;
        }
        } else if (currentModule.getId() == InsuranceModule.REINSURANCE_MODULE) {

        switch (bundleType) {
        case WebConstants.ERROR_BUNDLE:
        moduleErrorsBundle = ResourceBundle.getBundle(WebConstants.REINSURANCE_ERROR_MSGS, getLocale());
        break;

        case WebConstants.SUCCESS_BUNDLE:
        moduleSuccessBundle = ResourceBundle.getBundle(WebConstants.REINSURANCE_SUCCESS_MSGS, getLocale());
        break;

        case WebConstants.WARNING_BUNDLE:
        moduleWarningBundle = ResourceBundle.getBundle(WebConstants.REINSURANCE_WARNING_MSGS, getLocale());
        break;

        default:
        break;
        }

        } else if (currentModule.getId() == InsuranceModule.ADMINISTRATION_MODULE) {

        switch (bundleType) {
        case WebConstants.ERROR_BUNDLE:
        moduleErrorsBundle = ResourceBundle.getBundle(WebConstants.ADMINISTRATION_ERROR_MSGS, getLocale());
        break;

        case WebConstants.SUCCESS_BUNDLE:
        moduleSuccessBundle = ResourceBundle.getBundle(WebConstants.ADMINISTRATION_SUCCESS_MSGS, getLocale());
        break;

        case WebConstants.WARNING_BUNDLE:
        moduleWarningBundle = ResourceBundle.getBundle(WebConstants.ADMINISTRATION_WARNING_MSGS, getLocale());
        break;

        default:
        break;
        }
        }
        }

      My Standalone-ha XML cache configuration

       

      <subsystem xmlns="urn:jboss:domain:infinispan:4.0">

                  <cache-container name="server" aliases="singleton cluster" default-cache="default" module="org.wildfly.clustering.server">

                      <transport lock-timeout="60000"/>

                      <replicated-cache name="default" mode="SYNC">

                          <transaction mode="BATCH"/>

                      </replicated-cache>

                  </cache-container>

                  <cache-container name="web" default-cache="dist" module="org.wildfly.clustering.web.infinispan">

                      <transport lock-timeout="60000"/>

                      <distributed-cache name="dist" mode="ASYNC" l1-lifespan="0" owners="2">

                          <locking isolation="REPEATABLE_READ"/>

                          <transaction mode="BATCH"/>

                          <file-store/>

                      </distributed-cache>

                      <distributed-cache name="concurrent" mode="SYNC" l1-lifespan="0" owners="2">

                          <file-store/>

                      </distributed-cache>

                  </cache-container>

                  <cache-container name="ejb" aliases="sfsb" default-cache="dist" module="org.wildfly.clustering.ejb.infinispan">

                      <transport lock-timeout="60000"/>

                      <distributed-cache name="dist" mode="ASYNC" l1-lifespan="0" owners="2">

                          <locking isolation="REPEATABLE_READ"/>

                          <transaction mode="BATCH"/>

                          <file-store/>

                      </distributed-cache>

                  </cache-container>

                  <cache-container name="hibernate" default-cache="local-query" module="org.hibernate.infinispan:5.2">

                      <transport lock-timeout="60000"/>

                      <local-cache name="local-query">

                          <eviction strategy="LRU" max-entries="10000"/>

                          <expiration max-idle="100000"/>

                      </local-cache>

                      <invalidation-cache name="entity" mode="SYNC">

                          <transaction mode="NON_XA"/>

                          <eviction strategy="LRU" max-entries="10000"/>

                          <expiration max-idle="100000"/>

                      </invalidation-cache>

                      <replicated-cache name="timestamps" mode="ASYNC"/>

                  </cache-container>

                  <cache-container name="replicated_cache" default-cache="user_cache" module="org.wildfly.clustering.server" jndi-name="infinispan/replicated_cache">

                      <transport lock-timeout="60000"/>

                      <replicated-cache name="user_cache" jndi-name="infinispan/replicated_cache/user_cache" mode="SYNC">

                          <transaction locking="OPTIMISTIC" mode="FULL_XA"/>

                          <eviction strategy="NONE"/>

                          <expiration max-idle="10800000"/>

                      </replicated-cache>

                      <replicated-cache name="adm_sys_configurations_cache" jndi-name="infinispan/replicated_cache/adm_sys_configurations_cache" mode="SYNC">

                          <transaction locking="OPTIMISTIC" mode="FULL_XA"/>

                          <eviction strategy="NONE"/>

                      </replicated-cache>

                  </cache-container>

              </subsystem>

       

      NOTICE: All my referenced objects extending BaseEntity Which implements Serializable

       

      I tried to do the following but nothing changed :

       

      1- Mark the bean as @Clusterd

      2- Remove all Transient keyword from all fields

      3- Add Transient to All fields

      4- Patching Wildyfly weld from 2.3.5 to 2.4.5 weld version

       

      Anyone can help or share any idea?