-2

I'm a newbie using Fabric8-1.2.0.Beta4 and trying to deploy REST example application (taken from http://tomee.apache.org/examples-trunk/rest-example/README.html) to Tomee on Fabric8. Including openejb-cxf-rs and tomee-jaxrs don't seem to help.

Only changes made: 1) web.xml Added the following as suggested by http://tomee-openejb.979440.n4.nabble.com/Problem-deploying-REST-Examples-on-Eclipse-td4582815.html:

    <servlet>
       <servlet-name>ApplicationConfig</servlet-name>
       <init-param>
           <param-name>javax.ws.rs.Application</param-name>
           <param-value>ApplicationConfig</param-value>
       </init-param>
    </servlet>
    <servlet-mapping>
       <servlet-name>ApplicationConfig</servlet-name>
       <url-pattern>/*</url-pattern>
    </servlet-mapping> 

2) Added fabric8-maven-plugin and distributionManagement to pom.xml to use fabric8:deploy to deploy the war file and create rest-example profile.

    <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>fabric8-maven-plugin</artifactId>
        <version>1.2.0.Beta4</version>
        <configuration>
            <parentProfiles>containers-tomee hawtio</parentProfiles>
            <profile>${fabric8.profile}</profile>
            <profileVersion>${fabric8.version}</profileVersion>
            <jolokiaUrl>http://${deploy-host}:${deploy-port}/jolokia</jolokiaUrl>
            <webContextPath>/rest-example</webContextPath>
        </configuration>
    </plugin>


    <distributionManagement>  
        <repository>  
            <id>fabric-maven-proxy</id>  
            <name>FMC Maven Proxy</name>  
            <!-- Change to your target host -->  
            <url>fabric::default::http://admin:${password}@${deploy-host}:${deploy-port}/maven/upload/</url>
        </repository>  
    </distributionManagement> 

After which I created a container to start the REST application. Able to see the index.html but always getting 403 or 404 errors when trying to call the WS.

Pls help. Thanks


Had removed the changes in web.xml, downloaded apache-tomee-jaxrs-1.7.1 and configured it to run on this version of tomee, it is able to run without issue.

Would need figure out what's the difference between jaxrs and webprofile version so as to make it work on Fabric8-1.2.0.Beta4


Web.xml after change:

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
             metadata-complete="false"
             version="2.5">
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>WEB-INF/beans.xml</param-value>
        </context-param>

        <listener>
            <listener-class>
              org.springframework.web.context.ContextLoaderListener
             </listener-class>
        </listener>

        <servlet>
            <servlet-name>CXFServlet</servlet-name>
            <display-name>CXF Servlet</display-name>
            <servlet-class>
                org.apache.cxf.transport.servlet.CXFServlet
            </servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
            <servlet-name>CXFServlet</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
    </web-app>

beans.xml after change:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:jaxrs="http://cxf.apache.org/jaxrs"
           xsi:schemaLocation="
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://cxf.apache.org/jaxrs
           http://cxf.apache.org/schemas/jaxrs.xsd">

          <!-- do not use import statements if CXFServlet init parameters link to this beans.xml -->

         <import resource="classpath:META-INF/cxf/cxf.xml" />
         <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

         <jaxrs:server id="restExampleService" address="/rest-example">
            <jaxrs:serviceBeans>
                <ref bean="postWS" />
                <ref bean="commentWS" />
                <ref bean="userWS" />
            </jaxrs:serviceBeans>
         </jaxrs:server>

         <bean id="postWS" class="org.superbiz.rest.service.PostService" />
         <bean id="commentWS" class="org.superbiz.rest.service.CommentService" />
         <bean id="userWS" class="org.superbiz.rest.service.UserService" />
   </beans>

Also added 4 features to my profile in Fabric8: spring-web spring cxf-jaxrs fabric-rest

zephyr -
  • 11
  • 3
  • 2
    Hm, you will need to provide a stacktrace or code sample if you want any directed help. 4xx codes probably show that your application is running, but jaxrs or however you are mapping your URIs and HTTP verbs is not being registered correctly. – Sam Berry Oct 23 '14 at 02:09

1 Answers1

0

webprofile version doesn't support JAXRS (no provider) but jaxrs and plus versions have it built in.

Romain Manni-Bucau
  • 3,354
  • 1
  • 16
  • 13
  • Hi rmannibucau.. I know that but Fabric8 will only download webprofile version. I don't know how to get it to download the JAXRS version or what can be done to add JAXRS to webprofile. Pls advise if you know how. Thanks – zephyr - Oct 29 '14 at 00:43
  • Easiest is surely to add another container based on this one https://github.com/fabric8io/fabric8/blob/cef2ec8424876332ac6e74625cdc23257d1ba8d8/fabric/fabric8-karaf/src/main/resources/distro/fabric/import/fabric/profiles/containers/tomee.profile/io.fabric8.container.process.properties – Romain Manni-Bucau Oct 29 '14 at 08:14
  • Thanks it downloaded the jaxrs version in fabric8 but however, this REST application still does not run on fabric 8 (same issue), which it does run on my local standalone tomee jaxrs version. – zephyr - Nov 04 '14 at 04:59
  • Changed web.xml and beans.xml (see above), now able to call the WS, however it's throwing org.apache.cxf.interceptor.Fault at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:‌​170) ... Caused by: java.lang.NullPointerException at org.superbiz.rest.service.UserService.create(UserService.java:46).. Look like some issue with OpenEJB or hsqldb not loaded – zephyr - Nov 06 '14 at 02:24