How to launch gwt-project on external server, e.g. tomcat? - java

I deployed my gwt project on localhost with gwt-plugin on eclipse. Everything works fine. But when I try to launch application outside (from tomcat) it doesn't work normally. I put war content into webaaps folder. The client side of gwt works well but there is a problem with connection to server side.
Probable error from logs:
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "GET /BugGitGwt/ HTTP/1.1" 200 2954
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "GET /BugGitGwt/buggitgwt/buggitgwt.nocache.js HTTP/1.1" 200 6004
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "GET /BugGitGwt/loading4.gif HTTP/1.1" 200 2164
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "GET /BugGitGwt/BugGitGwt.css HTTP/1.1" 200 708
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "GET /BugGitGwt/buggitgwt/gwt/clean/clean.css HTTP/1.1" 200 29325
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "GET /BugGitGwt/buggitgwt/0B29E478EEA6D0F7C8617BCA1D490240.cache.html HTTP/1.1" 200 161530
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "POST /BugGitGwt/buggitgwt/greet HTTP/1.1" 500 2820
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "POST /BugGitGwt/buggitgwt/greet HTTP/1.1" 500 2820
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "POST /BugGitGwt/buggitgwt/greet HTTP/1.1" 500 2820
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "GET /BugGitGwt/buggitgwt/gwt/clean/images/hborder.png HTTP/1.1" 200 1995
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "GET /BugGitGwt/buggitgwt/gwt/clean/images/circles.png HTTP/1.1" 200 1492
127.0.0.1 - - [07/Mar/2014:17:31:36 +0400] "GET /BugGitGwt/buggitgwt/gwt/clean/images/vborder.png HTTP/1.1" 200 298
or this:
INFO: The APR based Apache Tomcat Native library which allows optimal performance in
production environments was not found on the
java.library.path: C:\Program Files (x86)\Java\jdk1.6.0_45\bin;
C:\Windows\Sun\Java\bin;
C:\Windows\system32;
C:\Windows;C:\Program Files (x86)\Intel\iCLS Client\;
C:\Program Files\Intel\iCLS Client\;
C:\Program Files (x86)\AMD APP\bin\x86_64;
C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;
C:\Windows;C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;
C:\Program Files (x86)\Java\jdk1.6.0_45\bin;
C:\apache-maven-3.1.1\bin;
C:\Program Files (x86)\MySQL\MySQL Utilities 1.3.6\;
C:\apache-ant-1.9.3\bin;
C:\Program Files (x86)\Java\jdk1.6.0_45\bin;
C:\Program Files (x86)\Git\bin;
C:\Program Files (x86)\Git\cmd;;.
or this:
INFO: JSR 356 WebSocket (Java WebSocket 1.0) support is not available
when running on Java 6. To suppress this message, run Tomcat on Java 7,
remove the WebSocket JARs from $CATALINA_HOME/lib or add
the WebSocketJARs to thetomcat.util.scan.DefaultJarScanner.jarsToSkip property in
$CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7
WebSocket API will be available.
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">
<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>ru.sersem.buggitgwt.server.DataProviderServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/buggitgwt/greet</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>BugGitGwt.html</welcome-file>
</welcome-file-list>
</web-app>
Service:
#RemoteServiceRelativePath("greet")
public interface DataProviderService extends RemoteService {
List<List<String>> getDatabaseData(String call);
}

Step to follow to run GWT project from external server.
Open command window
Navigate to war folder that contains following things:
war
|
|__GWTTestProject.html
|__GWTTestProject.css
|__gwttestproject folder
| |
| |__compiled js files and html files generated by GWT compilation
|
|__WEB-INF folder
|
|__classes
|__deploy
|__lib
|__web.xml
Execute following command using Command prompt to create a war file
jar -cf gwtproject.war *
Copy gwtproject.war under tomcat webapps
start the server
Please check it again in following files:
web.xml:
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>com.gwt.test.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/gwtproject/greet</url-pattern>
</servlet-mapping>
GreetingService:
#RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
Long greetServer(String name) throws IllegalArgumentException;
}

Okay. There was a thing. We use Java 6 in our enterprise but GWT supports Java 7. So it works under java 7 in eclipse but in system environment it was down.

Related

Tomcat rewrite url gives 404 while direct browsing gives 200

I think I have done some searching before posting this. Couldn't find a similar problem. I am using apache-tomcat-9.0.37. I am trying to forward the requests from /contextOld/ to /context-new/.
It is successfully rewriting to new url. But when the tomcat rewrites to the new url, it is giving a 404. When accessed directly via browser gives a 200.
localhost log
30-Sep-2021 14:01:27.250 FINE [http-nio-8080-exec-8] org.apache.catalina.core.ApplicationDispatcher.doForward The Response is vehiculed using a wrapper: org.springframework.security.web.firewall.FirewalledResponse
30-Sep-2021 14:02:58.978 FINE [http-nio-8080-exec-3] org.apache.catalina.valves.rewrite.RewriteValve.invoke Rewrote /contextOld/mainPage.htm as /context-new/mainPage.htm with rule pattern ^/contextOld/(.*)$
30-Sep-2021 14:04:31.042 FINE [http-nio-8080-exec-1] org.apache.catalina.core.ApplicationDispatcher.doForward Disabling the response for further output
30-Sep-2021 14:04:31.042 FINE [http-nio-8080-exec-1] org.apache.catalina.core.ApplicationDispatcher.doForward The Response is vehiculed using a wrapper: org.springframework.security.web.firewall.FirewalledResponse
30-Sep-2021 14:05:52.290 FINE [http-nio-8080-exec-1] org.apache.catalina.valves.rewrite.RewriteValve.invoke Rewrote /contextOld/mainPage.htm as /context-new/mainPage.htm with rule pattern ^/contextOld/(.*)$
30-Sep-2021 14:11:01.225 FINE [http-nio-8080-exec-8] org.apache.catalina.valves.rewrite.RewriteValve.invoke Rewrote /contextOld/mainPage.htm as /context-new/mainPage.htm with rule pattern ^/contextOld/(.*)$
30-Sep-2021 14:11:47.901 FINE [http-nio-8080-exec-6] org.apache.catalina.valves.rewrite.RewriteValve.invoke Rewrote /contextOld/mainPage.htm as /context-new/mainPage.htm with rule pattern ^/contextOld/(.*)$
30-Sep-2021 14:12:23.485 FINE [http-nio-8080-exec-8] org.apache.catalina.valves.rewrite.RewriteValve.invoke Rewrote /contextOld/mainPage.htm as /context-new/mainPage.htm with rule pattern ^/contextOld/(.*)$
30-Sep-2021 14:12:24.752 FINE [http-nio-8080-exec-6] org.apache.catalina.valves.rewrite.RewriteValve.invoke Rewrote /contextOld/mainPage.htm as /context-new/mainPage.htm with rule pattern ^/contextOld/(.*)$
30-Sep-2021 14:41:04.800 FINE [http-nio-8080-exec-2] org.apache.catalina.valves.rewrite.RewriteValve.invoke Rewrote /contextOld/mainPage.htm as /context-new/mainPage.htm with rule pattern ^/contextOld/(.*)$
The second request in the below accesss log is when accessing the url directly via a browser
localhost_access.log
0:0:0:0:0:0:0:1 - - [30/Sep/2021:14:41:04 +0000] "GET /context-new/mainPage.htm HTTP/1.1" 404 653 [2]
0:0:0:0:0:0:0:1 - - [30/Sep/2021:14:41:57 +0000] "GET /context-new/mainPage.htm HTTP/1.1" 200 9401 [69]
rewrite.config
RewriteCond %{REQUEST_URI} ^/contextOld/.*$
RewriteRule ^/contextOld/(.*)$ /context-new/$1 [L]
server.xml
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b [%D]" />
<Valve className="org.apache.catalina.valves.ErrorReportValve" errorCode.400="/webapps/Error/error.html" showServerInfo="false"/>
</Host>
I can provide any other relevant tomcat configuration if I have missed any here.
If /contextOld does not correspond to any application (you don't have neither a ROOT application nor a /contextOld application), you might have stumbled upon bug 64593.
This was corrected in Tomcat 9.0.38, so you just have to upgrade to the newest version.

Error while redeploying WAR in Jenkins,how to solve?

i am running two tomcat server simultaneously on port 8090 & 8081.
8090 connected with Jenkins-staging job
& 8081 connected with Jenkins-production job
8090 running perfectly. but 8081 has the following error :
Started by user admin
Building in workspace C:\Program Files (x86)\Jenkins\workspace\deploy-to-prod
Copied 1 artifact from "maven3-project" build number 69
Deploying C:\Program Files (x86)\Jenkins\workspace\deploy-to-prod\webapp\target\webapp.war to container Tomcat 8.x Remote with context
Redeploying [C:\Program Files (x86)\Jenkins\workspace\deploy-to-prod\webapp\target\webapp.war]
Undeploying [C:\Program Files (x86)\Jenkins\workspace\deploy-to-prod\webapp\target\webapp.war]
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to undeploy [C:\Program Files (x86)\Jenkins\workspace\deploy-to-prod\webapp\target\webapp.war]
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:139)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:177)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
at hudson.FilePath.act(FilePath.java:1078)
at hudson.FilePath.act(FilePath.java:1061)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
at hudson.model.Build$BuildExecution.post2(Build.java:186)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
at hudson.model.Run.execute(Run.java:1835)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The Tomcat Manager responded "FAIL - Unable to delete [C:\Program Files\APACHE\apache-tomcat-8.5.37-production\webapps\webapp.war]. The continued presence of this file may cause problems.
" instead of the expected "OK" message
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:715)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:501)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.undeploy(TomcatManager.java:441)
at org.codehaus.cargo.container.tomcat.Tomcat7xRemoteDeployer.performUndeploy(Tomcat7xRemoteDeployer.java:61)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:129)
... 18 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The Tomcat Manager responded "FAIL - Unable to delete [C:\Program Files\APACHE\apache-tomcat-8.5.37-production\webapps\webapp.war]. The continued presence of this file may cause problems.
" instead of the expected "OK" message
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:715)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:501)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.undeploy(TomcatManager.java:441)
at org.codehaus.cargo.container.tomcat.Tomcat7xRemoteDeployer.performUndeploy(Tomcat7xRemoteDeployer.java:61)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:129)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:177)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
at hudson.FilePath.act(FilePath.java:1078)
at hudson.FilePath.act(FilePath.java:1061)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
at hudson.model.Build$BuildExecution.post2(Build.java:186)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
at hudson.model.Run.execute(Run.java:1835)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Build step 'Deploy war/ear to a container' marked build as failure
Finished: FAILURE
# i have already changed server.xml file:
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8444" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8084" protocol="AJP/1.3" redirectPort="8444" />
`

I have a port issue in tomcat7 server Running war on http://localhost:8080/ but actual port is 8090 using maven project

I have a port issue in tomcat7 server Running war on http://localhost:8080/ but actual port is 8090.
I am a beginner in Maven.
I have attached the error image Port Error
Creating Tomcat server configuration at D:\Selva Kumar G\eclipse_workspace\DigGovi\runner\target\tomcat
[INFO] setting SystemProperties:
[INFO] solr.solr.home=D:\Selva Kumar G\eclipse_workspace\DigGovi/alf_data_dev/solr4/config
[INFO] create webapp with contextPath:
[INFO] Deploying dependency wars
[INFO] Deploy warfile: D:\Selva Kumar G\eclipse_workspace\DigGovi\repo\target\repo-1.0-SNAPSHOT.war to contextPath: /alfresco
[INFO] Deploy warfile: D:\Selva Kumar G\eclipse_workspace\DigGovi\share\target\share-1.0-SNAPSHOT.war to contextPath: /share
[INFO] Deploy warfile: C:\Users\B5451\.m2\repository\org\alfresco\alfresco-solr4\5.1.e\alfresco-solr4-5.1.e.war to contextPath: /solr4
[INFO] Deploy warfile: C:\Users\B5451\.m2\repository\org\alfresco\api-explorer\1.0\api-explorer-1.0.war to contextPath: /api-explorer
SETTINGS.XML
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
</settings>
To see the port numbers, just double click on the server in your eclipse IDE, and you will get a window of server. Click here to see the sample of server window.
In this HTTP/1.1 is the port you are using on your Url with localhost.
If you are not using eclipse IDE, then open your apache tomcat server folder in your local disk. Go to conf folder. Inside conf you will find a file called server. In that XML file You can see a portion like this. This is your port number.

Grails 3.0.4 deploying localhost but not remotely

Someone help please...I am able to run:
grails run-app
and access my application on localhost:8080. However, I have no luck deploying to Tomcat 7.052 on Ubuntu 14.04.1LTS. The war file uploads successfully using the Tomcat Web Manager but I get HTTP error 404 upon accessing via the browser. I am clicking on the application link on the Tomcat Web Manager to access the applications. I tried deploying the sample.war file from Tomcat examples and it works.
Here is what I have tried:
1) I changed my build.gradle file from:
...
compile "org.springframework.boot:spring-boot-starter-tomcat"
...
to:
...
provided "org.springframework.boot:spring-boot-starter-tomcat"
...
2) I ran:
grails war
to generate a war file in which I then uploaded successfully using Tomcat Web Manager.
3) I also tried restarting the tomcat service.
Here is my grails-app/conf/application.yml file:
---
grails:
profile: web
codegen:
defaultPackage: myApp
info:
app:
name: '#info.app.name#'
version: '#info.app.version#'
grailsVersion: '#info.app.grailsVersion#'
spring:
groovy:
template:
check-template-location: false
---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
pdf: application/pdf
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlets: html
taglib: none
staticparts: none
---
hibernate:
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password:
environments:
development:
dataSource:
dbCreate: create-drop
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: update
url: jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
After digging into the log files (catalina.out) embedded below, I found out that Tomcat was using Java 7 whilst my grails application had used Java 8. Here is what I did:
1) I installed Java 8 on my server and set Tomcat to use it. This has significantly slowed down my Tomcat though.
2) I then configured my dataSource in grails-app/conf/application.yml to include the correct configurations for MySQL database. These configuration are in Grails 3.x documentation under dataSource.
3) Lastly, I included
runtime 'mysql:mysql-connector-java:5.1.29'
in my gradle.build dependencies.
Sep 09, 2015 2:47:32 AM org.apache.catalina.util.Introspection loadClass
FINE: Failed to load class [{0}]
java.lang.UnsupportedClassVersionError: myApp/ApplicationLoader : Unsupported major.minor version 52.0 (unable to load class myApp.ApplicationLoader)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2948)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1208)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
at org.apache.catalina.util.Introspection.loadClass(Introspection.java:143)
at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2117)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2056)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2030)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2023)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1288)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:873)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:371)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Jetty responds with unnecessary redirect

I use jetty-maven-plugin to run my web application:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.12.v20130726</version>
<configuration>
<webApp>
<contextPath>/test</contextPath>
</webApp>
</configuration>
</plugin>
Next, I use nginx to proxify requests:
server {
server_name q.ru;
listen 80;
location / {
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:8080/test;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Now, I open my browser, and send request to http://q.ru (localhost in my /etc/hosts).
I get infinite redirection.
Here is HTTP dialog dump- request from nginx to jetty, and jetty response:
GET /test HTTP/1.1
Host: 127.0.0.1:8080
Connection: close
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
HTTP/1.1 302 Found
Location: http://127.0.0.1:8080/test/
Connection: close
Server: Jetty(8.1.12.v20130726)
Host and path are exactly specified in request. So why does jetty send 302 redirect ?
I'm pretty sure this stackoverflow question might help you, I've been searching for similar thing.
Hope that helps.
Cheers

Categories

Resources