tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Radhakrishna Kalyan <nrkkal...@gmail.com>
Subject OpenEJB in JavaSE(Need help)
Date Sat, 19 Oct 2013 14:54:49 GMT
Hi

Iam looking to develop a REST based webservice but I don't want to use any
application server. All I am looking is to start my application which in
turn should start the http server with CDI along with Jax-RS.  I felt
OpenEJB is the right tool for this.

I have used "com.sun.net.httpserver.HttpServer" as http server and Jersey
for my Jax-RS implementation and now I would like to use OpenEJB for CDI.

When I tried to write something like

public static void main(String[] args) throws Exception {
        MyBootStrap bootStrap= new MyBootStrap();
        Properties p = new Properties();
        p.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");

p.setProperty("com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager",
"true");
        EJBContainer.createEJBContainer(p).getContext().bind("inject",
bootStrap);

        HttpServer server = HttpServer.create(new InetSocketAddress(9998),
0);
        HttpHandler sf = RuntimeDelegate.getInstance().createEndpoint(new
ApplicationConfig(), HttpHandler.class);
        server.createContext("/", sf);
        server.start();
    }


But when I start my application then I am getting exception.
java.lang.RuntimeException: javax.naming.NoInitialContextException: Need to
specify class name in environment or system property, or as an applet
parameter, or in an application resource file:  java.naming.factory.initial
    at
com.sun.jersey.server.impl.cdi.CDIExtension.initialize(CDIExtension.java:196)
    at
com.sun.jersey.server.impl.cdi.CDIExtension.beforeBeanDiscovery(CDIExtension.java:297)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:295)
    at
org.apache.webbeans.event.NotificationManager.fireEvent(NotificationManager.java:429)
...More

Detail exception is attached as attachment.


I am not understanding how to trigger the CDI while starting http server.

Please give me some pointers if I am doing any wrong or if I should use any
thing more.

Thanks in advance.
-- 
Thanks and Regards
N Radhakrishna Kalyan

P:  +46 733 312 584
http://about.me/nrkkalyan
 <http://about.me/nrkkalyan>

Mime
View raw message