在CMP的例子中
ejb-jar文件中编写的ejb-ql语句按照书上所给写出,但是在JB8+Weblogic7的情况发布时报错如下:
"ProductBean.ejbgrpx": Spaces in the temporary directory path may cause WebLogic EJBC utility to produce fatal compile errors.
"ProductBean.ejbgrpx": D:\bea\jdk131_06\bin\javaw -classpath "D:\bea\weblogic700\server\lib\weblogic.jar;D:\bea\weblogic700\server\lib\webservices.jar;F:\MySQLJDBC\mysql.jar;" weblogic.ejbc -keepgenerated -compiler D:/JBuilder8/bin/bcjW F:/LeranEJB/ProductBean.jar.jar F:/LeranEJB/ProductBean.jar
"ProductBean.ejbgrpx": ERROR: Error from ejbc: Error while reading META-INF/weblogic-cmp-rdbms-jar.xml. The error was:
"ProductBean.ejbgrpx":
"ProductBean.ejbgrpx": weblogic.ejb20.cmp.rdbms.finders.IllegalExpressionException:
"ProductBean.ejbgrpx": While trying to process Query
"ProductBean.ejbgrpx": Method Name: findByname
"ProductBean.ejbgrpx": Parameter Types: (java.lang.String)
"ProductBean.ejbgrpx": EJB Query: SELECT OBJECT(a) FROM ProductBean AS a WHERE name = ?1
"ProductBean.ejbgrpx": )
"ProductBean.ejbgrpx": Invalid Expression: Could not find a Range Variable as defined in an AS declaration that refers to the root of the path expression: name. Please check your Query and verify that you have defined a FROM (abstract_schema_name) AS name in your Query.
"ProductBean.ejbgrpx": weblogic.ejb20.cmp.rdbms.finders.IllegalExpressionException:
"ProductBean.ejbgrpx": While trying to process Query
"ProductBean.ejbgrpx": Method Name: findByDescription
"ProductBean.ejbgrpx": Parameter Types: (java.lang.String)
"ProductBean.ejbgrpx": EJB Query: SELECT OBJECT(a) FROM ProductBean AS a WHERE description = ?1
"ProductBean.ejbgrpx": )
"ProductBean.ejbgrpx": Invalid Expression: Could not find a Range Variable as defined in an AS declaration that refers to the root of the path expression: description. Please check your Query and verify that you have defined a FROM (abstract_schema_name) AS description in your Query.
"ProductBean.ejbgrpx": weblogic.ejb20.cmp.rdbms.finders.IllegalExpressionException:
"ProductBean.ejbgrpx": While trying to process Query
"ProductBean.ejbgrpx": Method Name: findByBasePrice
"ProductBean.ejbgrpx": Parameter Types: (double)
"ProductBean.ejbgrpx": EJB Query: SELECT OBJECT(a) FROM ProductBean AS a WHERE basePrice = ?1
"ProductBean.ejbgrpx": )
"ProductBean.ejbgrpx": Invalid Expression: Could not find a Range Variable as defined in an AS declaration that refers to the root of the path expression: basePrice. Please check your Query and verify that you have defined a FROM (abstract_schema_name) AS basePrice in your Query.
"ProductBean.ejbgrpx": weblogic.ejb20.cmp.rdbms.finders.IllegalExpressionException:
"ProductBean.ejbgrpx": While trying to process Query
"ProductBean.ejbgrpx": Method Name: findExpensiveProducts
"ProductBean.ejbgrpx": Parameter Types: (double)
"ProductBean.ejbgrpx": EJB Query: SELECT OBJECT(a) FROM ProductBean AS a WHERE basePrice > ?1
"ProductBean.ejbgrpx": )
"ProductBean.ejbgrpx": Invalid Identifier in EJB QL expression: Could not find a Range Variable as defined in an AS declaration that refers to the root of the path expression: basePrice. Please check your Query and verify that you have defined a FROM (abstract_schema_name) AS basePrice in your Query.
"ProductBean.ejbgrpx": weblogic.ejb20.cmp.rdbms.finders.IllegalExpressionException:
"ProductBean.ejbgrpx": While trying to process Query
"ProductBean.ejbgrpx": Method Name: findCheapProducts
"ProductBean.ejbgrpx": Parameter Types: (double)
"ProductBean.ejbgrpx": EJB Query: SELECT OBJECT(a) FROM ProductBean AS a WHERE basePrice < ?1
"ProductBean.ejbgrpx": )
"ProductBean.ejbgrpx": Invalid Identifier in EJB QL expression: Could not find a Range Variable as defined in an AS declaration that refers to the root of the path expression: basePrice. Please check your Query and verify that you have defined a FROM (abstract_schema_name) AS basePrice in your Query.
"ProductBean.ejbgrpx": weblogic.ejb20.cmp.rdbms.finders.IllegalExpressionException:
"ProductBean.ejbgrpx": While trying to process Query
"ProductBean.ejbgrpx": Method Name: findAllProducts
"ProductBean.ejbgrpx": Parameter Types: ()
"ProductBean.ejbgrpx": EJB Query: SELECT OBJECT(a) FROM ProductBean AS a WHERE productID IS NOT NULL
"ProductBean.ejbgrpx": )
"ProductBean.ejbgrpx": Invalid Expression: Could not find a Range Variable as defined in an AS declaration that refers to the root of the path expression: productID. Please check your Query and verify that you have defined a FROM (abstract_schema_name) AS productID in your Query.
"ProductBean.ejbgrpx": ERROR: ejbc found errors
请问这是什么原因造成的?
1 路径有空格,TEMP TMP ...
2 是a.name 不是name
SELECT OBJECT(a) FROM ProductBean AS a WHERE a.name = ?1
问题出在这里,下面也是一样:
SELECT OBJECT(a) FROM ProductBean AS a WHERE name = ?1
From 后面跟的不是表名,而是Abstract schema name
name 也不是表中的字段,而是你的CMP中映射的变量名,
注意大小写, name = ?1之间不能有空格。