My jsp "addfund.jsp" looks as follow:
**************
...
...
<%!private Calculator cal = null;
private NumberFormat nf = null;
public void jspInit() {
Properties props = new Properties();
props.put(Context.INITIAL_
CONTEXT_FA
CTORY,
"weblogic.jndi.WLInitialCo
ntextFacto
ry");
props.put(Context.PROVIDER
_URL, "t3://localhost:7001");
try {
InitialContext ctx = new InitialContext(props);
cal = (Calculator) ctx.lookup("Calculator#com
.wei.chen.
ejbs.state
less.Calcu
lator");
} catch (Exception e) {
e.printStackTrace();
}
nf = NumberFormat.getInstance()
;
nf.setMaximumFractionDigit
s(2);
}%>
...
...
<%
Collection<Fund> funds = cal.getFunds();
%>
...
*****
The stateless session beans looks as follow:
*********
...
@Stateless(mappedName = "Calculator")
//@Remote(Calculator.class
)
public class EntityCalculator implements Calculator {
@PersistenceContext// (unitName="cal")
protected EntityManager em;
public void addFund(String name, double growthrate) {
Fund fund = new Fund(name, growthrate);
em.persist(fund);
}
public Collection<Fund> getFunds() {
return em.createQuery("from Fund f").getResultList();
}
...
...}
***********
As I invoke the "addfund.jsp", I got exceptions as follow:
**********
org.apache.jasper.JasperEx
ception: javax.ejb.EJBException: nested exception is: <4|false|0.0.0> org.apache.openjpa.persist
ence.Argum
entExcepti
on: An error occurred while parsing the query filter 'from Fund f'. Error message: <4|false|0.9.7> org.apache.openjpa.kernel.
jpql.Parse
Exception:
Encountered "from" at character 1, but expected: ["DELETE", "SELECT", "UPDATE"].
org.apache.jasper.servlet.
JspServlet
Wrapper.ha
ndleJspExc
eption(Jsp
ServletWra
pper.java:
541)
org.apache.jasper.servlet.
JspServlet
Wrapper.se
rvice(JspS
ervletWrap
per.java:4
35)
org.apache.jasper.servlet.
JspServlet
.serviceJs
pFile(JspS
ervlet.jav
a:320)
org.apache.jasper.servlet.
JspServlet
.service(J
spServlet.
java:266)
javax.servlet.http.HttpSer
vlet.servi
ce(HttpSer
vlet.java:
803)
But the same program runs quite well under JBoss.
Someone can help?
Start Free Trial