{"action":"opened","issue":{"url":"https://api.github.com/repos/jsimone/webapp-runner/issues/118","repository_url":"https://api.github.com/repos/jsimone/webapp-runner","labels_url":"https://api.github.com/repos/jsimone/webapp-runner/issues/118/labels{/name}","comments_url":"https://api.github.com/repos/jsimone/webapp-runner/issues/118/comments","events_url":"https://api.github.com/repos/jsimone/webapp-runner/issues/118/events","html_url":"https://github.com/jsimone/webapp-runner/issues/118","id":367094195,"node_id":"MDU6SXNzdWUzNjcwOTQxOTU=","number":118,"title":"'No naming context bound to this class loader' error when using realms as authentication method","user":{"login":"teemu47","id":10211104,"node_id":"MDQ6VXNlcjEwMjExMTA0","avatar_url":"https://avatars3.githubusercontent.com/u/10211104?v=4","gravatar_id":"","url":"https://api.github.com/users/teemu47","html_url":"https://github.com/teemu47","followers_url":"https://api.github.com/users/teemu47/followers","following_url":"https://api.github.com/users/teemu47/following{/other_user}","gists_url":"https://api.github.com/users/teemu47/gists{/gist_id}","starred_url":"https://api.github.com/users/teemu47/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teemu47/subscriptions","organizations_url":"https://api.github.com/users/teemu47/orgs","repos_url":"https://api.github.com/users/teemu47/repos","events_url":"https://api.github.com/users/teemu47/events{/privacy}","received_events_url":"https://api.github.com/users/teemu47/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-05T07:37:30Z","updated_at":"2018-10-05T07:37:30Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nApp works fine when deployed to Tomcat server. With webapp-runner an error occurs when app is trying to connect to database for authentication.\r\n\r\nTried with and without --context-xml flag which was picked up at startup: `Using context config: /src/main/webapp/META-INF/context.xml`\r\n\r\nStacktrace:\r\n```\r\norg.apache.catalina.realm.DataSourceRealm open\r\nSEVERE: Exception performing authentication\r\njavax.naming.NamingException: No naming context bound to this class loader\r\n\tat org.apache.naming.ContextBindings.getClassLoader(ContextBindings.java:268)\r\n\tat org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:380)\r\n\tat org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.java:255)\r\n\tat org.apache.catalina.realm.CombinedRealm.authenticate(CombinedRealm.java:188)\r\n\tat org.apache.catalina.realm.LockOutRealm.authenticate(LockOutRealm.java:153)\r\n\tat org.apache.catalina.authenticator.FormAuthenticator.doAuthenticate(FormAuthenticator.java:264)\r\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:572)\r\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)\r\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)\r\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)\r\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)\r\n\tat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)\r\n\tat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)\r\n\tat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)\r\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)\r\n\tat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\r\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)\r\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)\r\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\r\n\tat java.base/java.lang.Thread.run(Thread.java:844)\r\n```\r\n\r\nApp is using LockOutRealm, DatasSourceRealm and SecretKeyCredentialHandler. Here's the context-xml:\r\n\r\n```\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Context>\r\n    <WatchedResource>WEB-INF/web.xml</WatchedResource>\r\n\r\n    <Realm className=\"org.apache.catalina.realm.LockOutRealm\">\r\n        <Realm className=\"org.apache.catalina.realm.DataSourceRealm\"\r\n               localDataSource=\"true\"\r\n               dataSourceName=\"jdbc/authority\"\r\n               userTable=\"users\"\r\n               userNameCol=\"user_name\"\r\n               userCredCol=\"user_pass\"\r\n               userRoleTable=\"user_roles\"\r\n               roleNameCol=\"role_name\">\r\n            <CredentialHandler\r\n                    className=\"org.apache.catalina.realm.SecretKeyCredentialHandler\"\r\n                    algorithm=\"PBKDF2WithHmacSHA512\"\r\n                    keyLength=\"256\"/>\r\n        </Realm>\r\n    </Realm>\r\n\r\n    <Resource\r\n            type=\"javax.sql.DataSource\"\r\n            driverClassName=\"com.mysql.cj.jdbc.Driver\"\r\n            name=\"jdbc/authority\"\r\n            auth=\"Container\"\r\n            maxTotal=\"10\"\r\n            maxIdle=\"2\"\r\n            maxWaitMillis=\"20000\"\r\n            removeAbandonedOnBorrow=\"true\"\r\n            removeAbandonedOnMaintenance=\"true\"\r\n            removeAbandonedTimeout=\"60\"\r\n            logAbandoned=\"true\"\r\n            username=\"username\"\r\n            password=\"password\"\r\n            url=\"\"\r\n            validationQuery=\"select 1 from dual\"\r\n    />\r\n</Context>\r\n```\r\n**Environment:**\r\nwebapp-runner 9.0.11.0\r\njava version \"9.0.4\"\r\nJava(TM) SE Runtime Environment (build 9.0.4+11)\r\nJava HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)"}}
{"actor":{"display_login":"teemu47"}}