Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy WAR to Apache Tomcat: Content Encoding Error #20

Closed
asmbit opened this issue Feb 16, 2023 · 14 comments
Closed

Deploy WAR to Apache Tomcat: Content Encoding Error #20

asmbit opened this issue Feb 16, 2023 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@asmbit
Copy link

asmbit commented Feb 16, 2023

I'm not able to run the grailszk-example within a Tomcat Application Container as described in https://docs.grails.org/4.0.0/guide/deployment.html#deploymentContainer.

@maiconandsilva
Copy link
Member

maiconandsilva commented Feb 17, 2023

Do you have any Stacktrace log to show?

Any chance it might be related to this issue? (grails/grails-core#12829)

@asmbit
Copy link
Author

asmbit commented Feb 20, 2023

"java -jar grailszk-example-0.1.war" works fine. But when i copy the same war to a Tomcat container (9.0.71) i get attached screen. Sorry. No Stracktrace log (see attached logs).

  • Grails 4.0.13
  • JDK 1.8.0_352
  • clean Tomcat 9.0.71 or Tomcat 8.5 installation

2023-02-20 14_31_42-Seiten-Ladefehler – Mozilla Firefox
logs.zip

@maiconandsilva
Copy link
Member

Ok. I'll take a look at it.

@maiconandsilva maiconandsilva self-assigned this Feb 24, 2023
@maiconandsilva maiconandsilva added the bug Something isn't working label Feb 24, 2023
@asmbit
Copy link
Author

asmbit commented Mar 7, 2023

Hi Maicon, can i support you in some manner to resolve the issue. Thanks, Andreas

@maiconandsilva
Copy link
Member

maiconandsilva commented Mar 8, 2023

Hi, Andreas. Sorry it's taking too much time but I've been busy as of late. I'll solve this pressing issue as soon as I can. Although I can't give any particular date.

Also, you can try to solve this issue and make a pull request. Let me know if you are interested.

In the meantime, is it possible for you to deploy your app using the embedded tomcat? (java -jar myapp.jar)

@asmbit
Copy link
Author

asmbit commented Mar 8, 2023

Hi Maicon, there is no pressure on time. I can wait. Till now i have no experience in grails plugin development, but if i find time i will give a try. Thanks for your feedback.

@maiconandsilva
Copy link
Member

maiconandsilva commented Mar 20, 2023

@asmbit, can you test your app with the lastest version?

@asmbit
Copy link
Author

asmbit commented Mar 20, 2023

Hi @maiconandsilva, grailszk-example now works. But my application has same problem as before. I will investigate more and let you know. Thanks a lot!

@maiconandsilva
Copy link
Member

maiconandsilva commented Mar 20, 2023

@asmbit

Have you changed the version in your application?
How do you call the zul view in your application?

You can create an example in which I can reproduce this error to fix it.

@asmbit
Copy link
Author

asmbit commented Mar 21, 2023

@maiconandsilva

Yes, i changed version to 3.2.3.
I call the zul view by a controller invoking "forward". See example below:

package file.upload
class Test2Controller {
	def index() {
		forward uri: '/index.zul'
	}
}

With "bootRun" everything works fine. When deploying the war in Tomcat, i get the error as described before.

Have a nice day and thanks a lot!

@asmbit
Copy link
Author

asmbit commented Mar 22, 2023

Hi @maiconandsilva, i found a better solution instead of forward:

package file.upload
class Test2Controller {
	
	def index() {
		response.outputStream << z.wrapper(url: '/index.zul')
	}
}

For me the issue is solved. Thank you for your great readiness.

@maiconandsilva
Copy link
Member

Oh, Thank you. I'm going to check out the issue with using forward

@maiconandsilva maiconandsilva changed the title Deploy WAR to Apache Tomcat Deploy WAR to Apache Tomcat: Content Encoding Error Mar 22, 2023
@maiconandsilva
Copy link
Member

maiconandsilva commented Mar 28, 2023

The problem is that ZK's web-fragment.xml is being loaded with the deployed war, meaning ZK's configured DHtmlLayoutServlet is being run last. The problem is that by default compress is set to true which returns a gzipped response causing encoding error. For now, there are the known workarounds below:

Adding the following solves the issue if your ZK version is 8.6.0 or later:

configurations.all {
    exclude group: "org.zkoss.zk", module: "zkwebfragment"
}

For prior versions:

  • Create a file named web.xml in the WEB-INF directory of your project if it does not already exist.
  • Add the metadata-complete="true" attribute to the element in the web.xml file.
<?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="true">

</web-app>

See updated grailszk-example.

PS: There are other methods to prevent the web-fragment.xml from being loaded.

@asmbit
Copy link
Author

asmbit commented Mar 29, 2023

Great job! Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants