[jboss-jira] [JBoss JIRA] Updated: (JBAS-4805) InitialContextFactory.getHAContext() should not use hardcoded localhost for lookup

Galder Zamarreno (JIRA) jira-events at lists.jboss.org
Wed Oct 17 08:39:04 EDT 2007


     [ http://jira.jboss.com/jira/browse/JBAS-4805?page=all ]

Galder Zamarreno updated JBAS-4805:
-----------------------------------

    Workaround Description: 
+ Workaround for injecting ConnectionFactory instances - Inject JmsXA instead of ConnectionFactory

   @Resource(mappedName="java:/JmsXA", type=javax.jms.ConnectionFactory.class) 
   private ConnectionFactory factory;

+ Workarounds for injecting Queue/Topic instances:

1.- Not to inject Queue and instead, assuming the queue name is "queue/A" use the
following code to initialise it the first time you use the Queue instance variable:

String bindAddress = System.getProperty("jboss.bind.address") == null ? "localhost" : System.getProperty("jboss.bind.address");
InitialContext ic = new InitialContext();
Queue queueA = (Queue)ic.lookup("jnp://" + bindAddress + ":1100/queue/A");

2.- For this second option, let's assume the queue name is "queue/B". In this case,
you can add META-INF/jboss.xml to your EJB jar deployment, which looks like this:

<?xml version="1.0"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>InhaltPruefungVerwaltungBean</ejb-name>
<resource-ref>
<res-ref-name>queue/ref/B</res-ref-name>
<jndi-name>jnp://${jboss.bind.address:localhost}:1100/queue/B</jndi-name>
</resource-ref>
</session>
</enterprise-beans>
</jboss>

And inject the Queue in your EJB this way:

@Resource(mappedName="java:comp/env/queue/ref/B")
private Queue queueB;

  was:
A possible workaround (that the customer is trying out at the moment is):

in deploy/cluster-service.xml:

<mbean code="org.jboss.ha.jndi.HANamingService"
name="jboss:service=HAJNDI">
...
<!-- Bind address of bootstrap and HA-JNDI RMI endpoints -->
<attribute name="BindAddress">localhost</attribute> 


Updated with workarounds from support case.

> InitialContextFactory.getHAContext() should not use hardcoded localhost for lookup
> ----------------------------------------------------------------------------------
>
>                 Key: JBAS-4805
>                 URL: http://jira.jboss.com/jira/browse/JBAS-4805
>             Project: JBoss Application Server
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: EJB3
>    Affects Versions: JBossAS-4.2.1.GA, JBossAS-5.0.0.Beta2
>            Reporter: Galder Zamarreno
>         Assigned To: William DeCoste
>
> org.jboss.ejb3.InitialContextFactory.getHAContext() contains:
> env.put(Context.PROVIDER_URL, "localhost:" + getHaJndiPort());
> InitialContext haCtx = new InitialContext(env);
> The code should not have hardcoded localhost because as soon as someone binds JBoss 
> to something different, a localhost lookup will fail.
> This could should instead check HAJNDI service's BindAddress attribute and use that.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list