You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by andreessen <an...@list.ru> on 2010/01/21 18:54:54 UTC
Binding custom WebServiceContext problems.
Hi people,
Just ran into problems with binding. I am using OpenEJB for WS tests and
need to bind my custom WebServiceContext with JNDI to make
@Resource
WebServiceContext wctx;
works properly for my tests.
In my setUp method I do the following:
Properties props = new Properties();
props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
props.setProperty("openejb.embedded.remotable", "true");
initialContext = new InitialContext(props);
WebServiceContextStub wctxStub = new WebServiceContextStub();
initialContext.bind("java:comp/WebServiceContext", wctxStub);
wctxStub =
(WebServiceContextStub)initialContext.lookup("java:comp/WebServiceContext");
But the last line throws javax.naming.NameNotFoundException: Name
"comp/WebServiceContext" not found. (jndi name was taken from
http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java?p2=%2Fincubator%2Fopenejb%2Ftrunk%2Fopenejb3%2Fcontainer%2Fopenejb-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fopenejb%2Fcore%2Fstateless%2FStatelessInstanceManager.java&p1=%2Fincubator%2Fopenejb%2Ftrunk%2Fopenejb3%2Fcontainer%2Fopenejb-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fopenejb%2Fcore%2Fstateless%2FStatelessInstanceManager.java&r1=531838&r2=531837&pathrev=531838&view=diff&diff_format=s
here ).
How could it be done? Appreciate for your help...
--
View this message in context: http://n4.nabble.com/Binding-custom-WebServiceContext-problems-tp1049990p1049990.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Binding custom WebServiceContext problems.
Posted by David Blevins <da...@visi.com>.
On Jan 26, 2010, at 1:50 PM, andreessen wrote:
> Thanks for your reply. I realized that I was wrong after I had
> posted my
> qustion - of course it is impossible. The idea of my qustion is to
> substitute MessageContext (or WebServiceContext) "on the fly" -
> using test
> objects instead real..
Sure it's impossible now, but you know, it's this kind of thing where
new features are born. I've definitely imagined that people might
want to swap out entire beans with mock implementations for testing
and have sort of been mulling that over in my head for a while trying
to figure out how best it might be to do that. But the idea of
swapping out WebServiceContext or any other context is one that hadn't
occurred to me.
I'd love it if you could provide an example scenario of how it might
be leveraged in a test. You might be onto something neat.
-David
Re: Binding custom WebServiceContext problems.
Posted by andreessen <an...@list.ru>.
Hi David,
Thanks for your reply. I realized that I was wrong after I had posted my
qustion - of course it is impossible. The idea of my qustion is to
substitute MessageContext (or WebServiceContext) "on the fly" - using test
objects instead real..
--
View this message in context: http://n4.nabble.com/Binding-custom-WebServiceContext-problems-tp1049990p1290276.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Binding custom WebServiceContext problems.
Posted by David Blevins <da...@visi.com>.
On Jan 21, 2010, at 6:54 PM, andreessen wrote:
> Just ran into problems with binding. I am using OpenEJB for WS tests
> and
> need to bind my custom WebServiceContext with JNDI to make
> @Resource
> WebServiceContext wctx;
> works properly for my tests.
>
> In my setUp method I do the following:
>
> Properties props = new Properties();
> props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
>
> "org.apache.openejb.client.LocalInitialContextFactory");
> props.setProperty("openejb.embedded.remotable", "true");
> initialContext = new InitialContext(props);
> WebServiceContextStub wctxStub = new WebServiceContextStub();
> initialContext.bind("java:comp/WebServiceContext", wctxStub);
> wctxStub =
> (WebServiceContextStub)initialContext.lookup("java:comp/
> WebServiceContext");
>
> But the last line throws javax.naming.NameNotFoundException: Name
> "comp/WebServiceContext" not found.
Hmm. Each bean gets it's own private "java:comp" namespace, so
binding the replacement WebServiceContext to the test case created
InitialContext won't have the affect you want. The bean won't be able
to see it.
What is the ultimate goal of the "WebServiceContextStub"? Maybe there
a new feature we could add to help get the end result that you need.
-David
--
http://blog.dblevins.com/
http://twitter.com/dblevins
Support OpenEJB with Tweets!