[
https://issues.apache.org/jira/browse/OPENEJB-1969?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13532689#comment-13532689
]
Trevor Baker commented on OPENEJB-1969:
---------------------------------------
Tried the fix. I added something to java:/jndi/myprop. And it ended up as
java:openejb/jndi/myprop.
I changed the code to be:
@Override
public void start() throws LifecycleException {
try {
initialContext = new InitialContext(properties);
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
LocalInitialContextFactory.class.getName());
contextProducer.set(new InitialContext(props));
} catch (NamingException e) {
throw new LifecycleException("can't start the OpenEJB container",
e);
}
assembler = SystemInstance.get().getComponent(Assembler.class);
configurationFactory = new ConfigurationFactory();
}
And then jndi entry gets added to the appropriate place with a few caveats...
@Observes AfterStart event: I get context, but after populating jndi tree it
isn't available anywhere else. It's gone.
@Observes BeforeSuite event: doesn't get fired. I guessing Arquillian doesn't
support at the moment. Fine.
@Observes BeforeClass event: @Inject Instance<Context> ctx.get() returns null.
I'm guessing Arquillian issue? Fine.
@Observes Before event: I get context and can use it within my @Test but not in
my custom @ConfigProp, which does the new InitialContext() lookup in the
javax.enterprise.inject.spi.Bean#create(). My org uses Java SE 6 and decided to
write custom @ConfigProp instead of endorsing Java EE 6 annotation jar with
@Resource(lookup). Lame. Good news, Java SE 7 with @Resource(lookup) works.
@Observes(precedence=1) Before event: all works.
I recommend doing the code change above. Don't know if you want to look at the
other ones. Maybe the AfterStart one? I guess that's a separate issue though.
> OpenEJBDeployableContainer has InstanceProducer<Context>
> --------------------------------------------------------
>
> Key: OPENEJB-1969
> URL: https://issues.apache.org/jira/browse/OPENEJB-1969
> Project: OpenEJB
> Issue Type: Improvement
> Components: arquillian
> Affects Versions: 4.5.1
> Reporter: Trevor Baker
> Priority: Minor
>
> Nice to have
> In OpenEJBDeployableContainer
> Change this:
> private InitialContext initialContext;
> To this:
> @Inject
> @DeploymentScoped // I'm assuming DeploymentScoped .. is there a better
> one to use?
> private InstanceProducer<Context> initialContext;
> So other Arquillian stuff can access the context with:
> @Inject
> private Instance<Context> ctx;
>
> Instead of new InitialContext().
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira