Groups > Weblogic > WebLogic Enterprise JavaBeans > ArgumentException: Encountered "from" at character 1, but




ArgumentException: Encountered "from" at
character 1, but

ArgumentException: Encountered "from" at character 1, but
Wed, 14 May 2008 03:16:20 -070
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?

Regards

Post Reply
about | contact