I am not familiar with java environments but I have to develop a java project and I found JPA that as I understand a technology like entity framework of microsoft.
I went through below tutorial at youtube but I am taking a null pointer exception but I couldnt understand whats happening because I did same things with tutorial. My project Structure is below. I have a jsp file and I am using this file as main page so I am running the project from this file. I included index.xhtml because of necessity. Also you can find this file and index2.java file(Its "JSF Managed Bean") contents below.
Problem is at "tablo1FacadeLocal.create(tbl1);" line.
If you can spot the problem it would be great but if you suggest another way or thing like entity framework it works me too.
http://www.youtube.com/watch?v=4HhRF20-Jhs
Tablo1 and Tablo2 are my tables so I created Tablo1.java and Tablo2.java "Entity classes from database".
Then I did new>"Session Beans for Entity Classes" and created facades in ejb package.
Finally I did new>"JSF Managed Bean". Managed Bean name is index2.java
index2.jsp
<%@page import="Web.index2"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<%
index2 indx = new index2();
indx.setTablo1Values();
%>
</body>
</html>
index2.java
package Web;
import ejb.Tablo1FacadeLocal;
import entities.Tablo1;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class index2 {
@EJB
Tablo1FacadeLocal tablo1FacadeLocal;
public index2() {
}
public void setTablo1Values() {
Tablo1 tbl1 = new Tablo1();
tbl1.setClm1(5);
tbl1.setClmn2("fdfsfsdfs");
tablo1FacadeLocal.create(tbl1);
}
}