cancel
Showing results for 
Search instead for 
Did you mean: 

Database access with JSP

Former Member
0 Kudos

Hello,

i have a Java Server Page where i fill in some data in a formular. I want to put these data (only two strings) in a database. I already use a servlet to give this data to a (already existing) stateless session bean. I also created and deployed an sda, so that the table exists in the database.

But i do not understand, what to do next - how to use an entity bean to fill the table.

Can anyone give me some hints?

Thanks,

André

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

thanks for your answer.

So i created an entity bean in a project where i already have my session bean.

When i deploy the new ear file i do not get any error messages, but when i try to start it in the browser i get an error:

Details: java.lang.ClassCastException

at com.sap.engine.services.ejb.deploy.orMappingVerifier.AbstractSchemaVerifier.check(AbstractSchemaVerifier.java:48)

at com.sap.engine.services.ejb.EJBAdmin.prepareStart(EJBAdmin.java:2456)....

(and so on)

What does this mean?

André

Former Member
0 Kudos

I can't tell you exactly where your error is, for that I need more information. But you are getting a ClassCastException and that means that you are trying to handle one type of object as something else. Look at the lines of code where this error occurs and make sure you cast all objects wherever needed.

regards,

Dionisios

Former Member
0 Kudos

Hi Andre,

you need to retrieve the Home Object of your entity bean and use it to create, the same way you create your session bean.

Example:

InitialContext initialContext = new InitialContext();

EjbObject myEjb = null;

try {

java.lang.Object objRef = initialContext.lookup(EjbHome.JNDI_NAME);

EjbHome home = (EjbHome)PortableRemoteObject.narrow(objRef, EjbHome.class);

myEjb = home.create();

} catch (Exception) {

initialContext.close();

}

The lookup to the home object can vary, you might also have helper classes for that, it depends on your application server, API and architecture.

But however the call or whichever the server, you basically need to retrieve the home object of your entity bean and use the method create() - with any required parameters. Pretty much the same way you create a session bean.

Hope this helps.

regards,

Dionisios