java - Wildfly-swarm: cannot access jax-rs resource (404 Not found) -
i want give wildfly-swarm try. created project jax-rs fraction , simple hello world resource. ran got 404 not found.
here's pom.xml
<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>org.aca.studies</groupid> <artifactid>swarm</artifactid> <version>1.0</version> <properties> <version.wildfly-swarm>2017.7.0</version.wildfly-swarm> </properties> <build> <plugins> <plugin> <groupid>org.wildfly.swarm</groupid> <artifactid>wildfly-swarm-plugin</artifactid> <version>${version.wildfly-swarm}</version> <executions> <execution> <goals> <goal>package</goal> </goals> </execution> <execution> <id>start</id> </execution> <execution> <id>stop</id> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupid>org.wildfly.swarm</groupid> <artifactid>jaxrs</artifactid> <version>${version.wildfly-swarm}</version> </dependency> </dependencies> and here's jax-rs resource
package org.aca.studies; import javax.ws.rs.get; import javax.ws.rs.path; import javax.ws.rs.produces; @path("/app") public class resource { @get @path("/greet") @produces("text/html") public string greet() { return system.currenttimemillis() + ""; } } as can see simple. maybe i'm missing something. did not add @applicationpath annotated class because according documentation (https://wildfly-swarm.gitbooks.io/wildfly-swarm-users-guide/content/common/jax-rs.html) fraction adds 1 default. thing picked examples on github (https://github.com/wildfly-swarm/wildfly-swarm-examples/tree/master/jaxrs/jaxrs) that:
since wildfly swarm apps tend support 1 deployment per executable, automatically adds jboss-web.xml deployment if doesn't exist. used bind deployment root of web-server, instead of using .war's own name application context.
so that's why i'm trying access resource http://localhost:8080/app/greet
from pom think issue don't have <packaging>war</packaging> present means jar created instead.
if change maven packaging war should fine
Comments
Post a Comment