<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Error 500 in CAP entitySet READ in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14244189#M4929264</link>
    <description>Yasutake-san, thank you for your reply. Since this exercise is simple demo, so I haven't prepared to use it for updating HANA DB data yet. Is HANADB configuration mandatory for CAP program deployment anyway?(even if I won't use it for data updates?)</description>
    <pubDate>Wed, 15 Oct 2025 01:52:48 GMT</pubDate>
    <dc:creator>ZMoe</dc:creator>
    <dc:date>2025-10-15T01:52:48Z</dc:date>
    <item>
      <title>Error 500 in CAP entitySet READ</title>
      <link>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaq-p/14243017</link>
      <description>&lt;P&gt;Hi everyone, I'm new to CAP development. I ran into this problem when building a simple demo in the trial environment.&lt;/P&gt;&lt;P&gt;I have successfully deployed my CAP application to BTP and can access the service metadata.&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;&lt;A href="https://xxxtrial-dev-moe-cap-backend-srv.cfapps.us10-001.hana.ondemand.com/odata/v4/My_SRV/$metadata" target="_blank"&gt;https://xxxtrial-dev-moe-cap-backend-srv.cfapps.us10-001.hana.ondemand.com/odata/v4/My_SRV/$metadata&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="1.png"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/327023i38FE42EC0BDFE8BF/image-size/large?v=v2&amp;amp;px=999" alt="1.png" title="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I access the entitySet, I get the following error:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;&lt;A href="https://xxxtrial-dev-moe-cap-backend-srv.cfapps.us10-001.hana.ondemand.com/odata/v4/My_SRV/" target="_blank"&gt;https://xxxtrial-dev-moe-cap-backend-srv.cfapps.us10-001.hana.ondemand.com/odata/v4/My_SRV/&lt;/A&gt;&lt;STRONG&gt;MoeSet&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="2.png"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/327024i966894B398380191/image-size/large?v=v2&amp;amp;px=999" alt="2.png" title="2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I generated the CAP framework using the following command:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;mvn -B archetype:generate -DarchetypeArtifactId=cds-services-archetype -DarchetypeGroupId=com.sap.cds -DarchetypeVersion=RELEASE -DgroupId=com.moe.company -DartifactId=moe-cap-backend -Dpackage=com.moe.company.moecapbackend&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I created &lt;STRONG&gt;capservice.cds&lt;/STRONG&gt; under the srv directory with the following content:&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;service My_SRV {
    @requires: 'any'
    entity MoeSet as projection on TestSet;
}

entity TestSet {
    key testKey : String(64);
    inputData : String(100);
    memo: String(100);
    outputData: String(100);
}&lt;/LI-CODE&gt;&lt;P&gt;And &lt;SPAN&gt;I also created a &lt;STRONG&gt;MyServiceHandler.java&lt;/STRONG&gt; file under the main directory with the following content:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;package com.moe.company.mycapbackend;

import java.util.HashMap;
import java.util.Map;
import com.sap.cds.services.cds.CdsReadEventContext;
import com.sap.cds.services.cds.CqnService;
import com.sap.cds.services.handler.EventHandler;
import com.sap.cds.services.handler.annotations.On;
import com.sap.cds.services.handler.annotations.ServiceName;
import com.sap.cds.services.request.UserInfo;
import cds.gen.my_srv.MoeSet;


@ServiceName("My_SRV")
public class MyServiceHandler implements EventHandler {

  &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1399738"&gt;@On&lt;/a&gt;(event = CqnService.EVENT_READ, entity = "My_SRV.MoeSet")
  public void beforeReadProducts(CdsReadEventContext context) {
    UserInfo userInfo = context.getUserInfo();

    MoeSet datamodel = com.sap.cds.Struct.create(MoeSet.class);
    datamodel.put(MoeSet.MEMO, userInfo.getName());

    Map&amp;lt;Object, Map&amp;lt;String, Object&amp;gt;&amp;gt; result = new HashMap&amp;lt;&amp;gt;();
    String key ="test1";
    result.put(key, datamodel);

    context.setResult(result.values());

  }
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Since this is just a simple practice, I didn't add authentication. Here's my mta.yaml file:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;_schema-version: 3.3.0
ID: moe-cap-backend
version: 1.0.0-SNAPSHOT
description: "A simple CAP project."
parameters:
  enable-parallel-deployments: true
modules:
  - name: moe-cap-backend-srv
    type: java
    path: srv
    parameters:
      instances: 1
      buildpack: sap_java_buildpack_jakarta
    properties:
      SPRING_PROFILES_ACTIVE: cloud,sandbox
      JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jre.SAPMachineJRE']"
      JBP_CONFIG_SAP_MACHINE_JRE: '{ version: 17.+ }'
    build-parameters:
      builder: custom
      commands:
        - mvn clean package -DskipTests=true --batch-mode
      build-result: target/*-exec.jar
    provides:
      - name: srv-api # required by consumers of CAP services (e.g. approuter)
        properties:
          srv-url: ${default-url}

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are there any steps I might have missed?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Oct 2025 05:27:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaq-p/14243017</guid>
      <dc:creator>ZMoe</dc:creator>
      <dc:date>2025-10-14T05:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Error 500 in CAP entitySet READ</title>
      <link>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14243345#M4929184</link>
      <description>&lt;P&gt;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1948480"&gt;@ZMoe&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A 500 error when accessing an entity typically &lt;SPAN&gt;occurs&lt;/SPAN&gt; when the HANA Cloud is stopped. Can you verify that your HANA Cloud instance is running?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Oct 2025 10:17:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14243345#M4929184</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2025-10-14T10:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error 500 in CAP entitySet READ</title>
      <link>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14244189#M4929264</link>
      <description>Yasutake-san, thank you for your reply. Since this exercise is simple demo, so I haven't prepared to use it for updating HANA DB data yet. Is HANADB configuration mandatory for CAP program deployment anyway?(even if I won't use it for data updates?)</description>
      <pubDate>Wed, 15 Oct 2025 01:52:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14244189#M4929264</guid>
      <dc:creator>ZMoe</dc:creator>
      <dc:date>2025-10-15T01:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Error 500 in CAP entitySet READ</title>
      <link>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14244647#M4929334</link>
      <description>&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1948480"&gt;@ZMoe&lt;/a&gt; Sorry, I overlooked that your app doesn't use DB. In that case, HANA Cloud is not required. Do you see any detailed errors in the service log (retrieved via cf logs moe-cap-backend-srv)?</description>
      <pubDate>Wed, 15 Oct 2025 10:55:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14244647#M4929334</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2025-10-15T10:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Error 500 in CAP entitySet READ</title>
      <link>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14245480#M4929434</link>
      <description>&lt;P&gt;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/789"&gt;@MioYasutake&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your advice.&lt;/P&gt;&lt;P&gt;I checked the logs.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":crying_face:"&gt;😢&lt;/span&gt;Even though the code doesn't get or update data from the database, according to the log, it seems the CAP backend still tried to connect to some database.&lt;/P&gt;&lt;P&gt;I copied part of the log:&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;2025-10-16T06:57:39.471+0000 [APP/PROC/WEB/0] STDOUT com.sap.cds.services.impl.ContextualizedServiceException: Error executing the statement (service 'PersistenceService$Default', event 'READ', entity 'My_SRV.MoeSet')
2025-10-16T06:57:39.471+0000 [APP/PROC/WEB/0] STDOUT at com.sap.cds.services.impl.ServiceImpl.dispatch(ServiceImpl.java:269) ~[cds-services-impl-4.4.1.jar:na] 
2025-10-16T06:57:39.471+0000 [APP/PROC/WEB/0] STDOUT at com.sap.cds.services.impl.ServiceImpl.emit(ServiceImpl.java:180) ~[cds-services-impl-4.4.1.jar:na] 
2025-10-16T06:57:39.471+0000 [APP/PROC/WEB/0] STDOUT at com.sap.cds.services.ServiceDelegator.emit(ServiceDelegator.java:33) ~[cds-services-api-4.4.1.jar:na] 
2025-10-16T06:57:39.471+0000 [APP/PROC/WEB/0] STDOUT at com.sap.cds.services.utils.services.AbstractCqnService.run(AbstractCqnService.java:64) ~[cds-services-utils-4.4.1.jar:na] 

======================= 

2025-10-16T06:57:39.472+0000 [APP/PROC/WEB/0] STDOUT Caused by: com.sap.cds.CdsDataStoreException: SQL: SELECT T0."TESTKEY", T0."INPUTDATA", T0."MEMO", T0."OUTPUTDATA" FROM "MY_SRV_MOESET" T0 ORDER BY T0."TESTKEY" NULLS FIRST LIMIT 1000 
2025-10-16T06:57:39.472+0000 [APP/PROC/WEB/0] STDOUT ... 126 common frames omitted 
2025-10-16T06:57:39.472+0000 [APP/PROC/WEB/0] STDOUT Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "MY_SRV_MOESET" not found (this database is empty); SQL statement: 
2025-10-16T06:57:39.472+0000 [APP/PROC/WEB/0] STDOUT SELECT T0."TESTKEY", T0."INPUTDATA", T0."MEMO", T0."OUTPUTDATA" FROM "MY_SRV_MOESET" T0 ORDER BY T0."TESTKEY" NULLS FIRST LIMIT 1000 [42104-232]&lt;/LI-CODE&gt;&lt;P&gt;And I updated some code today. I added READ and CREATE methods.&lt;/P&gt;&lt;P&gt;But after I deployed it again, I got the same error.&lt;/P&gt;&lt;P&gt;*Even though it's a very simple example, I put the code on Git for now as a reference: &lt;A href="https://github.com/moez-1217/moe-cap.git" target="_blank" rel="noopener"&gt;https://github.com/moez-1217/moe-cap.git&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2025 07:11:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14245480#M4929434</guid>
      <dc:creator>ZMoe</dc:creator>
      <dc:date>2025-10-16T07:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Error 500 in CAP entitySet READ</title>
      <link>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14245551#M4929443</link>
      <description>Thank you for your advice. I checked the logs. Even though the code doesn't get or update data from the database, according to the log, it seems the CAP backend still tried to connect to some database.I copied part of the log:</description>
      <pubDate>Thu, 16 Oct 2025 08:00:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14245551#M4929443</guid>
      <dc:creator>ZMoe</dc:creator>
      <dc:date>2025-10-16T08:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Error 500 in CAP entitySet READ</title>
      <link>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14246397#M4929532</link>
      <description>&lt;P&gt;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1948480"&gt;@ZMoe&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't use a database, try adding the following profile to the application.yaml.&lt;/P&gt;&lt;LI-CODE lang="yaml"&gt;---
spring:
  config:
    activate:
      on-profile: cloud
cds:
  data-source:
    auto-config:
      enabled: false&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2025 20:26:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14246397#M4929532</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2025-10-16T20:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Error 500 in CAP entitySet READ</title>
      <link>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14248310#M4929692</link>
      <description>&lt;P&gt;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/789"&gt;@MioYasutake&lt;/a&gt;&amp;nbsp; Thank you for your reply.&lt;/P&gt;&lt;P&gt;My application.yaml was automatically generated with the same content as yours. So maybe it shouldn't be the issue here.&lt;/P&gt;&lt;P&gt;I later tried some other methods to fix the error mentioned above. Finally, I resolved it using the approach below (at least that error no longer appears, though I don't understand why). But thank you very much anyway.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I modified the structure/writing style of my .cds file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Before:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;service My_SRV {
    entity MoeSet as projection on TestSet;
}

entity TestSet {
    key testKey : String(64);
    inputData : String(100);
    memo: String(100);
    outputData: String(100);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After:&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;service My_SRV {
    entity TestSet {
		key testKey : String(64);
		inputData : String(100);
		memo: String(100);
		outputData: String(100);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Oct 2025 07:03:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-500-in-cap-entityset-read/qaa-p/14248310#M4929692</guid>
      <dc:creator>ZMoe</dc:creator>
      <dc:date>2025-10-20T07:03:53Z</dc:date>
    </item>
  </channel>
</rss>

