Advertisement

05.14.2008 at 03:26AM PDT, ID: 23400824
[x]
Attachment Details

ParseException: Encountered "from" at character 1, but expected: ["DELETE", "SELECT", "UPDATE"].

Asked by chenwei in Enterprise Java Beans (EJB), Java Programming Language, J2EE

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_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
props.put(Context.PROVIDER_URL, "t3://localhost:7001");

try {
InitialContext ctx = new InitialContext(props);
cal = (Calculator) ctx.lookup("Calculator#com.wei.chen.ejbs.stateless.Calculator");
} catch (Exception e) {
e.printStackTrace();
}

nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(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.JasperException: javax.ejb.EJBException: nested exception is: <4|false|0.0.0> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter 'from Fund f'. Error message: <4|false|0.9.7> org.apache.openjpa.kernel.jpql.ParseException: Encountered "from" at character 1, but expected: ["DELETE", "SELECT", "UPDATE"].
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


But the same program runs quite well under JBoss.

Someone can help?

Start Free Trial
[+][-]05.14.2008 at 03:28AM PDT, ID: 21562599

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 04:49AM PDT, ID: 21563063

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Enterprise Java Beans (EJB), Java Programming Language, J2EE
Sign Up Now!
Solution Provided By: themuppeteer
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.14.2008 at 06:58AM PDT, ID: 21564238

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628