Lookup / discover JNDI names in Glassfish 3.1.2

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Lookup / discover JNDI names in Glassfish 3.1.2

forums-8
Hello, i try to lookup an EntityManager using the following piece of code
without success: EntityManager em = null; try { Context ic = new
InitialContext(); em = (EntityManager)
ic.lookup("java:comp/env/persistence/em"); } catch (NamingException e) {
logger.log(Level.SEVERE, "shit happens"+e); } which lead me to the question
how i can find out what resources are available via JNDI. I saw there is an
asadmin command list-jndi-entries, but there is a lot of information i dont
really understand: ... adding inhabitant:
LazyInhabitant-10805987(org.glassfish.gms.GMSAdapterImpl, active: null) to
habitat org.jvnet.hk2.component.Habitat@cec0c5 adding index for inhabitant:
LazyInhabitant-10805987(org.glassfish.gms.GMSAdapterImpl, active: null) with
typeName org.glassfish.gms.bootstrap.GMSAdapter and name null to habitat
org.jvnet.hk2.component.Habitat@cec0c5 adding inhabitant:
LazyInhabitant-19642336(org.glassfish.gms.GMSConfigUpgrade, active: null) to
habitat org.jvnet.hk2.component.Habitat@cec0c5 adding index for inhabitant:
LazyInhabitant-19642336(org.glassfish.gms.GMSConfigUpgrade, active: null)
with typeName org.glassfish.api.admin.config.ConfigurationUpgrade and name
gmsupgrade to habitat org.jvnet.hk2.component.Habitat@cec0c5 adding
inhabitant:
LazyInhabitant-20248218(org.glassfish.gms.admin.GMSAnnounceBeforeStartClusterCommand,
active: null) to habitat org.jvnet.hk2.component.Habitat@cec0c5 adding index
for inhabitant:
LazyInhabitant-20248218(org.glassfish.gms.admin.GMSAnnounceBeforeStartClusterCommand,
active: null) with typeName org.glassfish.api.admin.AdminCommand and name
_gms-announce-before-start-cluster-command to habitat
org.jvnet.hk2.component.Habitat@cec0c5 adding index for inhabitant:
LazyInhabitant-20248218(org.glassfish.gms.admin.GMSAnnounceBeforeStartClusterCommand,
active: null) with typeName org.glassfish.api.admin.Supplemental and name
null to habitat org.jvnet.hk2.component.Habitat@cec0c5 adding inhabitant:
LazyInhabitant-2758093(org.glassfish.gms.admin.GMSAnnounceAfterStopClusterCommand,
active: null) to habitat org.jvnet.hk2.component.Habitat@cec0c5 adding index
for inhabitant:
LazyInhabitant-2758093(org.glassfish.gms.admin.GMSAnnounceAfterStopClusterCommand,
active: null) with typeName org.glassfish.api.admin.AdminCommand and name
_gms-announce-after-stop-cluster-command to habitat
org.jvnet.hk2.component.Habitat@cec0c5 adding index for inhabitant:
LazyInhabitant-2758093(org.glassfish.gms.admin.GMSAnnounceAfterStopClusterCommand,
active: null) with typeName org.glassfish.api.admin.Supplemental and name
null to habitat org.jvnet.hk2.component.Habitat@cec0c5 adding inhabitant:
LazyInhabitant-16607409(org.glassfish.gms.admin.ValidateMulticastCommand,
active: null) to habitat org.jvnet.hk2.component.Habitat@cec0c5 adding index
for inhabitant:
LazyInhabitant-16607409(org.glassfish.gms.admin.ValidateMulticastCommand,
active: null) with typeName com.sun.enterprise.admin.cli.CLICommand and name
validate-multicast to habitat org.jvnet.hk2.component.Habitat@cec0c5 adding
inhabitant:
LazyInhabitant-14962806(org.glassfish.gms.bootstrap.GMSAdapterService,
active: null) to habitat org.jvnet.hk2.component.Habitat@cec0c5 adding index
for inhabitant:
LazyInhabitant-14962806(org.glassfish.gms.bootstrap.GMSAdapterService,
active: null) with typeName org.glassfish.api.Startup and name null to
habitat org.jvnet.hk2.component.Habitat@cec0c5 proceedTo(-1) - curr=null,
act=null, plan=-1, env=class java.lang.Void, thrd=Thread[main,5,main] event
PROGRESS - curr=-1, act=-1, plan=-1, env=class java.lang.Void,
thrd=Thread[main,5,main] sun.net.www.MessageHeader@1d256fa8 pairs: {GET
/__asadmin/list-jndi-entries?Xhelp=true HTTP/1.1: null}{Content-type:
application/octet-stream}{User-Agent: metadata}{Cache-Control:
no-cache}{Pragma: no-cache}{Host: localhost:4848}{Accept: text/html,
image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
sun.net.www.MessageHeader@1ec89094 pairs: {null: HTTP/1.1 200
OK}{Content-Type: text/xml}{Transfer-Encoding: chunked}{Date: Fri, 13 Apr
2012 10:45:22 GMT} sun.net.www.MessageHeader@1774b9b8 pairs: {GET
/__asadmin/list-jndi-entries HTTP/1.1: null}{Content-type:
application/octet-stream}{User-Agent: hk2-agent}{Cache-Control:
no-cache}{Pragma: no-cache}{Host: localhost:4848}{Accept: text/html,
image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
sun.net.www.MessageHeader@104c5754 pairs: {null: HTTP/1.1 200
OK}{Content-Type: text/html}{Transfer-Encoding: chunked}{Date: Fri, 13 Apr
2012 10:45:22 GMT}
com.sun.enterprise.container.common.spi.util.InjectionManager:
com.sun.enterprise.container.common.impl.util.InjectionManagerImpl jdbc:
com.sun.enterprise.naming.impl.TransientContext java:global:
com.sun.enterprise.naming.impl.TransientContext ejb:
com.sun.enterprise.naming.impl.TransientContext UserTransaction:
com.sun.enterprise.transaction.TransactionNamingProxy$UserTransactionProxy
com: com.sun.enterprise.naming.impl.TransientContext Command
list-jndi-entries executed successfully. What does all this habitant /
inhabitant stuff mean?

--

[Message sent by forum member 'chris.joelly']

View Post: http://forums.java.net/node/885070


Reply | Threaded
Open this post in threaded view
|

Re: Lookup / discover JNDI names in Glassfish 3.1.2

forums-8
Once you inject with @PersistenceContext or declare a persistence-context-ref
in the current module or component, your lookup will work. For example,
@PersistenceContext(name="persistence/em") persistence/em -cheng

--

[Message sent by forum member 'cf126330']

View Post: http://forums.java.net/node/885070