|
|
|
|
|
|
h*********e 发帖数: 247 | 1 I am following http://wiki.eclipse.org/Jetty/Tutorial Jetty_and_Maven_HelloWorld Building and Running the Web Application
somehow http://localhost:8080/hello-world/hello does not work,
while http://localhost:8080/hello does!
why jetty ignores my contextroot? did I miss anything?
thank you | r*****l 发帖数: 2859 | 2 By default就是这样了。建议你用ServletContextHandler map到不同的context root上面。我最近在用embedded jetty写RESTful,所以正好也遇到这个
问题。
public class OneServletContext
{
public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(new HelloServlet()),"/*");
context.addServlet(new ServletHolder(new HelloServlet("Buongiorno
Mondo")),"/it/*");
context.addServlet(new ServletHolder(new HelloServlet("Bonjour le
Monde")),"/fr/*");
server.start();
server.join();
}
}
【在 h*********e 的大作中提到】 : I am following http://wiki.eclipse.org/Jetty/Tutorial Jetty_and_Maven_HelloWorld Building and Running the Web Application : somehow http://localhost:8080/hello-world/hello does not work, : while http://localhost:8080/hello does! : why jetty ignores my contextroot? did I miss anything? : thank you
| h*********e 发帖数: 247 | 3 yes, your way is the first part in that link, mine is the 2nd part. | r*****l 发帖数: 2859 | 4 这些demo有些时候不是很严谨的。你只可当做参考。如果你和demo写的不一样,不如把
code贴上来大家看看。
【在 h*********e 的大作中提到】 : yes, your way is the first part in that link, mine is the 2nd part.
| h*********e 发帖数: 247 | 5 是这样的,我本来在试<> by David Winterfeldt中的例子,
svn co http://svn.springbyexample.org/enterprise/simple-spring-web-services/tags/1.1.2/ simple-spring-web-services
在命令行mvn clean install successfully,
但是在eclipse中,我运行junit tests 得到如下error,所以我就想先熟悉熟悉jetty,
我找到http://wiki.eclipse.org/Jetty/Tutorial/Jetty_and_Maven_HelloWorld
试了试Developing a Standard WebApp with Jetty and Maven, 我自己没有做任何改
动,就是想先走一遍文中的步骤,结果发现这个contextroot问题。
总结一下就是:
1. follow http://wiki.eclipse.org/Jetty/Tutorial/Jetty_and_Maven_HelloWorld 的第4部分, 没有任何改动, 发现文中说的contextroot根本不work.
2. svn co http://svn.springbyexample.org/enterprise/simple-spring-web-services/tags/1.1.2/ simple-spring-web-services
将project import 到eclipse 中,junit tests 报如下错。
611 [main] INFO /ws - spring-ws: init
621 [main] ERROR /ws - unavailable
java.lang.reflect.MalformedParameterizedTypeException
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.
validateConstructorArguments(ParameterizedTypeImpl.java:42)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.(
ParameterizedTypeImpl.java:35)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(
ParameterizedTypeImpl.java:77)
at sun.reflect.generics.factory.CoreReflectionFactory.
makeParameterizedType(CoreReflectionFactory.java:86)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.
java:122)
at sun.reflect.generics.tree.ClassTypeSignature.accept(
ClassTypeSignature.java:31)
at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(
ClassRepository.java:82)
at java.lang.Class.getGenericInterfaces(Class.java:794)
at org.springframework.core.GenericTypeResolver.getTypeVariableMap(
GenericTypeResolver.java:154)
at org.springframework.core.GenericTypeResolver.resolveReturnType(
GenericTypeResolver.java:93)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.
getPropertyType(GenericTypeAwarePropertyDescriptor.java:58)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(
TypeConverterDelegate.java:138)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(
BeanWrapperImpl.java:832)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(
BeanWrapperImpl.java:651)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(
AbstractPropertyAccessor.java:78)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(
AbstractPropertyAccessor.java:63)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.
java:119)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.
java:431)
at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:
263)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.
java:643)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:
517)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection
.java:152)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:
130)
at org.mortbay.jetty.Server.doStart(Server.java:222)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
50)
at org.springbyexample.ws.embedded.EmbeddedPersonServiceClientTest.init(
EmbeddedPersonServiceClientTest.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.internal.runners.ClassRoadie.runBefores(ClassRoadie.java:49)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:
36)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.
java:42)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(
JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution
.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
RemoteTestRunner.java:197)
637 [main] INFO mortbay.log - Started S********************[email protected]:10080
637 [main] INFO embedded.EmbeddedPersonServiceClientTest - Server started.
639 [main] INFO xml.XmlBeanDefinitionReader - Loading XML bean definitions
from class path resource [org/springbyexample/ws/embedded/
EmbeddedPersonServiceClientTest-context.xml]
717 [main] INFO support.GenericApplicationContext - Refreshing org.
springframework.context.support.GenericApplicationContext@643f96ee: display
name [org.springframework.context.support.GenericApplicationContext@643f96ee
]; startup date [Sun Jan 08 14:59:02 EST 2012]; root of context hierarchy
717 [main] INFO support.GenericApplicationContext - Bean factory for
application context [org.springframework.context.support.
GenericApplicationContext@643f96ee]: org.springframework.beans.factory.
support.DefaultListableBeanFactory@24c68a98
724 [main] INFO config.PropertyPlaceholderConfigurer - Loading properties
file from class path resource [org/springbyexample/ws/embedded/ws.properties]
... | h*********e 发帖数: 247 | 6 I found the reason
the pom.xml had :
org.eclipse.jetty
jetty-server
${jettyVersion}
org.mortbay.jetty
jetty-maven-plugin
${jettyVersion}
/guoguoHello
change pom.xml to this then the contextPath is working:
org.mortbay.jetty
jetty-embedded
${jetty.version}
test
org.mortbay.jetty
jetty-java5-threadpool
${jetty.version}
test
org.mortbay.jetty
maven-jetty-plugin
10
/nowitisworking
【在 h*********e 的大作中提到】 : 是这样的,我本来在试<> by David Winterfeldt中的例子, : svn co http://svn.springbyexample.org/enterprise/simple-spring-web-services/tags/1.1.2/ simple-spring-web-services : 在命令行mvn clean install successfully, : 但是在eclipse中,我运行junit tests 得到如下error,所以我就想先熟悉熟悉jetty, : 我找到http://wiki.eclipse.org/Jetty/Tutorial/Jetty_and_Maven_HelloWorld : 试了试Developing a Standard WebApp with Jetty and Maven, 我自己没有做任何改 : 动,就是想先走一遍文中的步骤,结果发现这个contextroot问题。 : 总结一下就是: : 1. follow http://wiki.eclipse.org/Jetty/Tutorial/Jetty_and_Maven_HelloWorld 的第4部分, 没有任何改动, 发现文中说的contextroot根本不work. : 2. svn co http://svn.springbyexample.org/enterprise/simple-spring-web-services/tags/1.1.2/ simple-spring-web-services
| r*****l 发帖数: 2859 | 7 As I mentioned before: "As I mentioned before: "这些demo有些时候不是很严谨的
。你只可当做参考".
However, if you use this, it should work with Jetty version 7.2.0.v20101020.
org.mortbay.jetty
jetty-maven-plugin
${jettyVersion}
/hello-world
【在 h*********e 的大作中提到】 : 是这样的,我本来在试<> by David Winterfeldt中的例子, : svn co http://svn.springbyexample.org/enterprise/simple-spring-web-services/tags/1.1.2/ simple-spring-web-services : 在命令行mvn clean install successfully, : 但是在eclipse中,我运行junit tests 得到如下error,所以我就想先熟悉熟悉jetty, : 我找到http://wiki.eclipse.org/Jetty/Tutorial/Jetty_and_Maven_HelloWorld : 试了试Developing a Standard WebApp with Jetty and Maven, 我自己没有做任何改 : 动,就是想先走一遍文中的步骤,结果发现这个contextroot问题。 : 总结一下就是: : 1. follow http://wiki.eclipse.org/Jetty/Tutorial/Jetty_and_Maven_HelloWorld 的第4部分, 没有任何改动, 发现文中说的contextroot根本不work. : 2. svn co http://svn.springbyexample.org/enterprise/simple-spring-web-services/tags/1.1.2/ simple-spring-web-services
| h*********e 发帖数: 247 | 8 yes, you right, I forgot to mention I added this too:
7.2.0.v20101020 |
|
|
|
|
|
|