Skip to Content
Author's profile photo Rui Nogueira

SAP HCP openSAP course guide week 2

[Update: This course is being repeated with updates]

Hi everyone, please be informed that the course “Introduction to SAP HANA Cloud Platform” was updated with new functionalities of the platform. Some of the units from the first course in 2013 no longer work seamlessly. To avoid issues on your side, please look into the repetition of the course “Introduction to SAP HANA Cloud Platform”. There is also a course guide available with the links to all blog posts I wrote for the updated course.

Course Guide Week 2 – Persistency Basics

Hi everyone,

in the second week of the course Introduction to SAP HANA Cloud Platform we will provide you with some basics around the usage of the Persistence Service of our platform.

Find below additional information that can be useful to you during this course week. While monitoring the forums I’ll also add some sections around common mistakes and how to fix them into the corresponding units.

Table of Contents

Unit 1 – Introduction & First Steps With EJB

Common Issues

Persistence operation failed with reason: The bean encountered a non-application exception

When inserting a value in the ejb sample’s UI he following exception is displayed:

Persistence operation failed with reason: The bean encountered a non-application exception; nested exception is: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services – 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [274]: inserted value too large for column: 49620af6-80cd-454b-a95b-258eab7e287c Error Code: 274 Call: INSERT INTO T_PERSONS (ID, FIRSTNAME, LASTNAME) VALUES (?, ?, ?) bind => [3 parameters bound] Query: InsertObjectQuery(com.sap.cloud.sample.persistence.Person@8de9f444)

Solution: You’re using HANA schema without setting the additional property: <property name=”eclipselink.target-database” value=”com.sap.persistence.platform.database.HDBPlatform”/> in the persistence.xml.

1. go the cockpit -> Your application -> Database Schemas and delete the schema of the application.

2. set the property in persistence.xml

3. deploy/run the application again

MaxDB, HANA database, and the Target Database

Some participants realized that after deployment of their application they ended up with a schema on a MaxDB rather than a HANA database. You can check this in the Cloud Cockpit. Just click on Database Schemas and check the database type of your schema.

In the course you learned how to set the target database to com.sap.persistence.platform.database.HDBPlatform. (in the video this step has been shown at around 10:20). It is necessary to instruct EclipseLink to use HANA specific commands, types, etc. to access (an already existing) HANA database. However, it does not create a schema on a HANA database.

Actually a schema is created when an application is deployed in the cloud for the first time. The DB type that is used depends on the default settings that you can control in the Cloud Cockpit. So what you have to do in addition is to change the default settings in the Cloud Cockpit to HANA as described in Changing the Default Database and deploy your application with a new name (that forces the creation of a new schema).

I don’t see the JPA Content object in my eclipse IDE

  1. Right Click on your JPA project, in the menu which appears click on properties.
  2. In the properties window Select Project Facets.
  3. If Project Facets are not displayed click on link saying convert to facetted project.
  4. If Facets already available select Checkbox against JPA.
  5. Below  the Properties window a link appears “Further configurations required”.
  6. Click on this link.
  7. In JPA facets window which appears select EclipseLink 2.X.X from Platform drop down and Disable Library Configuration from JPA Implementation drop down.
  8. Click OK

The JPA Content should appear now.

Unit 2 – Connecting To Your Database

Common issues while opening the db tunnel

“Command [open-db-tunnel] not found”

Solution: use the newest version of the Java EE 6 sdk from https://tools.hana.ondemand.com/sdk/ this command is pretty new and can be missing in some older sdk versions

If you call “neo -help” it will list all the commands supported in this SDK. The open-db-tunnel command if is listed in the “persistence” group.

“Host [hanatrail.ondemand.com] cannot be accessed. HTTPS proxy settings not found”

Solution:

1. Check the spelling of the host you provide in the command it should be hanatrial.ondemand.com.

2. Set up a proxy: Check the section below: “Should I use a proxy?”

“Host [proxy] cannot be accessed”

Solution: Your proxy settings are either not correct or you don’t need to use a proxy at all. Check the section below: “Should I use proxy?”

“‘.’ is not recognized as an internal or external command, operable program or batch file”

Solution: You are calling ./neo.sh on windows. Windows users should use: neo.bat to execute the open-db-tunnel command.

After connecting to the tunnel,the connection properties does not show the instance number

Solution: Your schema is MaxDB so you don’t need the instance number to connect to it. However you cannot connect to a MaxDB schema using HANA Studio. You have two options:

  1. If you want to use HANA Studio follow these instructions to change your default database type and create a HANA schema:
    • To change the default database type for your account follow the instructions described in Changing the Default Database.
    • Then either delete your application schema so that the new deployment will create a new one or just deploy the application with a new name.
  2. If you want to continue using the MaxDB schema connect to it using the Eclipse Database Development perspective.
    The corresponding documentation shows how to connect to a database not with the tunnel but with a remote accessing servlet – this is the predecessor of the db tunnel. However the only difference is that when you configure the database connection you have to provide the jdbc url, username and password provided by the tunnel output. In the MaxDB case you don’t need to know the instance number that’s why it is not printed by the tunnel.

“Detected attempt to connect with invalid user: “DEV_XXX” ” after opening the tunnel

Solution: When you add a new System in the HANA Studio there is an “Auto-reconnect” checkbox which is by default checked. So once a system is added in the HANA Studio it will try regularly to refresh the system and collect some meta-information. When the tunnel is closed the attempts to reconnect fail but when you open a new tunnel a new password will be created. The Studio however will try to reconnect with the old password which will result in authentication exceptions and that’s why you see the warning message in the console. If you don’t change the password in your system properties (in HANA Studio) fast enough the user will be locked after some time. The user will be unlocked next time you open the tunnel.

So you either have to immediately edit the password in HANA Studio every time you reconnect the tunnel or just un-select the “Auto-reconnect” checkbox when adding a new System (in this case you should refresh the system manually from the context menu).

SSL certification error when trying to add a new system in Hana Studio

Solution: Open the <HANA_studio_installation_folder>\hdbstudio.ini there should be a -vm parameter with value stating where the java.exe is located. (For example: C:\jdk1.7\bin\javaw.exe, usually in a new line just after the -vm parameter). Make sure that the VM used is Java 6 or Java 7. Sometimes when you have a previously installed old jdk the Hana Studio installer choose to use it.

Proxy settings

To be able to establish a database tunnel through the console client you need to have your proxy settings setup correctly. Just follow this instruction: https://help.hana.ondemand.com/help/frameset.htm?7613dee4711e1014839a8273b0e91070.html

Should I use a proxy?

Check in the Firefox (Chrom) what kind of settings do you have for the proxy. Open “Tools”->”Options”->”Network”-> “Settings” There should be one of the following options selected:

  • No proxy – in this case you should set no proxy settings in both eclipse and command console
  • Manual proxy settings – there should be a host and port which you should use both in eclipse and in command console (the syntax of the “set” command for the different operating systems can be seen in the <HCP_SDK_PATH>\tools\readme.txt file). <HCP_SDK_PATH> is the path in the file system where you unzipped the HANA Cloud Platform SDK.
  • Automatic proxy configuration URL (something like: http://proxy:8083/). Copy and paste this URL in the browser and download the file it points to. You can open the file with Notepad. At the very end of this file should stay something like:
    return “PROXY dxxx3proxy.yyy.zzz.corp:8080;PROXY proxy.xxx.yyy.corp:8080;”;
    Use the proxy and port that are marked bold  in eclipse and the Console Client (in this case PROXY and 8080)

Unit 3 – Creating A JDBC Application

Unit 4 – Sharing Data Between Applications

Unit 5 -Using Multiple Databases

Assigned Tags

      21 Comments
      Comments are closed.
      Author's profile photo Former Member
      Former Member

      Hey Rui,  It is very informative and knowledgeable blog as well as straight forward guide. Very good afford. thanks for sharing and keep it up

      Arshiyan

      Author's profile photo Prashant Soni
      Prashant Soni

      Hello Rui,

      Persistence service of SAP HANA Platform is quite interesting.

      Now after deploying the application "persistance with ejb" in unit 1, when i enter the firstname & the lastname and click "Add Person", i get the following error:

      error.JPG

      I followed the note given in section "2.2 Maintain the metadata of the person entity" (from here we copied the Target Database for persistence.xml) and got same error.

      Solution for this?

      Thanks & Regards,

      Prashant Soni

      Author's profile photo Bernd Hofmann
      Bernd Hofmann

      Hello Prashant,

      Could it be that you deployed your application first and then changed the Target Database afterwards? In that case the table still exists with the wrong meta data still leading to the same error.

      To get over this you have to delete the tables and create them anew. The easiest way to do this is using the "Drop and Create Tables" feature. Open the "Schema Generation" tab of the persistence.xml file and choose "Drop and Create Tables" in the "DDL generation type" field. Then redeploy your application again.

      Of course, after successful deployment you should set this parameter back to "Create Tables". Otherwise you would always delete your tables during deployment.

      Regards,

      Bernd

      PS: As this is a more general page with background information about  the course I would recommend not to put questions here but rather use the discussion forum that has been provided for exactly this purpose. You'll find it here: https://open.sap.com/courses/7/discussion_topics (with specific sub forums for each week).

      Thanks and Regards,

      Bernd

      Author's profile photo Former Member
      Former Member

      Hi Rui,

      I am wondering about 2 things:

      1. when you said in Unit 5 "we copy the commands from slides (new method for the java servlet etc." where those slides are actually? I had to type the lines myself.

      2. I compared the 2 types of loggers and could not find a difference, I even used "all" type.

      Is any type will reveal the actual value which was sent to the database? Oracle has such a way. Thanks,Michael

      Author's profile photo Former Member
      Former Member

      Hi Rui,

              I am having a problem in running the console client command prompt. Is this a separate command prompt or the standard Win 7 prompt ? Since you use a Mac its a bit confusing as the way you run (Right click on the Tools folder and run the services) is not available in Windows. Please let me know on this .

      Regards,

      Sandeep

      Author's profile photo Former Member
      Former Member

      Hi Sandeep,

      this is the standard win7 prompt(cmd.exe). You need to open it and to navigate to the location of the "tools" folder. More details on setting up the console client you can find in the official documentation.

      Best regards,

      Nikolay

      Author's profile photo Former Member
      Former Member

      Thanks Nikolay, its clear now.

      One more query regarding HANA Client and HANA Studio. As per the unit 2 , I have installed HANA studio. Do we also need to install HANA Client ? and access SAP HANA Repository ?

      Regards,

      Sandeep

      Author's profile photo Former Member
      Former Member

      Hi Sandeep,

      You won't need the client for the JDBC application from week 2 of the course. Here you are installing it for remote database access. The client is necessary for developing HANA native applications.

      Best regards,

      Nikolay

      Author's profile photo David Brilleman
      David Brilleman
      I am having a problem connecting HANA Studio to the HANA Repository.   After running the neo open-db-tunnel and using the information in HANA Studio to create repository workspace, I get an error authenticating. 

      An error occurred: Connecting to the database failed Connection failed (RTE:[89006] System call 'connect' failed, rc=10060:A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)
      . Could not connect to SAP HANA repository

      Then I closed and opended a new tunnel but HANA Studio claims the System already exists.  

      System 'J14 phln00544861a 00 (DEV_C86IDMME7SLX8PSLL5KUZH1SI)' already exists in folder '/'

      (Question) How can I remove a System connection to start over?  Also, I did not see the view 'SAP HANA System View', instead I used SAP HANA Repository.  Am I on the wrong version of HANA Studio?  I am on HANA Studio Version: 1.0.48; Build id: 201301130825 (372847)
      Author's profile photo Former Member
      Former Member

      Hi Rui,

      great course! Keep it up!

      Author's profile photo Former Member
      Former Member

      Hi Rui,

      I may sound silly but since am new to this please excuse me.

      I could not find a create table query within the PersistencewithEJB sample. Neither could I find any select or insert options. I could understand from the java code that they have been formulated as a table using code. But when I connect to the HANA studio using the schema of the application even though I could not see the table getting created in the DEV account due to reasons that ELitsa had explained in one of the discussions, I could find the table getting created in the Neo account. I had tried modifying the application adding some more fields. Then also its working fine.

      Is it the persistence service that is creating the query in the HANA DB or the EJB? Since I could find a datasource defining code in JDBC and in the slides also its mentioned that in JDBC "Initial creation of database structures required". And in JDBC also there is the use of persistence service. Am a lil confused here.

        If am missing out something please let me know.

      Thanks,

      Meera

      Author's profile photo Elitsa Semerdzhieva
      Elitsa Semerdzhieva

      Hi Meera,

      The EJB sample is using JPA and not JDBC. In JPA you just define your persistence units as java classes and then the JPA provider - in our case EclipseLink creates a table for every such class. In our case it creates a table T_PERSONS (there is an annotation in the Persistence class specifying the tables name) and columns - id, firstname and lastname. If you add more filends here the EclipseLink will add more columns.

      If you look at the persistence.xml you'll see that the Person.class is listed there - this is the way to notify EclipseLink that it should create a table for it.

      This is the biggest advantage of JPA compared to JDBC that you work only with java objects and the JPA takes care to translate the operations to SQL statements, execute them and then translate the results into java objects again.

      Hope it's a bit clearer now.

      Greetings,

      Elitsa

      Author's profile photo Former Member
      Former Member

      Hi All,

      I have another problem that I have ran into.

      hanaStudioError.png

      After I have received the logon details for creating a new system in HANA studio, I go to the user folder that should hold all the information I have entered into my application.

      But the folders are empty and I receive an error saying that the Database connection is not available. Why would this be happening?

      Surely the proxy settings are correct as I was given a valid user/password to connect the DB Tunnel. And the path is also correct.

      So I am just wondering why is this happening?

      Thanks.

      Best Regards,

      /Barry

      Author's profile photo Elitsa Semerdzhieva
      Elitsa Semerdzhieva

      Hi Barry,

      Try deleting this system in HANA studio. Execute again the open-db-tunnel command so you get a new password and try adding the System again. Also make sure that the type of your schema is HANA (you can see this also in the output of the tunnel).

      In the NEO_XXXXXXXXX schema -> Tables there should be the T_PERSONS table and if you have added some names in the application UI you should be able to see also them.

      Hope that helps,

      Greetings,

      Elitsa

      Author's profile photo Former Member
      Former Member

      Hi Elitsa,

      I now got it working.

      Thank you for your assistance.

      Thanks Elitsa.

      Best Regards,

      /Barry

      Author's profile photo Former Member
      Former Member

      Hi Everyone,

      I have deployed the solution to the cloud.

      And opened it through the Database Tunnel in HANA Studio,

      But say for example a customer is using an application I have created, like a survey.

      They apply all the data to this survey.

      But they wont be able to see it because they wont be running an database tunnel.

      How can I perform this without using a DB Tunnel?

      Author's profile photo Rui Nogueira
      Rui Nogueira
      Blog Post Author

      Hi Barry, if you provide the data in an application that your customer can access, your customer doesn't need any DB tunnel. You provide the information to your customer via your application and that's it. If you want to restrict the access to these applications you can work with roles as described in week 4 of the course (user authentication and security).

      Hope I've understood your use case correctly.

      Best,

      Rui

      Author's profile photo Former Member
      Former Member

      Hi RUi

      Getting this error when clicking on application URL - I have maintained the HANA DB in the persistence.xml any ideas?

      Persistence with EJB Sample!

      Persistence operation failed with reason: The bean encountered a non-application exception; nested exception is: javax.persistence.PersistenceException: Exception [EclipseLink-7042] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.ValidationException Exception Description: Database platform class [com.sap.persistence.platform.database.HDBPlatform] not found. Internal Exception: java.lang.ClassCastException: class com.sap.persistence.platform.database.HDBPlatform:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@55088a5f[org.eclipse.persistence.core:2.4.1.v20121003-ad44345(id=252)] incompatible with interface org.eclipse.persistence.internal.databaseaccess.Platform:org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@5e980724[persistence-with-ejb:0.0.0(id=301)]

      thanks

      Stephen

      Author's profile photo Arnaud BERTRAND
      Arnaud BERTRAND

      Just keep the default value. This is depend on the version and the change of the target is no longer required.

      Author's profile photo Former Member
      Former Member

      I get below error when in try to add cloud system>trial schema. i have provided correct host and correct credentials. i have default proxy setting i.e 'Native' as i am using home PC.

      Please help

      Host_Connection_Error.png

      Author's profile photo Rui Nogueira
      Rui Nogueira
      Blog Post Author

      Hi everybody, this course is being repeated on openSAP. As some of the units have been re-recorded to reflect updates on the platform I highly recommend to look into the learning materials there instead of using the videos from the first course in 2013.

      This is also the reason why I close this blog post for comments.

      @Sneha: please post your question into the openSAP forum for the new introductory course or simply add it to the SCN Forum of the SAP HANA Cloud Platform.

      Best,

      Rui

      Comments are closed.