"500 - An Exception has occurred" while creating a Community

384 views
Skip to first unread message

Thiago Camelo

unread,
Aug 21, 2023, 5:07:20 PM8/21/23
to DSpace Technical Support
I am developing a new UI for interact w/ the REST API and while developing the components that submit content to the endpoints i found myself unable to post a (new) community in the main community endpoint. I get a not very descritive error in the request response: "500 An exception has occurred".

The data i'm submitting to: (as string)
{
  "name": "Comunidade teste",
  "metadata": {
    "dc.title": [
      {
        "value": "Comunidade teste",
        "language": null,
        "authority": null,
        "confidence": -1
      }
    ],
    "dc.description": [
      {
        "value": "testando 123",
        "language": null,
        "authority": null,
        "confidence": -1
      }
    ]
  }
}

both are not HTTPS, same machine (localhost based), using axios;
i can login and get both csrf and jwt correctly but i'm clueless about the rest

main endpoint info:
{ "dspaceUI": "http://localhost:5173/", "dspaceName": "Repositorio Academico", "dspaceServer": "http://192.....:8080/server/", "dspaceVersion": "DSpace 7.6", "type": "root" }

DSpace Technical Support

unread,
Aug 22, 2023, 12:20:16 PM8/22/23
to DSpace Technical Support
Hi,

A 500 exception in DSpace generally means "something went wrong on the backend" or that the client is unable to communicate with the backend.  The only way to determine the cause of the error is to try to locate the detailed exception in the backend logs as described in our troubleshooting guide: https://wiki.lyrasis.org/display/DSPACE/Troubleshoot+an+error#Troubleshootanerror-DSpace7.x(orabove)

There are a number of suggestions in that troubleshooting guide for how to debug these sorts of issues.  If you can find a more detailed error message, you can always post it back here if it doesn't make sense.  There are also some common installation issues we have listed at https://wiki.lyrasis.org/display/DSDOC7x/Installing+DSpace#InstallingDSpace-CommonInstallationIssues

Tim

Thiago Camelo

unread,
Aug 22, 2023, 1:23:08 PM8/22/23
to DSpace Technical Support

Hi Tim, thanks for the answer.
I followed the suggestions on the troubleshoot guide and after setting up the java trace i got this:

java.lang.NullPointerException: Cannot invoke "org.dspace.content.Site.getID()" because the return value of "org.dspace.content.service.SiteService.findSite(org.dspace.core.Context)" is null ...

There's nothing similar to this in the common installation issues article nor in the backend documentation (as far as i looked). Can you help me troubleshoot this?

DSpace Technical Support

unread,
Aug 22, 2023, 3:20:36 PM8/22/23
to DSpace Technical Support
Hi Thiago,

It sounds like the SIte object didn't initialize in your database properly.  That can sometimes occur if something fails in the installation or setup of your database.

You should verify that all database migrations ran successfully on your database by running this from commandline (in the [dspace]/bin/ folder):
./dspace database status

It should report every migration as either "Success" (ran successfully) or "Out of Order" (ran successfully but run out of numerical order -- sometimes happens via upgrades).

If anything is failed or Pending or Ignored, then you need to complete all the migrations via : ./dspace database migrate ignored

If everything is succeeded, then you can force the "Site" object to be recreated by running ./dspace database migrate force

After running any of these commands, you should verify no new errors appear in your dspace.log.

More docs on all these commandline options are at https://wiki.lyrasis.org/display/DSDOC7x/Database+Utilities

Tim

Thiago Camelo

unread,
Aug 22, 2023, 4:47:24 PM8/22/23
to DSpace Technical Support

Hi Tim,

Yes, you're absolutelly correct. That solved it, thank you.
Reply all
Reply to author
Forward
0 new messages