0

ZKspringboot deploy to tomcat - no working examples

asked 2022-11-10 01:23:31 +0800

chrisj124 gravatar image chrisj124
1

Hi I am trying to use ZKSpringboot starter - actually using the zkspringboot-minimal-war example. I have it setup in Eclipse - when I run it as Spring boot run everything works and startup loads the ZK Servlets. But when I try to run the project on Tomcat, I can see Spring start, but none of the ZK servlets start - nothing works.

Does anyone have a working ZK Spring demo that can run as a war on tomcat? Or any ideas why the startup on tomcat is not working - when I have everything in place that the zkspringboot-minimal-war example has.

when starting up as run Spring boot I see: Root WebApplicationContext: initialization completed in 616 ms ZK-Springboot: ServletRegistrationBean for DHtmlLayoutServlet with url pattern [*.zul, *.zhtml] ZK-Springboot: ServletRegistrationBean for DHtmlUpdateServlet with path /zkau Starting ZK 9.6.0 CE (build: 2021081016)

when starting under tomcat I only see: INFO: Initializing Spring embedded WebApplicationContext

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-11-10 07:42:31 +0800

chrisj124 gravatar image chrisj124
1

I think it was mostly issues in my project after working on it for a while. I'll post some thoughts so if anyone else runs into similar, they might find something helpful.

1) I ran into issues with the POM following what is in GitHub (zkspringboot-minimal-war). Errors similar to (Could not initialize class org.apache.maven.plugin.war.util.WebappStructureSerializer) For me the only way to solve these issues were by adding the following in the build - plugins section of the pom (after the org.springframework.boot plugin):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>3.3.1</version>
</plugin>

2) My spring starter had already created a seperate Servlet Initializer class in the same package as my SpringBootApplication class. If you look at the zkspringboot-minimal-war it has the SpringBootApplication class extend SpringBootServletInitializer and adds in

@Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(DctmApplication.class);
    }

So you need to get rid of the extra Initializer class if your spring starter created that.

3) I had to ignore the different startup messages displayed in Spring startup when using spring-boot: run - versus deployed on Tomcat. When deployed on Tomcat I don't see messages about ZK Servlet initializing. However it still is working

4) Difference in running on Tomcat container in Eclipse - versus packaged war deployed on Tomcat. When referencing the path in browser:

  • Tomcat on Eclipse the spring project doesn't answer on the name of your project like some web apps will. It answers on the artifact name you have configured in pom. You can double check once you deploy by looking in your project's .settings folder for a file called org.eclipse.wst.common.component

you'll see something like

<property name="context-root" value="rps-controller"/>
  • When deployed on tomcat as a war, it will of course follow the name of your war file in the path.

Chris

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2022-11-10 01:23:31 +0800

Seen: 9 times

Last updated: Nov 10 '22

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More