I'm trying to create a very simple RESTful Web Service with Spring Boot to perform NLP to the content passed as a parameter. You can find it on my GitHub.
For some reason, I can't deploy it to my Tomcat container in my home server as a WAR (see here), therefore I decided at least to try to set it up as a runnable JAR.
If I run it on my development machine by invoking:
java -jar -Xss32M -Xmx8G -XX:+UseG1GC -XX:+UseStringDeduplication ClearWS-0.1.0.jar
it works like a charm. If I point my browser to http://localhost:8888/process?content=This%20is%20a%20test., I get the expected JSON:
{ "id": 1,
"sentences": [
{ "start": 0,
"end": 0,
"content": "This is a test.",
"tokens": [
{ "start": 0, "end": 4, "index": 0, "text": "This", "posTag": "DT", "chunkTag": "NP", "lemma": "this" },
{ "start": 5, "end": 7, "index": 1, "text": "is", "posTag": "VBZ", "chunkTag": "VP", "lemma": "be" },
{ "start": 8, "end": 9, "index": 2, "text": "a", "posTag": "DT", "chunkTag": "NP", "lemma": "a" },
{ "start": 10, "end": 14, "index": 3, "text": "test", "posTag": "NN", "chunkTag": "NP", "lemma": "test" },
{"start": 14, "end": 15, "index": 4, "text": ".", "posTag": ".", "chunkTag": ".", "lemma": "." } ],
"size": 5
} ]
}
Now, I've moved the ClearWS-0.1.0.jar
file to my home server and there I started it with the same command as above: no error messages. Locally (via localhost:8888), everything is still working perfectly. If I try to use it remotely, however, it doesn't work: after some time the browser tells me that my attempt to connect has failed.
That home server machine has a NATed address that doesn't change often, so I can hook it using no-ip.com
and access it anyway. Notice that my other J2EE services deployed to Tomcat container are perfectly reachable and usable remotely. I thought it might be the embedded Tomcat conflicting with the stand-alone one, so I shut the latter down but still I can't reach ClearWS-0.1.0
.
I'm starting to think that Spring understand that I still don't fully trust it, so it fails on me on purpose... Out of the joke, can anybody with a better understanding of Spring and networks help me to sort this problem out? Thanks in advance.
Solution: I simply forgot to forward port 8888... Once added that configuration to my router, I was able to remotely use the service. Now I'd like to be able to deploy it in my existing Tomcat container... any idea?
答案 0 :(得分:0)
如果您确实要将其部署到tomcat容器,则需要创建war文件as specified in the Spring Boot documentation。它主要涉及将maven包装设置为战争。如果你的tomcat容器是6.0或更少,你需要编写一个web.xml,否则你将提供一个 SpringBootServletInitializer 。
就个人而言,我认为这些天在集装箱内运行没有任何好处。 java世界中的运动现在用于嵌入式servlet conatiner,这使得在云中或像docker这样的容器中运行更加容易。