New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run Ozark on Open Liberty 18.0.0.2 #200

Closed
mthmulders opened this Issue Sep 3, 2018 · 6 comments

Comments

Projects
None yet
2 participants
@mthmulders

mthmulders commented Sep 3, 2018

After having read the spec, I wanted to try MVC using Ozark on Open Liberty 18.0.0.2.

I wrote a very simple Hello World-style app, but I can't get it to work. When I access it, the following appears in the log:

[ERROR   ] SRVE0315E: An exception occurred: java.lang.Throwable: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4998)
    at [internal classes]
Caused by: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:366)
    ... 1 more
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:219)
    ... 1 more
Caused by: java.lang.NullPointerException
    at org.mvcspec.ozark.bootstrap.OzarkInitializer.isMvcApplication(OzarkInitializer.java:71)
    at org.mvcspec.ozark.bootstrap.OzarkInitializer.initialize(OzarkInitializer.java:51)
    at org.mvcspec.ozark.bootstrap.OzarkCoreFeature.configure(OzarkCoreFeature.java:41)
    at org.apache.cxf.jaxrs.provider.ServerProviderFactory.setProviders(ServerProviderFactory.java:220)
    ... 1 more

From what I found, it seems that OzarkCoreFeature doesn't get the ServletContext injected. I don't know why that is. Any clues?

@chkal

This comment has been minimized.

Contributor

chkal commented Sep 3, 2018

I guess you tried version 1.0.0-m03 of Ozark? Unfortunately this version doesn't work on Liberty. But you could give the latest snapshots a try. There have been some fixes since the last release and the latest snapshots should work fine.

Have a look here:

https://www.mvc-spec.org/ozark/docs/install-snapshots.html

@mthmulders

This comment has been minimized.

mthmulders commented Sep 3, 2018

Indeed, I have tried using 1.0.0-m03. Upgrading to latest snapshots brings me further, but I still can't get everything to work.

Instead of the previously enable jaxrs-2.0 feature in OpenLiberty, I've enabled beanValidation-2.0 (for validation), cdi-2.0 (for CDI), jaxrs-2.1 and jsp-2.3 (for JSP compilation) and restarted OpenLiberty.

Now I'm seeing the following:

Caused by: java.lang.NullPointerException
    at org.mvcspec.ozark.engine.ServletViewEngine.forwardRequest(ServletViewEngine.java:77)
    at org.mvcspec.ozark.engine.JspViewEngine.processView(JspViewEngine.java:55)
    at org.mvcspec.ozark.core.ViewableWriter.writeTo(ViewableWriter.java:165)
    at org.mvcspec.ozark.core.ViewableWriter.writeTo(ViewableWriter.java:75)
    at org.apache.cxf.jaxrs.utils.JAXRSUtils$3.run(JAXRSUtils.java:1425)
    at org.apache.cxf.jaxrs.utils.JAXRSUtils$3.run(JAXRSUtils.java:1422)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1422)
    at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:249)
    ... 37 more

It seems that there is a ServletRegistration for the JSP that is specified using the @View annotation on my Controller method. This registration, however, doesn't appear to have a mapping. The getMappings() method returns null there. I'm not sure if this is permitted by the Servlet spec: from the getMappings() JavaDoc I would think that it should return an empty Collection in that case.

What do you think?

P.S. I've updated the sample app accordingly.

chkal added a commit to chkal/ozark that referenced this issue Sep 3, 2018

@chkal

This comment has been minimized.

Contributor

chkal commented Sep 3, 2018

IMHO returning null from getMappings() is actually not allowed. The javadocs explicitly mention that the collection can be empty, so returning null is really weird.

However, I just created #201 to implement a workaround. Let's see if the CI build is still green.

chkal added a commit that referenced this issue Sep 3, 2018

@chkal

This comment has been minimized.

Contributor

chkal commented Sep 3, 2018

I just merged #201. So you could update the snapshots and try again.

@mthmulders

This comment has been minimized.

mthmulders commented Sep 3, 2018

Awesome, that has fixed it!

@chkal

This comment has been minimized.

Contributor

chkal commented Sep 4, 2018

Thanks for letting us know! 👍

However, please note that there are still some other known issues with Ozark on Liberty, as the TCK currently doesn't pass. This is most likely caused by incompatibilities with CXF. So feel free to report any issue you run into.

@chkal chkal closed this Sep 4, 2018

@chkal chkal added this to the 1.0.0-m04 milestone Sep 4, 2018

@chkal chkal self-assigned this Sep 4, 2018

@chkal chkal added the bug label Sep 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment