尝试使用ConnectionFactory注入Res-Ref-Env-Property的异常

时间:2019-03-29 12:13:14

标签: java netbeans jms

使用Netbeans IDE + Glassfish服务器运行应用程序时,出现以下错误:

java.lang.IllegalStateException: Exception attempting to inject Res-Ref-Env-Property: web.PostRecords/connectionFactory@javax.jms.ConnectionFactory@ resolved as: jndi: jms/NewMessageFactory@res principal: null@mail: null No Runtime properties Database Vendor : null Create Tables at Deploy : false Delete Tables at Undeploy : false into class web.PostRecords: Lookup failed for 'java:comp/env/web.PostRecords/connectionFactory' in SerialContext[myEnv=

我知道它与JMS连接工厂设置或试图连接到它的代码有关,但无法确切地找出问题所在。这是尝试连接到它的代码以及我的JMS连接工厂的设置。

    @Resource(mappedName="jms/NewMessageFactory")
    private ConnectionFactory connectionFactory;

    @Resource(mappedName="jms/NewMessage")
    private Queue queue;

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");

        String recordName=request.getParameter("recordName");
        String artistName=request.getParameter("artistName");
        if ((recordName!=null) && (artistName!=null)) {
            try {
                Connection connection = connectionFactory.createConnection();
                Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                MessageProducer messageProducer = session.createProducer(queue);

enter image description here

enter image description here

0 个答案:

没有答案