@DatabaseIdentityStoreDefinition fails to find DataSource

101 views
Skip to first unread message

Guilherme Mussi

unread,
May 13, 2018, 11:22:35 AM5/13/18
to Payara Forum
Dear Payara community,

I am trying to use the annotation @DatabaseIdentityStoreDefinition to define the identity store for my application.
My data source is currently configured as follows in the glassfish-resources.xml:

...

<jdbc-resource pool-name="SNSPool" jndi-name="java:app/jdbc/snsDB" />

...

My persistence.xml works fine, and I can also inject the DataSource using the @Resource annotation.

However, it is not working with the @DatabaseIdentityStoreDefinition:

@ApplicationScoped

@Named

@DatabaseIdentityStoreDefinition(

  dataSourceLookup = "java:app/jdbc/snsDB",

  callerQuery = "select password from caller where name = ?",

  groupsQuery = "select group_name from caller_groups where caller_name = ?",

  hashAlgorithm = PasswordHash.class,

  useFor = IdentityStore.ValidationType.VALIDATE,

  priority = 10

)

@BasicAuthenticationMechanismDefinition(realmName = "file")

public class SystemStartup {


}



When I make a request to the system for the first time, the exception below is thrown (I increased the log level from INFO to FINEST):



[2018-05-13T17:10:25.935+0200] [] [FINE] [] [com.sun.enterprise.container.common.impl.JavaModuleNamingProxy] [tid: _ThreadID=26 _ThreadName=http-thread-pool::http-listener(7)] [timeMillis: 1526224225935] [levelValue: 500] [CLASSNAME: com.sun.enterprise.container.common.impl.JavaModuleNamingProxy] [METHODNAME: getJavaModuleOrAppEJB] [[

  java:global/jdbc/snsDB Unable to map java:app/jdbc/snsDB to derived name java:global/jdbc/snsDB

javax.naming.NamingException: Lookup failed for 'java:global/jdbc/snsDB' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NameNotFoundException: jdbc]

at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:496)

at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)

at javax.naming.InitialContext.lookup(InitialContext.java:417)

at javax.naming.InitialContext.lookup(InitialContext.java:417)

at com.sun.enterprise.container.common.impl.JavaModuleNamingProxy.getJavaModuleOrAppEJB(JavaModuleNamingProxy.java:340)

at com.sun.enterprise.container.common.impl.JavaModuleNamingProxy.handle(JavaModuleNamingProxy.java:149)

at com.sun.enterprise.naming.impl.NamedNamingObjectManager.tryNamedProxies(NamedNamingObjectManager.java:134)

at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:164)

at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:476)

at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)

at javax.naming.InitialContext.lookup(InitialContext.java:417)

at javax.naming.InitialContext.lookup(InitialContext.java:417)

at org.glassfish.soteria.cdi.CdiUtils.jndiLookup(CdiUtils.java:226)

at org.glassfish.soteria.identitystores.DatabaseIdentityStore.getDataSource(DatabaseIdentityStore.java:194)

at org.glassfish.soteria.identitystores.DatabaseIdentityStore.validate(DatabaseIdentityStore.java:109)

at org.glassfish.soteria.identitystores.DatabaseIdentityStore.validate(DatabaseIdentityStore.java:101)

at org.jboss.weldx.security.enterprise.identitystore.IdentityStore$635317201$Proxy$_$$_WeldClientProxy.validate(Unknown Source)

at org.glassfish.soteria.cdi.DefaultIdentityStoreHandler.validate(DefaultIdentityStoreHandler.java:96)

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.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)

at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:106)

at org.jboss.weldx.security.enterprise.identitystore.IdentityStoreHandler$1763020431$Proxy$_$$_WeldClientProxy.validate(Unknown Source)

at org.glassfish.soteria.mechanisms.BasicAuthenticationMechanism.validateRequest(BasicAuthenticationMechanism.java:84)

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.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)

at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:106)

at org.jboss.weldx.security.enterprise.authentication.mechanism.http.HttpAuthenticationMechanism$1696408576$Proxy$_$$_WeldClientProxy.validateRequest(Unknown Source)

at org.glassfish.soteria.mechanisms.jaspic.HttpBridgeServerAuthModule.validateRequest(HttpBridgeServerAuthModule.java:114)

at org.glassfish.soteria.mechanisms.jaspic.DefaultServerAuthContext.validateRequest(DefaultServerAuthContext.java:76)

at com.sun.web.security.RealmAdapter.validate(RealmAdapter.java:1632)

at com.sun.web.security.RealmAdapter.invokeAuthenticateDelegate(RealmAdapter.java:1483)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:579)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:622)

at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:598)

at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)

at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)

at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:516)

at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:213)

at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)

at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)

at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:242)

at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)

at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)

at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)

at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)

at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)

at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)

at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)

at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)

at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)

at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)

at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)

at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)

at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)

at java.lang.Thread.run(Thread.java:748)

Caused by: javax.naming.NameNotFoundException: jdbc

at com.sun.enterprise.naming.impl.TransientContext.resolveContext(TransientContext.java:299)

at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:207)

at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:208)

at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:70)

at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:114)

at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:483)

... 62 more

]]


The system is renaming java:app/jdbc/snsDB to java:global/jdbc/snsDB.
Am I missing something here?

Additional info:

I am using Payara Micro 5.181. 
Application is deployed as an UberJar using the --outputUberJar option.
On the REST methods that I am trying to secure I am using only @RolesAllowed("admin") and nothing else on the specific methods that need to be secured.

Thank you very much for your insight on this.

With kind regards,
Guilherme
Reply all
Reply to author
Forward
0 new messages