template-definitions not found after deployment

217 views
Skip to first unread message

Michael Haufe

unread,
Apr 19, 2021, 10:38:12 AM4/19/21
to Magnolia User Mailing List
On localhost my vanilla light module works fine but when deployed there is a 404 error.

The end point effected is:

/magnoliaAuthor/.rest/template-definitions/v1/mpa-lm:pages/Basic

The yaml files have been deployed and appear in the Resource Files app.

I also enabled anonymous access to the "/.rest/*" endpoint

There are no errors being thrown in the server logs.

This is the light-module being used:


Strangely I am able to define a new page with the expected templates appearing in the dialog drop-down, but once the WYSIWYG appears I am confronted with the 404 in the console as seen above.

Any suggestions towards identifying the underlying cause would be appreciated

Christopher Zimmermann

unread,
Apr 20, 2021, 2:42:14 AM4/20/21
to Magnolia User Mailing List
Hi, 
I don't quite understand the setup but...
Assuming the issue is with accessing the template-definitions endpoint...

Does "Network" tab in the dev tools in the browser? 
You say it works on your localhost - what is the full path to the template-definitions that works?

Then on your deployment instance, what is the full path to the template-definitions that does not work?
What if you take this path and enter it directly into the browser URL bar?
(I'm just wondering if there could be some CORS issues - though, then I would have expected a 500 instead of a 404)

--
You received this message because you are subscribed to the Google Groups "Magnolia User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to user-list+...@magnolia-cms.com.
To view this discussion on the web, visit https://groups.google.com/a/magnolia-cms.com/d/msgid/user-list/ad7b0bc7-36b8-4d71-bdfa-0f90935b2c17n%40magnolia-cms.com.


--
Best regards,

Christopher Zimmermann Product Manager 
christopher...@magnolia-cms.com 

Skype: czimmermann_magnolia

Magnolia 
Oslo-Strasse 2, 4142 Münchenstein (Basel), Switzerland
Office: +41 61 228 90 00 www.magnolia-cms.com
 
 

Bartosz Staryga

unread,
Apr 20, 2021, 3:00:53 AM4/20/21
to Magnolia User Mailing List
Hey Michael,

I might have an idea what is wrong :)

The repo you are using assumes that you spun up Magnolia with help of Magnolia CLI.
Magnolia CLI creates 2 instances on local machine:
React from the repo uses hardcoded url to author instance in 3 places:

I am gonna take a guess that your remote server, the one you deploy a light module to, does not have an instance in `my-server.com/magnoliaAuthor` but under root so sth like `my-server.com`.
If this is the case, you need to adapt the React app in 3 places I listed earlier and rebuild it.

If this is not the case, then my question is how do you build your remote instance of Magnolia?
I saw a few days ago that `template-definitions` endpoint was not added when instance was prepared with Maven.

Cheers,
Bartosz



--
You received this message because you are subscribed to the Google Groups "Magnolia User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to user-list+...@magnolia-cms.com.
To view this discussion on the web, visit https://groups.google.com/a/magnolia-cms.com/d/msgid/user-list/ad7b0bc7-36b8-4d71-bdfa-0f90935b2c17n%40magnolia-cms.com.


--
Best regards,

Bartosz Staryga
Front-End Solution Architect, Headless Expert
bartosz...@magnolia-cms.com 

Magnolia 
Oslo-Strasse 2, 4142 Münchenstein (Basel), Switzerland
 
 

Michael Haufe

unread,
Apr 20, 2021, 9:48:42 AM4/20/21
to Magnolia User Mailing List, christopher...@magnolia-cms.com
On Tuesday, April 20, 2021 at 1:42:14 AM UTC-5 christopher...@magnolia-cms.com wrote:
Hi, 
I don't quite understand the setup but...
Assuming the issue is with accessing the template-definitions endpoint...

Does "Network" tab in the dev tools in the browser? 
You say it works on your localhost - what is the full path to the template-definitions that works?

Then on your deployment instance, what is the full path to the template-definitions that does not work?
What if you take this path and enter it directly into the browser URL bar?
(I'm just wondering if there could be some CORS issues - though, then I would have expected a 500 instead of a 404)

 The project was created with:

```bash
mvn org.sonatype.plugins:nexus-m2settings-maven-plugin:1.6.5:download -DnexusUrl=https://nexus.magnolia-cms.com -DtemplateId=magnolia-enterprise
mvn archetype:generate -Dfilter=info.magnolia.maven.archetypes:magnolia
```

The `magnolia-project-archetype` was chosen

The version chosen when prompted was 1.3

The top level pom.xml file was updated to use DX Core

The second level pom.xml was updated to use magnolia-dx-core-webapp option

The server does not have a public instance as this is for evaluation purposes only therefore the following configuration was set to prevent issues with publishing and creating users:

modules/publishing-core/config/receivers/magnoliaPublic8080/enabled = false

CORS was configured:

The `addCORSHeaders` file from the hello-headless project[1] was imported and moved directly after the uriSecurity node

The url of a page being edited in the WYSIWYG is:

http://<domain>/magnoliaAuthor/.magnolia/admincentral#app:pages-app:detail;/mpa-home:edit

The 404 url in the browser console is:

<http://<domain>/magnoliaAuthor/.rest/template-definitions/v1/mpa-lm:pages/Home>

The response body is:

{"error":{"code":"notFound","message":"Could not find resource for full path: http://<domain>/magnoliaAuthor/.rest/template-definitions/v1/mpa-lm:pages/Home"}}

The index.js file in the client has the following defined:

```
const nodeName = 'mpa-home';
const config = {
  componentMappings: {
    'mpa-lm:pages/Home': Home,
    'mpa-lm:pages/Basic': Basic,
    'mpa-lm:components/Text': Text,
    'mpa-lm:components/List': List,
    'mpa-lm:components/Item': Item,
  },
};
```

I was suspicious that the relevant default module was missing but apparently not as the following does exist:

<http://<domain>/magnoliaAuthor/.magnolia/admincentral#app:resources:view;/spa-rendering/restEndpoints/templateDefinitions/templateDefinitionEndpoint.yaml:edit>

The resource file exists on the server

<http://<domain>/magnoliaAuthor/.magnolia/admincentral#app:resources:edit;/mpa-lm/templates/pages/Basic.yaml:edit>

```
title: mpa Basic
templateScript: /mpa-lm/webresources/build/index.html
renderType: spa
class: info.magnolia.rendering.spa.renderer.SpaRenderableDefinition
areas:
  main:
    title: Main area
    availableComponents:
      text:
        id: mpa-lm:components/Text
```

Michael Haufe

unread,
Apr 20, 2021, 10:03:36 AM4/20/21
to Magnolia User Mailing List, bartosz...@magnolia-cms.com
On Tuesday, April 20, 2021 at 2:00:53 AM UTC-5 bartosz...@magnolia-cms.com wrote:

React from the repo uses hardcoded url to author instance in 3 places:

This was replaced with the `env-cmd` node package and the setting moved to a .env file with the following:

PUBLIC_URL=/magnoliaAuthor/.resources/mpa-lm/webresources/build
REACT_APP_MGNL_STATIC=/.resources/webresources/static
 

This is the confusing part. The pages end point returns a result:

```
@id: "a0cb37a1-2344-4572-8102-7819b7d0fd2a"
@name: "mpa-home"
@nodeType: "mgnl:page"
@nodes: ["main"]
@path: "/mpa-home"
jcrName: "mpa-home"
main: {@name: "main", @path: "/mpa-home/main", @id: "e92716dd-88a1-477f-8bec-681988e9212f", @nodeType: "mgnl:area", @nodes: Array(0)}
mgnl:template: "mpa-lm:pages/Home"
```
But the template definitions end point fails

 
I am gonna take a guess that your remote server, the one you deploy a light module to, does not have an instance in `my-server.com/magnoliaAuthor` but under root so sth like `my-server.com`.
If this is the case, you need to adapt the React app in 3 places I listed earlier and rebuild it.

Yes, the deployed instance is located at <http://10.145.26.215/magnoliaAuthor>
 
If this is not the case, then my question is how do you build your remote instance of Magnolia?
I saw a few days ago that `template-definitions` endpoint was not added when instance was prepared with Maven.

You can see the details of my server setup in my previous response to Christopher. 

Michael Haufe

unread,
Apr 20, 2021, 10:09:30 AM4/20/21
to Magnolia User Mailing List, bartosz...@magnolia-cms.com
On Tuesday, April 20, 2021 at 2:00:53 AM UTC-5 bartosz...@magnolia-cms.com wrote:

I saw a few days ago that `template-definitions` endpoint was not added when instance was prepared with Maven.
 
Since that is what's being done here, is that because of a missing plugin in pom.xml? Is this a larger issue with a support ticket open?


Bartosz Staryga

unread,
Apr 20, 2021, 10:13:25 AM4/20/21
to Magnolia User Mailing List
Hey Michael,

I have asked around and this indeed is a bug that required lib is not brought in.
The missing lib that needs to be added is: resteasy-jaxb-provider

There is already a ticket in place: https://jira.magnolia-cms.com/browse/PAGES-429
In meantime you need to add it yourself.

Cheers,
Bartosz



--
You received this message because you are subscribed to the Google Groups "Magnolia User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to user-list+...@magnolia-cms.com.

Michael Haufe

unread,
Apr 20, 2021, 12:01:29 PM4/20/21
to Magnolia User Mailing List, bartosz...@magnolia-cms.com
On Tuesday, April 20, 2021 at 9:13:25 AM UTC-5 bartosz...@magnolia-cms.com wrote:
Hey Michael,

I have asked around and this indeed is a bug that required lib is not brought in.
The missing lib that needs to be added is: resteasy-jaxb-provider

There is already a ticket in place: https://jira.magnolia-cms.com/browse/PAGES-429
In meantime you need to add it yourself.

Thanks. This looks like  a partial solution. I added the following to ../mgnl-poc-webapp/pom.xml:

     <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jackson2-provider</artifactId>
      <version>4.5.8.Final</version>
    </dependency>
    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jaxb-provider</artifactId>
      <version>4.5.8.Final</version>
    </dependency>

The 404 error went away, but has been replaced by a 500 error:

"org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: info.magnolia.rest.RestError of media type: application/json"

Did I miss something obvious?

Mikaël Geljić

unread,
Apr 21, 2021, 4:34:27 AM4/21/21
to Magnolia User Mailing List, tno.thene...@gmail.com, Bartosz Staryga
Hi Michael,

Given you're overlaying dx-core-webapp, I don't believe you're affected by PAGES-429. Magnolia's rest-integration module should pull all required resteasy libraries already. The jackson2-provider is the one that brings `org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider`, which is a universal MessageBodyWriter for json serialization.

Can you confirm if all the resteasy libraries are present in your WEB-INF/lib, otherwise run a mvn dependency:tree on the webapp?
Also, are you deploying to tomcat or any other runtime?

Cheers,
Mika

Michael Haufe

unread,
Apr 22, 2021, 9:39:59 AM4/22/21
to Magnolia User Mailing List, Mikaël Geljić, Michael Haufe, bartosz...@magnolia-cms.com
This is deployed to Tomcat.

What ended up working for me (which is probably overkill) is the following:

<dependency>
  <groupId>info.magnolia.pages</groupId>
  <artifactId>magnolia-spa-rendering</artifactId>
  <version>6.2.6</version>
</dependency>
<dependency>
  <groupId>info.magnolia.pages</groupId>
  <artifactId>magnolia-spa-rendering-extended</artifactId>
  <version>1.1</version>
</dependency>
<dependency>
  <groupId>org.jboss.resteasy</groupId>
  <artifactId>resteasy-jackson2-provider</artifactId>
  <version>4.5.8.Final</version>
</dependency>
<dependency>
  <groupId>org.jboss.resteasy</groupId>
  <artifactId>resteasy-jaxb-provider</artifactId>
  <version>4.5.8.Final</version>
</dependency>
Reply all
Reply to author
Forward
0 new messages