sitemesh / sitemesh2

SiteMesh 2: Official repository
http://sitemesh.github.io/sitemesh2/
Other
134 stars 83 forks source link

Jakarta version for SiteMesh 2 #42

Closed rainboyan closed 4 months ago

rainboyan commented 9 months ago

Hi @codeconsole, do you have any plans to support Jakarta EE 9? I can help, and release a Jakarta version for SiteMesh 2. Grace framework 2023 will support SiteMesh 2.x and 3.x.

codeconsole commented 9 months ago

@rainboyan, First you would have to demonstrate it working with 2.5.0. Have you already done that?

rainboyan commented 9 months ago

Not yet, Grace 2023.0.x was released with 2.4.2. But Grace 2022.6.x and 2023.1.x will upgrade to 2.5.0. So the first thing I think is to release a Jakarta version of 2.4.2, then will be 2.5.0.

codeconsole commented 9 months ago

Unfortunately the versioning wouldn't really make sense because a Jakarta version of 2.4.2 would be breaking for 2.4.x. I would be open to doing a Jakarta version of 2.5.x as 2.6.x, but I don't want to invest any time with 2.4.x unless it is a maintenance release.

I can provide support with integrating Grace with SiteMesh 3

rainboyan commented 9 months ago

@codeconsole thank you for your reply.

Unfortunately the versioning wouldn't really make sense because a Jakarta version of 2.4.2 would be breaking for 2.4.x.

Maybe I'm not clear enough, a Jakarta version is just a new branch released with different artifcatId, and would not be breaking for 2.4.x. I know Sitemesh 2.5.0 has already been released, but Grails 6 is still using 2.4.4. In Grails 2023.0.x, I have already migrated Sitemesh 2.4.4 to support Jakarta namespace, so I can make a PR for this version.

<dependency>
    <groupId>opensymphony</groupId>
    <artifactId>sitemesh-jakarta</artifactId>
    <version>2.4.4</version>
</dependency>

I can provide support with integrating Grace with SiteMesh 3

In Grails 6, Grails introduced a new Sitemesh 3 plugin to support Sitemesh 3, but I think there's a better way to support SiteMesh3, and Grace will provide a GrailsLayoutFinder interface that can be easily extended. Grace can use SiteMesh 3's AutoConfiguration support for Spring Boot directly and does not require a separate plugin.

codeconsole commented 9 months ago

@rainboyan I would prefer not to. If we do another release of SiteMesh 2, it needs to be based off of 2.5.x

I am willing to release a Jakarta version built off of 2.5.x. Otherwise, I am more than happy to provide you any support you need to getting SiteMesh 3 working.

rainboyan commented 9 months ago

@codeconsole Well, before you release the 2.5/2.6 jakarta version, I'll release a 2.4 jakarta version for Grace internal use, and I will release Grace 2023.0.0 after that.

codeconsole commented 9 months ago

@rainboyan why not skip all of 2.x and go straight to SiteMesh 3.2.0?

rainboyan commented 9 months ago

Grace 2023.0.x branch support Spring Boot 3.0.x has entered maintenance mode, and I don't plan to change it. Next, I will start the development of Grace 2023.1.x and will upgrade to SiteMesh 3.2.

codeconsole commented 9 months ago

@rainboyan if you want to submit a pull request based off of the 2.4.x, I am willing to merge it into a separate branch 2.4.x-jakarta and release it to the central repository.

We can release it via a classifier

<dependency>
    <groupId>opensymphony</groupId>
    <artifactId>sitemesh</artifactId>
    <version>2.4.4</version>
    <classifier>jakarta</classifier>
</dependency>

https://github.com/sitemesh/sitemesh2/tree/2.4.x

It would be accessible via api "opensymphony:sitemesh:2.4.4:jakarta"

ClancyDamon commented 9 months ago

Is there any potential ETA for Jakarta EE 9 support for 2.5.x? I'm working on upgrading my application for Tomcat 10 due to upcoming changes with my host provider, and support is necessary for me. Even a branch that would need to be self compiled/installed would be good.

codeconsole commented 9 months ago

@ClancyDamon sure, we can get something out within the next week.

ClancyDamon commented 9 months ago

That's fantastic, thank you!

codeconsole commented 9 months ago

@ClancyDamon You can use the following snapshot repo: https://s01.oss.sonatype.org/content/repositories/snapshots

2.6.0-SNAPSHOT has been deployed here https://s01.oss.sonatype.org/content/repositories/snapshots/opensymphony/sitemesh/

rainboyan commented 9 months ago

@codeconsole I don't understand the branches to support Jakarta, I think you should use a different branch, instead of the 'master'. We should support Java EE 8 and Jakarta EE 9 at the same version, use a different classifier 'jakatar' as you said.

codeconsole commented 9 months ago

master is 2.6.x, which will be Jakarta only based off of 2.5.x

for the 2.4.x jakarta would be run off of 2.4.x-jakarta, but after looking at the gradle docs, I am not 100% sure it is possible to release only a classifier to maven central based on a completely different source set.

rainboyan commented 9 months ago

@codeconsole I think Gradle supports this feature, can you create a new branch named '2.4.x-jakarta', I will try it.

ClancyDamon commented 9 months ago

There's a problem with the current 2.6.0 master branch code. Looks like you just flipped "javax" to "jakarta" in the pom.xml. That's not the dependency you're looking for.

<dependencies>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
</dependencies>

should instead be

<dependencies>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <version>6.1.0-M1</version>
            <scope>provided</scope>
        </dependency>
</dependencies>

I changed that, and it compiled/installed for me with a simple "mvn install" command.

rainboyan commented 9 months ago

@codeconsole Is 2.5.0 the last version to support Java EE 8? If 2.6.0 version is just a version that migrated to Jakarta namespace without any new features, I think it's better to use 2.5.0-jakarta to release the version that support Jakarta EE 9.

I was going to use 2.4.4-jakarta for Grace 2023.0, but I don't need it anymore. Because Grace 2023.0.0-M1 has been released, it uses a simplified version that supports Jakarta EE 9.

I've been spending a lot of time on Grace releases lately, and a lot of plugins need to be released to Maven Central again. I hope that Grace 2023.0.0 will be released as soon as possible.

codeconsole commented 9 months ago

@rainboyan yes, 2.6.0 and after will be jakarta only

codeconsole commented 9 months ago

@ClancyDamon maven is no longer used to build. If you would like to build, use gradlew instead.

I deleted pom.xml to remove the confusion https://github.com/sitemesh/sitemesh2/commits/master/

codeconsole commented 9 months ago

2.6.0 can be used by using the snapshot repository

repositories {
    maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
    mavenCentral()
}

dependencies {
    implementation 'opensymphony:sitemesh:2.6.0-SNAPSHOT'
}

The jar is here

rainboyan commented 8 months ago

@codeconsole I just created a Grace app to integrate SiteMesh 3.1 with Grace 2022.1.0, in development mode it works well, but when it is packaged in WAR and executed through java command it will not work properly.

Can you help me to get it working?

Do I configure the decorator location wrong in the application.yml?

I have tried to copy the decorators from app/views/layouts to src/web app/layouts, but it doesn't work either.

https://github.com/grace-guides/gs-sitemesh3-layout

codeconsole commented 8 months ago

@rainboyan sure, I can help with that. Might take me a couple days to get to it

codeconsole commented 8 months ago

@rainboyan I was able to replicate the issue, but I have yet to come up with a fix. I do know that executable jars work. Are you creating an executable war or a plain war?

rainboyan commented 8 months ago

@codeconsole

I create an executable war throght Gradle assemble task as below.

$ ./gradlew assemble -Dgrails.env=dev
$ cd build/libs
$ java -jar gs-sitemesh3-layout-0.0.1-SNAPSHOT.war

However, I packaged it into a jar and ran it with the same error.

2024-02-13 14:04:05.892  INFO --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring GroovyPagesServlet 'groovyPagesServlet'
2024-02-13 14:04:05.892  INFO --- [nio-8080-exec-1] org.grails.web.pages.GroovyPagesServlet  : Initializing Servlet 'groovyPagesServlet'
2024-02-13 14:04:05.892  INFO --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : GSP servlet initialized
2024-02-13 14:04:05.916  INFO --- [nio-8080-exec-1] org.grails.web.pages.GroovyPagesServlet  : Completed initialization in 24 ms
2024-02-13 14:04:05.918  INFO --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : GroovyPagesServlet:  "/layouts/sitemesh.gsp" not found
2024-02-13 14:04:05.919 ERROR --- [nio-8080-exec-1] org.sitemesh.webapp.WebAppContext        : Error 404 processing decorator '/layouts/sitemesh.gsp'
2024-02-13 14:04:05.924 ERROR --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception

java.lang.IllegalStateException: Cannot forward after response has been committed
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:302)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:294)
    at org.sitemesh.webapp.WebAppContext.dispatch(WebAppContext.java:205)
    at org.sitemesh.webapp.WebAppContext.decorate(WebAppContext.java:176)
    at org.sitemesh.BaseSiteMeshContext.decorate(BaseSiteMeshContext.java:55)
    at org.sitemesh.webapp.SiteMeshFilter.postProcess(SiteMeshFilter.java:100)
    at org.sitemesh.webapp.contentfilter.ContentBufferingFilter.bufferAndPostProcess(ContentBufferingFilter.java:191)
    at org.sitemesh.webapp.contentfilter.ContentBufferingFilter.doFilter(ContentBufferingFilter.java:142)
    at org.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:144)
    at org.sitemesh.config.ConfigurableSiteMeshFilter.doFilter(ConfigurableSiteMeshFilter.java:195)
codeconsole commented 8 months ago

@rainboyan seems like it is being caused by a dependency resolution issue. I think one of my changes excluding grails-web-sitemesh from controller plugin got rolled back and is causing the issue by resolving both sitemesh 2 and 3.
yeah, I forgot about this.

You need to make sure all instances of 'org.grails.plugins:sitemesh2' and 'org.grails:grails-web-sitemesh' are excluded.

You can see a working demo here and how it was modified to use SiteMesh 3 https://github.com/codeconsole/grails-sitemesh3-demo/commit/f6dede8f4c1e885801286f43586377fbe1ee0396

rainboyan commented 8 months ago

@codeconsole OK, I'll check your demo project, Where is the source of grails-plugin-sitemesh3?

codeconsole commented 8 months ago

https://github.com/codeconsole/grails-sitemesh3

rainboyan commented 8 months ago

Thanks you very much @codeconsole

codeconsole commented 8 months ago

@rainboyan were you able to figure out the problem?

rainboyan commented 8 months ago

@codeconsole Yeah,it works now.but I think it's not the best way to do. SiteMesh 2 and 3 could not be used in the same time. And the layouts should not be accessible to the public. I hope SiteMesh 3 will support more API to allow users to customise.

codeconsole commented 8 months ago

@rainboyan why would you want to use both SiteMesh 2 and SiteMesh 3 at the same time?

rainboyan commented 8 months ago

@codeconsole Currently, Grace still use SiteMesh 2 as default decorator engine, supports for SiteMesh 3 is still in development, SiteMesh 3 is one of the viable options. As a framework, I think it's worth trying to explore all the possibilities. I have fixed the issue, now SiteMesh 2 and 3 could be used in the same time.

You can check: http://localhost:8080/demo/show, it still use SiteMesh 2 decorator.

https://github.com/grace-guides/gs-sitemesh3-layout

codeconsole commented 8 months ago

@rainboyan did you figure out what was causing the 404s when you were trying to run the war? if so, how did you fix it?

rainboyan commented 8 months ago

@codeconsole I copy GrailsLayoutHandlerMapping from your project grails-sitemesh3, GrailsLayoutHandlerMapping will make url /layouts/* be accessible, and I also removed suffix .gsp of the decorators.

rainboyan commented 7 months ago

The Jakarta version for SiteMesh 2.4.2 is here https://github.com/graceframework/sitemesh-jakarta.

This is only a temporary solution and is currently only being tested in Grace, may be upgraded to SiteMesh 2.6.x in Grace 2023.1.x if 2.6.x is migrated to Jakarta.

@codeconsole Thanks for your help.

stephencarvalho commented 6 months ago

Hi @codeconsole can this 2.6.0-SNAPSHOT be officially released as a maven package, so that it can be found here: https://mvnrepository.com/artifact/opensymphony/sitemesh

Because my company has a project that we are upgrading to spring 3 but due to security policies we cannot download artifacts apart from maven official releases.

codeconsole commented 6 months ago

Hi @stephencarvalho yes, I can do that. Can you confirm you have thoroughly tested 2.6.0-SNAPSHOT with your project and you have no issues?

Also, have you tried SiteMesh 3? It integrates with Spring Boot 3 and offers a starter.

stephencarvalho commented 6 months ago

Yes @codeconsole I tested it by importing it locally, we also tried sitemesh 3 but we are unable to figure out how to configure sitemesh 3 to replace sitemesh 2. Additionally what would be the ETA for it to be released to maven?

Thanks!

codeconsole commented 6 months ago

Should be really simple to replace 2 with 3. Have you looked at the examples? https://github.com/sitemesh/sitemesh3/tree/master/examples

I could probably get around to a release in the next week or so. I am a bit busy until the 7th.

stephencarvalho commented 6 months ago

A week or so should work, thank you!

stephencarvalho commented 5 months ago

@codeconsole any update on the maven release?

codeconsole commented 5 months ago

@stephencarvalho still working on it. I decided on some changes. I will be releasing it under 2.7.x. What Java / Jakarta versions will you be using?

@rainboyan I decided I will push out a 2.6.x branch using Jakarta based on 2.4.x code since 2.6.x hasn't been released yet. Not sure if that is any help to you at this point considering you already using your own fork.

rainboyan commented 5 months ago

@codeconsole I think it's still a good time to do it, Grace 2023.0.0-M6 has just been released, and we can consider switching to SiteMesh 2.6.0 in M7. After that, Grace 2023.1.0 can be upgraded to SiteMesh 2.7.0.

stephencarvalho commented 5 months ago

@codeconsole thanks for the update! I’ll be using Java 17 and these version of jakarta depending on what jakarta package you are asking about: IMG_7373

rainboyan commented 5 months ago

@codeconsole Is there a definite release date?

codeconsole commented 5 months ago

@rainboyan I am hoping to get to this in the next few days...

codeconsole commented 5 months ago

Snapshots are not automatically generated.

repositories {
    maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
    mavenCentral()
}

@rainboyan please try 2.6.0-SNAPSHOT which is a jdk 17 version of 2.4.x

dependencies {
    implementation 'opensymphony:sitemesh:2.6.0-SNAPSHOT'
}

@stephencarvalho please try 2.7.0-SNAPSHOT which is a jdk 17 version of 2.5.x

dependencies {
    implementation 'opensymphony:sitemesh:2.7.0-SNAPSHOT'
}
stephencarvalho commented 5 months ago

2.7.0 snapshots is working fine for me. I think it can be officially released

rainboyan commented 5 months ago

@codeconsole Thanks for your help, it works for Grace 2023.0.x now.

This is the PR for Grace 2023.0.x, I will add some more tests here,

https://github.com/graceframework/grace-framework/pull/301