[
https://issues.jboss.org/browse/WFLY-3865?page=com.atlassian.jira.plugin....
]
Brad Maxwell edited comment on WFLY-3865 at 1/2/15 2:05 PM:
------------------------------------------------------------
@Resource / resource-ref is what a component would use to inject the JNDI resource. The
component that binds the JNDI resource would not want @Resource ... as that jndi value
would not exist and result in the deployment failing to deploy (chicken & the egg
problem). The only workaround I've seen is to do a try / catch in the @PreDestory and
log warning if it does not exist. The workaround would have PreDestroy remove the jndi
value if the deployment is undeployed when the app server is still running, and when the
app server is shutdown it would either unbind it or the app server would unbind it and a
warning would be logged.
It would be good to allow the component that binds it into jndi to attempt to unbind it at
shutdown before the app server binds it down.
was (Author: bmaxwell):
@Resource / resource-ref is what a component would use to inject the JNDI resource. The
component that binds the JNDI resource would not want @Resource ... as that jndi value
would not exist and result in the deployment failing to deploy (chicken & the egg
problem). The only workaround I've seen is to do a try / catch in the @PreDestory and
log warning if it does not exist. The workaround would have PreDestroy remove the jndi
value if the deployment is undeployed when the app server is still running, and when the
app server is shutdown it would either unbind it or the app server would unbind it and a
warning would be logged.
java:jboss/exported is not available in @PreDestroy methods during
shutdown
---------------------------------------------------------------------------
Key: WFLY-3865
URL:
https://issues.jboss.org/browse/WFLY-3865
Project: WildFly
Issue Type: Feature Request
Components: Naming
Affects Versions: 8.1.0.Final
Reporter: Kyle Lape
Assignee: Eduardo Martins
With the following code in a class named e.g. {{JNDIBinderBean.java}}
{code:java}
private static final String name = "java:jboss/exported/JNDIBinderBean";
private static final String value = "JNDIBinderBean instantiated at " + new
Date();
@PostConstruct
public void start() {
new InitialContext().rebind(name, value);
}
@PreDestroy
public void stop() {
new InitialContext().unbind(name);
}
{code}
When Wildfly shuts down, I get an error saying that the MSC service isn't available:
{noformat}
javax.naming.NamingException: JBAS011836: Could not resolve service
service jboss.naming.context.java.jboss.exported.JNDIBinderBean
{noformat}
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)