I create a new component in the hot-deploy.
first, i just add a index.jsp in the component's webapp,everything is ok. I want to test the GenericDelegator ,so I create a servlet for test. this is servlet code: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package qiya.deng.servlet; import java.io.*; import java.net.*; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.Vector; import javax.servlet.*; import javax.servlet.http.*; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntity; /** * * @author qiya */ public class ViewMethod extends HttpServlet { /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet ViewMethod</title>"); out.println("</head>"); out.println("<body>"); out.println(" Servlet ViewMethod at " + request.getContextPath () + "");out.println("</body>"); out.println("</html>"); try { GenericDelegator delegator; StringBuilder xmlString = new StringBuilder(); List productStoresList = new Vector(); try { delegator = GenericDelegator.getGenericDelegator("default"); productStoresList = delegator.findAll("ProductStore"); Iterator itera = productStoresList.iterator(); Map newmap; xmlString.append("<ProductStores>"); while (itera.hasNext()) { xmlString.append("<ProductStore>"); GenericEntity elem = (GenericEntity) itera.next(); newmap = new HashMap(); newmap = elem.getAllFields(); Set returnMap = newmap.entrySet(); for (Iterator i1 = returnMap.iterator(); i1.hasNext();) { Entry en = (Entry) i1.next(); xmlString.append("<" + en.getKey().toString() + ">"); xmlString.append(en.getValue()); xmlString.append("</" + en.getKey().toString() + ">"); } xmlString.append("</ProductStore>"); } xmlString.append("</ProductStores>"); } catch (Exception exe) { exe.printStackTrace(); } System.out.println(xmlString.toString()); out.println(xmlString.toString()); } finally { out.close(); } } // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> /** * Handles the HTTP <code>GET</code> method. * @param request servlet request * @param response servlet response */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP <code>POST</code> method. * @param request servlet request * @param response servlet response */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. */ public String getServletInfo() { return "Short description"; } // </editor-fold> } when i calling the servlet ,there is something wrong information in the console. java.lang.ClassCastException: org.ofbiz.geronimo.GeronimoTransactionFactory at org.ofbiz.entity.transaction.TransactionFactory.getTransactionFactory (TransactionFactory.java:67) at org.ofbiz.entity.transaction.TransactionFactory.getUserTransaction(Tr ansactionFactory.java:90) at org.ofbiz.entity.transaction.TransactionUtil.begin(TransactionUtil.ja va:67) at org.ofbiz.entity.transaction.TransactionUtil.begin(TransactionUtil.ja va:58) at org.ofbiz.entity.GenericDelegator.findCountByCondition(GenericDelegat or.java:1854) at org.ofbiz.entity.GenericDelegator.findCountByCondition(GenericDelegat or.java:1845) at org.ofbiz.entity.GenericDelegator.findCountByAnd(GenericDelegator.jav a:1840) at org.ofbiz.entity.util.EntityCrypto.<init>(EntityCrypto.java:62) at org.ofbiz.entity.GenericDelegator.<init>(GenericDelegator.java:200) at org.ofbiz.entity.GenericDelegator.getGenericDelegator(GenericDelegato r.java:119) at qiya.deng.servlet.ViewMethod.processRequest(ViewMethod.java:56) at qiya.deng.servlet.ViewMethod.doGet(ViewMethod.java:99) at javax.servlet.http.HttpServlet.service(HttpServlet.java:595) at javax.servlet.http.HttpServlet.service(HttpServlet.java:688) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:107) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java: 541) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav a:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p rocessConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo int.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol lowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP ool.java:684) at java.lang.Thread.run(Thread.java:595) |
Administrator
|
Please use user ML for such question : it's explained here
http://docs.ofbiz.org/display/OFBADMIN/Mailing+Lists#MailingLists-DeveloperList:dev@... Jacques De : "qiyadeng" <[hidden email]> > > I create a new component in the hot-deploy. > first, i just add a index.jsp in the component's webapp,everything is ok. > > I want to test the GenericDelegator ,so I create a servlet for test. > > this is servlet code: > > /* > * To change this template, choose Tools | Templates > * and open the template in the editor. > */ > > package qiya.deng.servlet; > > import java.io.*; > import java.net.*; > > import java.util.HashMap; > import java.util.Iterator; > import java.util.List; > import java.util.Map; > import java.util.Map.Entry; > import java.util.Set; > import java.util.Vector; > import javax.servlet.*; > import javax.servlet.http.*; > import org.ofbiz.entity.GenericDelegator; > import org.ofbiz.entity.GenericEntity; > > /** > * > * @author qiya > */ > public class ViewMethod extends HttpServlet { > > /** > * Processes requests for both HTTP <code>GET</code> and > <code>POST</code> methods. > * @param request servlet request > * @param response servlet response > */ > protected void processRequest(HttpServletRequest request, > HttpServletResponse response) > throws ServletException, IOException { > response.setContentType("text/html;charset=UTF-8"); > PrintWriter out = response.getWriter(); > > > out.println("<html>"); > out.println("<head>"); > out.println("<title>Servlet ViewMethod</title>"); > out.println("</head>"); > out.println("<body>"); > out.println("<h1>Servlet ViewMethod at " + > request.getContextPath () + "</h1>"); > out.println("</body>"); > out.println("</html>"); > > > try { > > GenericDelegator delegator; > StringBuilder xmlString = new StringBuilder(); > List productStoresList = new Vector(); > try { > delegator = GenericDelegator.getGenericDelegator("default"); > productStoresList = delegator.findAll("ProductStore"); > > Iterator itera = productStoresList.iterator(); > Map newmap; > xmlString.append("<ProductStores>"); > while (itera.hasNext()) { > xmlString.append("<ProductStore>"); > GenericEntity elem = (GenericEntity) itera.next(); > newmap = new HashMap(); > newmap = elem.getAllFields(); > > Set returnMap = newmap.entrySet(); > for (Iterator i1 = returnMap.iterator(); i1.hasNext();) { > > Entry en = (Entry) i1.next(); > xmlString.append("<" + en.getKey().toString() + ">"); > xmlString.append(en.getValue()); > xmlString.append("</" + en.getKey().toString() + ">"); > } > xmlString.append("</ProductStore>"); > } > xmlString.append("</ProductStores>"); > } catch (Exception exe) { > exe.printStackTrace(); > } > System.out.println(xmlString.toString()); > out.println(xmlString.toString()); > > > } finally { > out.close(); > } > } > > // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. > Click on the + sign on the left to edit the code."> > /** > * Handles the HTTP <code>GET</code> method. > * @param request servlet request > * @param response servlet response > */ > protected void doGet(HttpServletRequest request, HttpServletResponse > response) > throws ServletException, IOException { > processRequest(request, response); > } > > /** > * Handles the HTTP <code>POST</code> method. > * @param request servlet request > * @param response servlet response > */ > protected void doPost(HttpServletRequest request, HttpServletResponse > response) > throws ServletException, IOException { > processRequest(request, response); > } > > /** > * Returns a short description of the servlet. > */ > public String getServletInfo() { > return "Short description"; > } > // </editor-fold> > } > > > > when i calling the servlet ,there is something wrong information in the > console. > > > java.lang.ClassCastException: org.ofbiz.geronimo.GeronimoTransactionFactory > at > org.ofbiz.entity.transaction.TransactionFactory.getTransactionFactory > (TransactionFactory.java:67) > at > org.ofbiz.entity.transaction.TransactionFactory.getUserTransaction(Tr > ansactionFactory.java:90) > at > org.ofbiz.entity.transaction.TransactionUtil.begin(TransactionUtil.ja > va:67) > at > org.ofbiz.entity.transaction.TransactionUtil.begin(TransactionUtil.ja > va:58) > at > org.ofbiz.entity.GenericDelegator.findCountByCondition(GenericDelegat > or.java:1854) > at > org.ofbiz.entity.GenericDelegator.findCountByCondition(GenericDelegat > or.java:1845) > at > org.ofbiz.entity.GenericDelegator.findCountByAnd(GenericDelegator.jav > a:1840) > at org.ofbiz.entity.util.EntityCrypto.<init>(EntityCrypto.java:62) > at > org.ofbiz.entity.GenericDelegator.<init>(GenericDelegator.java:200) > at > org.ofbiz.entity.GenericDelegator.getGenericDelegator(GenericDelegato > r.java:119) > at qiya.deng.servlet.ViewMethod.processRequest(ViewMethod.java:56) > at qiya.deng.servlet.ViewMethod.doGet(ViewMethod.java:99) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:595) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:688) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl > icationFilterChain.java:252) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF > ilterChain.java:173) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV > alve.java:213) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextV > alve.java:178) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j > ava:126) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j > ava:105) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal > ve.java:107) > at > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java: > 541) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav > a:148) > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java > :869) > at > org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p > rocessConnection(Http11BaseProtocol.java:664) > at > org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo > int.java:527) > at > org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol > lowerWorkerThread.java:80) > at > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP > ool.java:684) > at java.lang.Thread.run(Thread.java:595) > > > > -- > View this message in context: > Sent from the OFBiz - Dev mailing list archive at Nabble.com. > |
Free forum by Nabble | Edit this page |