I created some JDBC resources and user resources in GlassFish. I named the JDBC resource jdbc/mydband user resource service/test.
jdbc/mydb
service/test
A JDBC connection is being made with a call ic.lookup("java:comp/env/jdbc/mydb"). It can also be found with help ic.lookup("jdbc/mydb"), which has some flaws, see Robin's answer below.
ic.lookup("java:comp/env/jdbc/mydb")
ic.lookup("jdbc/mydb")
But my user resource needs to be searched with ic.lookup("service/test"). The line does not work. Is it possible, and if so: how? ic.lookup("java:comp/env/service/test")
ic.lookup("service/test")
ic.lookup("java:comp/env/service/test")
, Java EE, JNDI. , .
JDBC, jndi. , , , , , . , .
.xml, , - / domain.xml:
<resources> <!-- JDBC RESOURCE --> ... <custom-resource res-type="java.lang.String" jndi-name="MyCustomStringResource" factory-class="org.glassfish.resources.custom.factory.PrimitivesAndStringFactory"> <property name="value" value="hello, this is a string resource"></property> </custom-resource> ... </resources> <servers> <server name="server" config-ref="server-config"> <application-ref ref="__admingui" virtual-servers="__asadmin"></application-ref> ... <resource-ref ref="MyCustomStringResource"></resource-ref> ... </server> </servers>
, Glassfish " ". Java EE , "java: comp/env" , . ,
, jdbc/mydb (EJB/servlet ..), . java: comp/env , .
glassfish 3 up admin gui localhost: 4848 gui JDNI > >
for the previous version of glassfish, I would recommend changing glassfish.xml to create a new resource using qualifiers