[jboss-jira] [JBoss JIRA] (AS7-3162) RESTEasy: Unknown servet name javax.ws.rs.core.Application when javax.ws.rs.core.Application subclass is on classpath

Pavel Janousek (Commented) (JIRA) jira-events at lists.jboss.org
Thu Jan 5 09:22:09 EST 2012


    [ https://issues.jboss.org/browse/AS7-3162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12654051#comment-12654051 ] 

Pavel Janousek commented on AS7-3162:
-------------------------------------

Hi Weinen, you are right only partially.

My primary goal was finding the way how to do servlet-mapping in web.xml (not via annotation) and use the +portable+ way - not locking to concrete JAX-RS implementation. I thought this way is to specify servlet-mapping via reserved key (servlet-name) javax.ws.rs.Application or javax.ws.rs.core.Application. This was really bad idea.

But my previous example/deployment from [there|https://issues.jboss.org/browse/AS7-3162?focusedCommentId=12653831&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12653831] is valid, I'm missing only definition of servlet-name org.jboss.as.test.integration.jaxrs.deployments.ApplicatonEmptyWithoutAOP. This is Servlet 3.0 feature - omit servlet-class in this way.

So you don't need annotation and can use servlet-mapping via fully qualified class name, but it seems you must define servlet-name yourself - I understood Stuarts citation from JAX-RS specs as requirement for JAX-RS implementation in this case - never mind.

So Application class can stay untouched, but deployment must be modified to this:{code}<?xml version=1.0 encoding="UTF-8"?>
<web-app version="3.0" 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_3_0.xsd" metadata-complete="false">

	<servlet>
		<servlet-name>org.jboss.as.test.integration.jaxrs.deployments.ApplicatonEmptyWithoutAOP</servlet-name>
	</servlet> 

	<servlet-mapping>
		<servlet-name>org.jboss.as.test.integration.jaxrs.deployments.ApplicatonEmptyWithoutAOP</servlet-name>
		<url-pattern>/myjaxrs/*</url-pattern>
	</servlet-mapping>
</web-app>{code}

Sure, this way is also supported by RESTEasy and it works too:-).

Anyway - topic about mixing annotation and web.xml mapping - there is section 8 in Servlet 3.0 specs, where everything about these topics is described. Very shortly - web.xml mapping has higher priority (= replaces annotation in conflicted states) and annotation is processed only when attribute metadata-complete of web-app element isn't set to true - this works too. I'm feeling mixing annotation and servlet-mapping primary as way for cooperation legacy code (annotation was introduced in Java 1.5 - so not many years ago as servlet technology) and AOP paradigm. Many servlets are implemented (and debugged) by old-school way and annotation modifications can enter many issues to them - we should take this in "QA mind":-) too.
                
> RESTEasy: Unknown servet name javax.ws.rs.core.Application when javax.ws.rs.core.Application subclass is on classpath 
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: AS7-3162
>                 URL: https://issues.jboss.org/browse/AS7-3162
>             Project: Application Server 7
>          Issue Type: Bug
>          Components: REST
>    Affects Versions: 7.1.0.CR1b
>            Reporter: Pavel Janousek
>            Assignee: Weinan Li
>            Priority: Blocker
>
> I've deployment like this:
> {code}
> @Deployment
> public static Archive<?> deploy() {
> 	WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrsnoap.war");
> 	war.addPackage(HttpRequest.class.getPackage());
> 	war.addClasses(ApplicationTestCase.class, ApplicationInvalid1.class);
> 	war.addAsWebInfResource(
> 			WebXml.get("<servlet-mapping>\n"
> 					+ "        <servlet-name>javax.ws.rs.core.Application</servlet-name>\n"
> 					+ "        <url-pattern>/myjaxrs/*</url-pattern>\n"
> 					+ "</servlet-mapping>\n" + "\n"), "web.xml");
> 	return war;
> }
> {code}
> This deployment fails during deploying because of "Context [/jaxrsnoap] startup failed due to previous errors: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name javax.ws.rs.core.Application"
> ApplicationInvalid1 is empty subclass of javax.ws.rs.core.Application like:
> {code}
> public class ApplicationInvalid1 extends Application {
> 	private Set<Class<?>> classes = new HashSet<Class<?>>();
> 	public ApplicationInvalid1() {
> 	}
> 	@Override
> 	public Set<Class<?>> getClasses() {
> 		return classes;
> 	}
> }
> {code}
> There isn't any reference to this class in web.xml or somewhere else. Only class is placed on classpath. If I remove this class from deployment (= change appropriate line to "war.addClasses(ApplicationTestCase.class);", everything will be OK.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list