Hi,

Here I'm using DS based comp. dev't, and I have one bundle 
 'vnc-mw-example-http' that registers servlet successfully but it fails for 
actual test saying context path not found.

I'm getting this exception:

org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher]
 
: Scanning bundle [vnc-mw-directory-http]
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.swissbox.extender.BundleWatcher]
 
: Scanning bundle [vnc-mw-example-http]
org.ops4j.pax.web.pax-web-runtime[org.ops4j.pax.web.service.internal.HttpServiceFactoryImpl]
 
: Binding bundle: [vnc-mw-example-http [161]] to http service
org.ops4j.pax.web.pax-web-runtime[org.ops4j.pax.web.service.internal.HttpServiceStarted]
 
: Creating http service for: vnc-mw-example-http [161]
org.ops4j.pax.web.pax-web-runtime[org.ops4j.pax.web.service.internal.HttpServiceProxy]
 
: HttpServiceProxy created for HttpService 
org.ops4j.pax.web.service.internal.HttpServiceStarted@133de94b for bundle 
vnc-mw-example-http [161]
biz.vnc.mw.api.http.ServletRegistration@41be6f4e registering 
biz.vnc.mw.api.http.JAXApplication@4c93fc50 : 1 classes, 1 singletons, 0 
properties @ '/mw-test'
org.ops4j.pax.web.pax-web-runtime[org.ops4j.pax.web.service.internal.HttpServiceProxy]
 
: Registering servlet: [/mw-test] -> 
org.glassfish.jersey.servlet.ServletContainer@7fe3ddd8
org.ops4j.pax.web.pax-web-runtime[org.ops4j.pax.web.service.internal.HttpServiceStarted]
 
: Register servlet (alias=/mw-test). Using context 
[ContextModel{id=org.ops4j.pax.web.service.spi.model.ContextModel-1,name=,httpContext=DefaultHttpContext
 
[bundle=vnc-mw-example-http [161], 
contextID=default],contextParams={},virtualHosts={},connectors={}}]
org.ops4j.pax.web.pax-web-runtime[org.ops4j.pax.web.service.internal.ServletEventDispatcher]
 
: Sending web event ServletEvent [replay=false, type=DEPLOYING, 
bundle=161-vnc-mw-example-http, timestamp=1498822301386, alias=/mw-test, 
servletName=org.ops4j.pax.web.service.spi.model.ServletModel-2, 
urlParameter=[/mw-test/*], 
servletClass=org.glassfish.jersey.servlet.ServletContainer], 
httpContext=DefaultHttpContext [bundle=vnc-mw-example-http [161], 
contextID=default]] for bundle vnc-mw-example-http
org.ops4j.pax.web.pax-web-runtime[org.ops4j.pax.web.service.internal.LogServiceHandler]
 
: org/osgi/service/web/DEPLOYING
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.JettyServerImpl]
 
: Adding servlet 
[ServletModel{id=org.ops4j.pax.web.service.spi.model.ServletModel-2,name=org.ops4j.pax.web.service.spi.model.ServletModel-2,urlPatterns=[/mw-test/*],alias=/mw-test,servlet=org.glassfish.jersey.servlet.ServletContainer@7fe3ddd8,initParams={},context=ContextModel{id=org.ops4j.pax.web.service.spi.model.ContextModel-1,name=,httpContext=DefaultHttpContext
 
[bundle=vnc-mw-example-http [161], 
contextID=default],contextParams={},virtualHosts={},connectors={}}}]
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper]
 
: Creating new ServletContextHandler for HTTP context [DefaultHttpContext 
[bundle=vnc-mw-example-http [161], contextID=default]] and model 
[ContextModel{id=org.ops4j.pax.web.service.spi.model.ContextModel-1,name=,httpContext=DefaultHttpContext
 
[bundle=vnc-mw-example-http [161], 
contextID=default],contextParams={},virtualHosts={},connectors={}}]
org.ops4j.pax.web.pax-web-api[org.ops4j.pax.web.utils.ServletContainerInitializerScanner]
 
: will add 
org.eclipse.jetty.websocket.server.NativeWebSocketServletContainerInitializer 
to ServletContainerInitializers
org.ops4j.pax.web.pax-web-api[org.ops4j.pax.web.utils.ServletContainerInitializerScanner]
 
: added ServletContainerInitializer: 
org.eclipse.jetty.websocket.server.NativeWebSocketServletContainerInitializer
org.ops4j.pax.web.pax-web-api[org.ops4j.pax.web.utils.ServletContainerInitializerScanner]
 
: will add 
org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer
 
to ServletContainerInitializers
org.ops4j.pax.web.pax-web-api[org.ops4j.pax.web.utils.ServletContainerInitializerScanner]
 
: added ServletContainerInitializer: 
org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection]
 
: Adding bean: HttpServiceContext{httpContext=null}
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.HttpServiceContext]
 
: Creating default LateInvalidatingHashSessionManager, no SessionIdManager 
currently set
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.HttpServiceContext]
 
: registering context DefaultHttpContext [bundle=vnc-mw-example-http [161], 
contextID=default], with context-name: 
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper]
 
: configureSessionManager for context 
[HttpServiceContext{httpContext=DefaultHttpContext 
[bundle=vnc-mw-example-http [161], contextID=default]}] using - timeout:5, 
cookie:JSESSIONID, url:jsessionid, cookieHttpOnly:false, workerName:null, 
lazyLoad:false, storeDirectory: null
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper]
 
: Session timeout set to 5 minutes for context 
[HttpServiceContext{httpContext=DefaultHttpContext 
[bundle=vnc-mw-example-http [161], contextID=default]}]
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper]
 
: Session cookie set to JSESSIONID for context 
[HttpServiceContext{httpContext=DefaultHttpContext 
[bundle=vnc-mw-example-http [161], contextID=default]}]
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper]
 
: Session cookieHttpOnly set to false for context 
[HttpServiceContext{httpContext=DefaultHttpContext 
[bundle=vnc-mw-example-http [161], contextID=default]}]
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper]
 
: Session cookie secure set to false for context 
[HttpServiceContext{httpContext=DefaultHttpContext 
[bundle=vnc-mw-example-http [161], contextID=default]}]
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper]
 
: Session URL set to jsessionid for context 
[HttpServiceContext{httpContext=DefaultHttpContext 
[bundle=vnc-mw-example-http [161], contextID=default]}]
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper]
 
: is LazyLoad active? false
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper]
 
: Added servlet context: HttpServiceContext{httpContext=DefaultHttpContext 
[bundle=vnc-mw-example-http [161], contextID=default]}
org.ops4j.pax.web.pax-web-jetty[org.ops4j.pax.web.service.jetty.internal.HttpServiceContext]
 
: contextInitialized: 
javax.servlet.ServletContextEvent[source=ServletContext@HttpServiceContext{httpContext=DefaultHttpContext
 
[bundle=vnc-mw-example-http [161], 
contextID=default]}]->org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer$ContextDestroyListener@2883acff
2017-06-30 17:01:42.474:WARN:default:FelixStartLevel: unavailable
java.lang.NullPointerException
at 
org.glassfish.hk2.utilities.ServiceLocatorUtilities.addClasses(ServiceLocatorUtilities.java:435)
at 
org.glassfish.hk2.utilities.ServiceLocatorUtilities.enablePerThreadScope(ServiceLocatorUtilities.java:107)
at 
org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:141)
at 
org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:123)
at 
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:330)
        ..............
  
 
org.ops4j.pax.web.pax-web-runtime[org.ops4j.pax.web.service.internal.HttpServiceStarted]
 
: Could not start the servlet context for context path []
javax.servlet.ServletException: 
org.ops4j.pax.web.service.spi.model.ServletModel-2@378be0fa==org.glassfish.jersey.servlet.ServletContainer,-1,false
at 
org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:661)
at 
org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:419)
        .............
Caused by: java.lang.NullPointerException
at 
org.glassfish.hk2.utilities.ServiceLocatorUtilities.addClasses(ServiceLocatorUtilities.java:435)
at 
org.glassfish.hk2.utilities.ServiceLocatorUtilities.enablePerThreadScope(ServiceLocatorUtilities.java:107)
at 
org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:141)
        ................
For detailed log I have attached complete log and a way how I register 
servlet file. It registers servlet successfully then how it is getting 
failed saying not context path found.

Thank you.

On Wednesday, May 31, 2017 at 8:08:31 PM UTC+5:30, Achim Nierbeck wrote:
>
> Hi, 
>
> sorry to say, but those are the most simple examples you'll find. 
> Believe me we're not making them harder then they need to. 
>
> here is the example: 
> https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/web-jersey
>
> the corresponding test is: 
>
> https://github.com/ops4j/org.ops4j.pax.web/blob/master/pax-web-itest/pax-web-itest-container/pax-web-itest-container-jetty/src/test/java/org/ops4j/pax/web/itest/jetty/JerseyCustomContextIntegrationTest.java
>
> regards, Achim 
>
>
> 2017-05-31 16:14 GMT+02:00 Umesh Rajani <[email protected] <javascript:>>
> :
>
>> Hi 
>>
>> I have gone through :https://github.com/ops4j/org.ops4j.pax.web
>> I have checked examples :
>> https://github.com/ops4j/org.ops4j.pax.web/tree/master/pax-web-itest/pax-web-itest-container/pax-web-itest-container-jetty
>>
>> But it is too much complex to replicate in my own code, I want to perform 
>> runtime unit test for jersey REST bundle, I checked there are already 
>> sample test for jersey given but it hard to decode and replicate.
>>
>> So do we have any simple example to use Web PAX-Exam for unit test for 
>> any web application.
>>
>> I'm already using PAX-Exam for unit testing for non-web bundle and it 
>> works fine. but to test 
>> REST jersey giving me nightmare 
>>
>> Please anyone has gone through any simple example.
>>
>> Thank you 
>>
>> -- 
>> -- 
>> ------------------
>> OPS4J - http://www.ops4j.org - [email protected] <javascript:>
>>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "OPS4J" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
>
> Apache Member
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & 
> Project Lead
> blog <http://notizblog.nierbeck.de/>
> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
>
> Software Architect / Project Manager / Scrum Master 
>
>

-- 
-- 
------------------
OPS4J - http://www.ops4j.org - [email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
package biz.vnc.mw.example.http;

import java.util.Date;

import javax.servlet.ServletException;

import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.http.HttpService;
import org.osgi.service.http.NamespaceException;

import biz.vnc.mw.api.http.ServletRegistration;


@Component(immediate = true, configurationPolicy = ConfigurationPolicy.IGNORE)
public class Example
{
	@Reference private HttpService _httpService;

	private ServletRegistration _registration;

	@Activate void activate(BundleContext bc) throws ServletException, NamespaceException
	{
		_registration = ServletRegistration.register(
			bc, _httpService, "/mw-test",
			Controller1.class,		// controller lifecycle will be managed by JAX implementation. usually per-request
			new Controller2("created at " + new Date()) // singleton controller instance
		);
	}

	@Deactivate void deactivate()
	{
		if (_registration != null)
			_registration.unregister();
	}
}

Attachment: log-Pax-web-REST-test
Description: Binary data

Reply via email to