0

Code to send mail is working fine while running standalone! but when processed in wildfly it is throwing following error :

17:55:33,038 ERROR [io.undertow.request] (default task-39) UT005023: Exception handling request to /hibu-activiti-rest/service/runtime/process-instances: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.IllegalAccessError: tried to access class javax.mail.Session$1 from class javax.mail.Session
        at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1287) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_181]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_181]
        at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_181]
Caused by: java.lang.IllegalAccessError: tried to access class javax.mail.Session$1 from class javax.mail.Session
        at javax.mail.Session.loadProviders(Session.java:900) [javax.mail-1.5.1.jar:1.5.1]
        at javax.mail.Session.<init>(Session.java:216) [javax.mail-1.5.1.jar:1.5.1]
        at javax.mail.Session.getDefaultInstance(Session.java:316) [javax.mail-1.5.1.jar:1.5.1]
        at javax.mail.Session.getDefaultInstance(Session.java:356) [javax.mail-1.5.1.jar:1.5.1]
        at com.hibu.activiti.delegates.cpq.billingjob.AlertBillingErrorDelegate.execute(AlertBillingErrorDelegate.java:65)

Using wildfly-8.1.0

Also, AlertBillingErrorDelegate.java:65 is Session session = Session.getDefaultInstance(properties);

Using jdk1.8.0_181.

Nikhil Kumar
  • 88
  • 11
  • 1
    Does this answer your question? [java.lang.IllegalAccessError: tried to access method](https://stackoverflow.com/questions/7076414/java-lang-illegalaccesserror-tried-to-access-method) – dan1st Nov 09 '20 at 11:59
  • I went through that link initially, didn't help much. I am using provided and the version in wildfly is javax.mail-1.5.1, which is same everywhere. – Nikhil Kumar Nov 09 '20 at 13:10
  • Did you also look at the second answer? – dan1st Nov 09 '20 at 13:21
  • What about using `compile`? – dan1st Nov 09 '20 at 15:35
  • `compile` will still include it in the ending archive, `provided` is correct. – James R. Perkins Nov 09 '20 at 19:27
  • I am now using 1.5.2 version in my POM but still the error is showing related to 1.5.1(I think it is coming from wildfly 8.1 which is having 1.5.1 version). Caused by: java.lang.IllegalAccessError: tried to access class javax.mail.Session$1 from class javax.mail.Session at javax.mail.Session.loadProviders(Session.java:900) [javax.mail-1.5.1.jar:1.5.1] How can I force wildfly server to use the version which I am providing? i.e. 1.5.2 – Nikhil Kumar Nov 11 '20 at 09:20

0 Answers0