Glassfish和RESTful webservice的简单JMS示例响应404错误

时间:2018-03-12 16:00:39

标签: java xml rest glassfish ejb

我目前正在使用Glassfish 4与教程Simple JMS example with Glassfish and a RESTful webservice使用Jersey 2 Servlet容器(不是教程中的Jersey 1)而不使用Maven。

最终出现错误404.应用程序已成功部署,我不知道为什么会收到错误。

当我查看我的glassfish目录时,应该在某处部署应用程序。它可能在glassfish/domains/domain1/applications/__internal/JMS1/..,但此目录为空。

更新

我发现glassfish在glassfish/domains/domain1/eclipseApps/JMS1/..部署了eclipse生成的应用程序。因此,应用程序已成功部署。

我做错了什么?我只是访问了一个错误的URL或类似的东西吗?

这是我的代码

日志

2018-03-12T16:34:32.824+0100|Information: Server shutdown initiated
2018-03-12T16:34:32.843+0100|Information: Unregistered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl@3071d086 from service registry.
2018-03-12T16:34:32.844+0100|Information: FileMonitoring shutdown
2018-03-12T16:34:32.853+0100|Information: JMXStartupService: Stopped JMXConnectorServer: null
2018-03-12T16:34:32.854+0100|Information: JMXStartupService and JMXConnectors have been shut down.
2018-03-12T16:34:33.034+0100|Schwerwiegend: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@5a3b7ca7]) and a value of type [org.glassfish.admingui.theme.AdminguiThemeContext] (value [org.glassfish.admingui.theme.AdminguiThemeContext@5431ce55]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
2018-03-12T16:34:33.035+0100|Schwerwiegend: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@5a3b7ca7]) and a value of type [org.glassfish.admingui.theme.AdminguiThemeContext] (value [org.glassfish.admingui.theme.AdminguiThemeContext@5431ce55]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
2018-03-12T16:34:33.036+0100|Schwerwiegend: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@5a3b7ca7]) and a value of type [org.glassfish.admingui.theme.AdminguiThemeContext] (value [org.glassfish.admingui.theme.AdminguiThemeContext@5431ce55]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
2018-03-12T16:34:33.036+0100|Schwerwiegend: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@5a3b7ca7]) and a value of type [org.glassfish.admingui.theme.AdminguiThemeContext] (value [org.glassfish.admingui.theme.AdminguiThemeContext@5431ce55]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
2018-03-12T16:34:33.037+0100|Schwerwiegend: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@5a3b7ca7]) and a value of type [org.glassfish.admingui.theme.AdminguiThemeContext] (value [org.glassfish.admingui.theme.AdminguiThemeContext@5431ce55]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
2018-03-12T16:34:33.142+0100|Information: JdbcRuntimeExtension,  getAllSystemRAResourcesAndPools = [GlassFishConfigBean.org.glassfish.jdbc.config.JdbcResource, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcResource, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcConnectionPool, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcConnectionPool]
2018-03-12T16:34:33.161+0100|Information: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter stopping...
2018-03-12T16:34:36.340+0100|Information: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter stopped.
2018-03-12T16:34:36.341+0100|Information: RAR7094: jmsra shutdown successful.
2018-03-12T16:35:22.889+0100|Information: Running GlassFish Version: GlassFish Server Open Source Edition  4.0  (build 89)
2018-03-12T16:35:22.892+0100|Information: Server log file is using Formatter class: com.sun.enterprise.server.logging.ODLLogFormatter
2018-03-12T16:35:23.016+0100|Information: SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
2018-03-12T16:35:23.017+0100|Information: SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
2018-03-12T16:35:23.022+0100|Information: SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
2018-03-12T16:35:23.426+0100|Information: Grizzly Framework 2.3.1 started in: 44ms - bound to [/0.0.0.0:8.080]
2018-03-12T16:35:23.508+0100|Information: Grizzly Framework 2.3.1 started in: 48ms - bound to [/0.0.0.0:8.181]
2018-03-12T16:35:23.516+0100|Information: Grizzly Framework 2.3.1 started in: 2ms - bound to [/0.0.0.0:4.848]
2018-03-12T16:35:23.791+0100|Information: Authorization Service has successfully initialized.
2018-03-12T16:35:23.833+0100|Information: Grizzly Framework 2.3.1 started in: 2ms - bound to [/0.0.0.0:3.700]
2018-03-12T16:35:24.140+0100|Information: visiting unvisited references
2018-03-12T16:35:24.693+0100|Information: visiting unvisited references
2018-03-12T16:35:24.927+0100|Information: visiting unvisited references
2018-03-12T16:35:25.020+0100|Information: visiting unvisited references
2018-03-12T16:35:25.033+0100|Information: visiting unvisited references
2018-03-12T16:35:25.604+0100|Information: SEC1002: Security Manager is OFF.
2018-03-12T16:35:25.604+0100|Information: SEC1010: Entering Security Startup Service
2018-03-12T16:35:25.606+0100|Information: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
2018-03-12T16:35:25.639+0100|Information: SEC1011: Security Service(s) Started Successfully
2018-03-12T16:35:25.822+0100|Information: this.makeModuleFor(org.glassfish.main.web.glue, null) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.web.glue [263]], State = [READY]
2018-03-12T16:35:25.822+0100|Information: this.makeModuleFor(org.glassfish.web.javax.servlet.jsp, null) returned OSGiModuleImpl:: Bundle = [org.glassfish.web.javax.servlet.jsp [149]], State = [READY]
2018-03-12T16:35:25.962+0100|Information: Created HTTP listener http-listener-1 on host/port 0.0.0.0:8080
2018-03-12T16:35:25.970+0100|Information: Created HTTP listener http-listener-2 on host/port 0.0.0.0:8181
2018-03-12T16:35:25.975+0100|Information: Created HTTP listener admin-listener on host/port 0.0.0.0:4848
2018-03-12T16:35:26.001+0100|Information: Created virtual server server
2018-03-12T16:35:26.003+0100|Information: Created virtual server __asadmin
2018-03-12T16:35:26.096+0100|Information: Setting JAAS app name glassfish-web
2018-03-12T16:35:26.097+0100|Information: Virtual server server loaded default web module 
2018-03-12T16:35:28.110+0100|Information: JTS5014: Recoverable JTS instance, serverId = [3700]
2018-03-12T16:35:28.706+0100|Information: JMS010: ADDRESSLIST in setJmsServiceProvider: mq://localhost:7676/
2018-03-12T16:35:28.706+0100|Information: JMS08: JMS Service Connection URL is : mq://localhost:7676/
2018-03-12T16:35:29.808+0100|Information: HV000001: Hibernate Validator 5.0.0.Final
2018-03-12T16:35:29.992+0100|Information: Grizzly Framework 2.3.1 started in: 2ms - bound to [/0.0.0.0:7.676]
2018-03-12T16:35:29.997+0100|Information: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter: Version:  5.0  (Build 14-e) Compile:  April 12 2013 0104
2018-03-12T16:35:29.997+0100|Information: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter starting: broker is EMBEDDED, connection mode is Direct
2018-03-12T16:35:32.907+0100|Information: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter Started:EMBEDDED
2018-03-12T16:35:32.945+0100|Information: JMS013: Assuming destination type javax.jms.Queue for MDB SimpleMessageDrivenBean from administered object SimpleQueue
2018-03-12T16:35:33.182+0100|Information: WELD-000900 2.0.0 (SP1)
2018-03-12T16:35:33.313+0100|Information: EJB5181:Portable JNDI names for EJB SimpleJMSRestfulWebService: [java:global/JMS1/restful-webservice/SimpleJMSRestfulWebService!de.datagroup.jms.SimpleJMSRestfulWebService, java:global/JMS1/restful-webservice/SimpleJMSRestfulWebService]
2018-03-12T16:35:34.231+0100|Warnung: Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
2018-03-12T16:35:34.231+0100|Warnung: Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled
2018-03-12T16:35:35.063+0100|Information: Initiating Jersey application, version Jersey: 2.0 2013-05-03 14:50:15...
2018-03-12T16:35:35.427+0100|Information: Loading application [JMS1#restful-webservice.war] at [restful-webservice]
2018-03-12T16:35:35.430+0100|Information: Loading application JMS1 done in 11.460 ms
2018-03-12T16:35:35.447+0100|Information: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
2018-03-12T16:35:35.457+0100|Information: GlassFish Server Open Source Edition  4.0  (89) startup time : Felix (2.316ms), startup services(12.652ms), total(14.968ms)
2018-03-12T16:35:35.597+0100|Information: Initiating Jersey application, version Jersey: 2.0 2013-05-03 14:50:15...
2018-03-12T16:35:37.138+0100|Information: Initiating Jersey application, version Jersey: 2.0 2013-05-03 14:50:15...
2018-03-12T16:35:37.295+0100|Information: Listening to REST requests at context: /management/domain.
2018-03-12T16:35:37.715+0100|Information: Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl@505bc480 as OSGi service registration: org.apache.felix.framework.ServiceRegistrationImpl@5120886f.
2018-03-12T16:35:37.835+0100|Information: JMXStartupService has started JMXConnector on JMXService URL service:jmx:rmi://NBC0403232.consinto.com:8686/jndi/rmi://NBC0403232.consinto.com:8686/jmxrmi
2018-03-12T16:35:37.927+0100|Information: visiting unvisited references
2018-03-12T16:35:38.086+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-common, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-common [48]], State = [READY]
2018-03-12T16:35:38.088+0100|Information: this.makeModuleFor(org.glassfish.hk2.hk2, 2.1.92) returned OSGiModuleImpl:: Bundle = [org.glassfish.hk2.hk2 [118]], State = [READY]
2018-03-12T16:35:38.088+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-plugin-service, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-plugin-service [58]], State = [READY]
2018-03-12T16:35:38.093+0100|Information: this.makeModuleFor(org.glassfish.main.deployment.deployment-client, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.deployment.deployment-client [67]], State = [READY]
2018-03-12T16:35:38.093+0100|Information: this.makeModuleFor(org.glassfish.main.registration.registration-api, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.registration.registration-api [230]], State = [READY]
2018-03-12T16:35:38.093+0100|Information: this.makeModuleFor(org.glassfish.main.registration.registration-impl, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.registration.registration-impl [231]], State = [READY]
2018-03-12T16:35:38.094+0100|Information: this.makeModuleFor(javax.servlet-api, 3.1.0) returned OSGiModuleImpl:: Bundle = [javax.servlet-api [147]], State = [READY]
2018-03-12T16:35:38.094+0100|Information: this.makeModuleFor(javax.servlet.jsp-api, 2.3.1) returned OSGiModuleImpl:: Bundle = [javax.servlet.jsp-api [148]], State = [READY]
2018-03-12T16:35:38.094+0100|Information: this.makeModuleFor(com.sun.el.javax.el, 3.0.0) returned OSGiModuleImpl:: Bundle = [com.sun.el.javax.el [132]], State = [READY]
2018-03-12T16:35:38.094+0100|Information: this.makeModuleFor(com.sun.jsftemplating, 2.1.0) returned OSGiModuleImpl:: Bundle = [com.sun.jsftemplating [186]], State = [READY]
2018-03-12T16:35:38.095+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.dataprovider, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.dataprovider [63]], State = [READY]
2018-03-12T16:35:38.095+0100|Information: this.makeModuleFor(com.sun.pkg.client, 1.0.0) returned OSGiModuleImpl:: Bundle = [com.sun.pkg.client [229]], State = [READY]
2018-03-12T16:35:38.095+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-cluster-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-cluster-plugin [46]], State = [READY]
2018-03-12T16:35:38.096+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-jts-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-jts-plugin [57]], State = [READY]
2018-03-12T16:35:38.096+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-corba-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-corba-plugin [51]], State = [READY]
2018-03-12T16:35:38.098+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-concurrent-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-concurrent-plugin [50]], State = [READY]
2018-03-12T16:35:38.098+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-jca-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-jca-plugin [54]], State = [READY]
2018-03-12T16:35:38.098+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-jdbc-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-jdbc-plugin [55]], State = [READY]
2018-03-12T16:35:38.098+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-jms-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-jms-plugin [56]], State = [READY]
2018-03-12T16:35:38.099+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-web-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-web-plugin [60]], State = [READY]
2018-03-12T16:35:38.099+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-common, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-common [48]], State = [READY]
2018-03-12T16:35:38.099+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-updatecenter-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-updatecenter-plugin [59]], State = [READY]
2018-03-12T16:35:38.099+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-community-branding-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-community-branding-plugin [49]], State = [READY]
2018-03-12T16:35:38.099+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-ejb-lite-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-ejb-lite-plugin [52]], State = [READY]
2018-03-12T16:35:38.099+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-ejb-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-ejb-plugin [53]], State = [READY]
2018-03-12T16:35:38.100+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-common-full-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-common-full-plugin [47]], State = [READY]
2018-03-12T16:35:38.202+0100|Information: visiting unvisited references
2018-03-12T16:35:38.220+0100|Information: visiting unvisited references
2018-03-12T16:35:38.222+0100|Information: visiting unvisited references
2018-03-12T16:35:38.302+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-common, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-common [48]], State = [READY]
2018-03-12T16:35:38.302+0100|Information: this.makeModuleFor(org.glassfish.hk2.hk2, 2.1.92) returned OSGiModuleImpl:: Bundle = [org.glassfish.hk2.hk2 [118]], State = [READY]
2018-03-12T16:35:38.303+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-plugin-service, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-plugin-service [58]], State = [READY]
2018-03-12T16:35:38.303+0100|Information: this.makeModuleFor(org.glassfish.main.deployment.deployment-client, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.deployment.deployment-client [67]], State = [READY]
2018-03-12T16:35:38.303+0100|Information: this.makeModuleFor(org.glassfish.main.registration.registration-api, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.registration.registration-api [230]], State = [READY]
2018-03-12T16:35:38.303+0100|Information: this.makeModuleFor(org.glassfish.main.registration.registration-impl, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.registration.registration-impl [231]], State = [READY]
2018-03-12T16:35:38.304+0100|Information: this.makeModuleFor(javax.servlet-api, 3.1.0) returned OSGiModuleImpl:: Bundle = [javax.servlet-api [147]], State = [READY]
2018-03-12T16:35:38.304+0100|Information: this.makeModuleFor(javax.servlet.jsp-api, 2.3.1) returned OSGiModuleImpl:: Bundle = [javax.servlet.jsp-api [148]], State = [READY]
2018-03-12T16:35:38.304+0100|Information: this.makeModuleFor(com.sun.el.javax.el, 3.0.0) returned OSGiModuleImpl:: Bundle = [com.sun.el.javax.el [132]], State = [READY]
2018-03-12T16:35:38.304+0100|Information: this.makeModuleFor(com.sun.jsftemplating, 2.1.0) returned OSGiModuleImpl:: Bundle = [com.sun.jsftemplating [186]], State = [READY]
2018-03-12T16:35:38.305+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.dataprovider, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.dataprovider [63]], State = [READY]
2018-03-12T16:35:38.305+0100|Information: this.makeModuleFor(com.sun.pkg.client, 1.0.0) returned OSGiModuleImpl:: Bundle = [com.sun.pkg.client [229]], State = [READY]
2018-03-12T16:35:38.305+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-cluster-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-cluster-plugin [46]], State = [READY]
2018-03-12T16:35:38.305+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-jts-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-jts-plugin [57]], State = [READY]
2018-03-12T16:35:38.305+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-corba-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-corba-plugin [51]], State = [READY]
2018-03-12T16:35:38.306+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-concurrent-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-concurrent-plugin [50]], State = [READY]
2018-03-12T16:35:38.306+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-jca-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-jca-plugin [54]], State = [READY]
2018-03-12T16:35:38.306+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-jdbc-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-jdbc-plugin [55]], State = [READY]
2018-03-12T16:35:38.306+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-jms-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-jms-plugin [56]], State = [READY]
2018-03-12T16:35:38.306+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-web-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-web-plugin [60]], State = [READY]
2018-03-12T16:35:38.307+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-common, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-common [48]], State = [READY]
2018-03-12T16:35:38.307+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-updatecenter-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-updatecenter-plugin [59]], State = [READY]
2018-03-12T16:35:38.307+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-community-branding-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-community-branding-plugin [49]], State = [READY]
2018-03-12T16:35:38.307+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-ejb-lite-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-ejb-lite-plugin [52]], State = [READY]
2018-03-12T16:35:38.307+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-ejb-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-ejb-plugin [53]], State = [READY]
2018-03-12T16:35:38.308+0100|Information: this.makeModuleFor(org.glassfish.main.admingui.console-common-full-plugin, 4.0.0) returned OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.console-common-full-plugin [47]], State = [READY]
2018-03-12T16:35:39.439+0100|Information: Mojarra 2.2.0 ( 20130502-2118 https://svn.java.net/svn/mojarra~svn/tags/2.2.0@11930) f�r Kontext '' wird initialisiert.
2018-03-12T16:35:40.902+0100|Information: Loading application [__admingui] at [/]
2018-03-12T16:35:40.903+0100|Information: Loading application __admingui done in 3.350 ms
2018-03-12T16:35:49.793+0100|Information: visiting unvisited references
2018-03-12T16:35:49.867+0100|Information: visiting unvisited references
2018-03-12T16:35:49.937+0100|Information: visiting unvisited references
2018-03-12T16:35:49.943+0100|Information: visiting unvisited references
2018-03-12T16:35:49.949+0100|Information: visiting unvisited references
2018-03-12T16:35:50.033+0100|Information: JMS013: Assuming destination type javax.jms.Queue for MDB SimpleMessageDrivenBean from administered object SimpleQueue
2018-03-12T16:35:50.072+0100|Information: EJB5181:Portable JNDI names for EJB SimpleJMSRestfulWebService: [java:global/JMS1/restful-webservice/SimpleJMSRestfulWebService!de.datagroup.jms.SimpleJMSRestfulWebService, java:global/JMS1/restful-webservice/SimpleJMSRestfulWebService]
2018-03-12T16:35:50.538+0100|Information: Initiating Jersey application, version Jersey: 2.0 2013-05-03 14:50:15...
2018-03-12T16:35:50.597+0100|Information: Loading application [JMS1#restful-webservice.war] at [restful-webservice]
2018-03-12T16:35:50.651+0100|Information: JMS1 was successfully deployed in 977 milliseconds.
2018-03-12T16:36:08.034+0100|Warnung: Context path from ServletContext: /restful-webservice differs from path from bundle: restful-webservice

SimpleJMSRestfulWebService

package de.datagroup.jms;

import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.NamingException;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.ws.rs.GET;
import javax.ws.rs.Path;

/**
* Example of a RESTful webservice producing messages for a JMS Queue.
* Call via <a href="http://localhost:8080/webservicetest/jms">http://localhost:8080/webservicetest/jms</a>
* @author Matthias Fraass
*/
@Stateless // dependency injection won't work without that
@Path("/jms")
public class SimpleJMSRestfulWebService {

    @Resource(mappedName = "SimpleConnectionFactory") //= connection factorie's JNDI name
    private ConnectionFactory connectionFactory;

    @Resource(mappedName = "SimpleQueue") //= Queue's JNDI name
    private Queue queue;

    /**
    * Our RESTful webservice
    */
    @GET
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public String putMessage() throws NamingException, JMSException, NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException {
        System.out.println("called putMessage");
        Connection connection = connectionFactory.createConnection();
        Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
        MessageProducer messageProducer = session.createProducer(queue);
        long start = System.currentTimeMillis();
        int i=0;
        do {
            TextMessage message = session.createTextMessage();
            message.setText("Hello, JMS! #"+start);
            messageProducer.send(message);
            i++;
        } while (i < 1000);
        long now = System.currentTimeMillis();
        return "JMS produced 1000 messages within " + (now-start) + "ms";
    }
}

SimpleMessageDrivenBean 包含在父项目JMS1中的EJB模块中(如教程中所示)

package de.datagroup.jms;

import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
* Simple message driven bean.
*/
@MessageDriven(mappedName = "SimpleQueue")
public class SimpleMessageDrivenBean implements MessageListener {

    /**
    * Default constructor.
    */
    public SimpleMessageDrivenBean() {

    }

    /**
    * @see MessageListener#onMessage(Message)
    */
    @Override
    public void onMessage(Message message) {
        try {
            System.out.println("Got message: " + ((TextMessage) message).getText() + " @" + System.currentTimeMillis());
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }

}

web.xml 泽西岛2.x不需要web.xml所以我将其删除了。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
  <display-name>restful-webservice</display-name>

    <servlet>
        <servlet-name>Jersey Web Application</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>org.glassfish.jersey.config.property.resourceConfigClass</param-name>
            <param-value>org.glassfish.jersey.api.core.PackagesResourceConfig</param-value>
        </init-param>
        <init-param>
            <param-name>org.glassfish.jersey.config.property.packages</param-name>
            <param-value>de.datagroup.jms</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Jersey Web Application</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

的glassfish-web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <context-root>/restful-webservice</context-root>
</glassfish-web-app>

2 个答案:

答案 0 :(得分:1)

我认为在您的glassfish-web.xml中,您已将context-root定义为'/ restful-webservice',而在其他地方将其定义为'restful-webservice'(没有初始正斜杠)。我认为他们应该全面保持一致。

答案 1 :(得分:0)

最后,我解决了这个问题。

我读到我需要一个扩展{strong>泽西2.x servlet容器Application类的类,所以我添加了以下类:

@ApplicationPath("/app")
public class JmsApplication extends Application {

    @Override
    public Set<Class<?>> getClasses() {
        final Set<Class<?>> classes = new HashSet<>();
        classes.add(SimpleJMSRestfulWebService.class);
        return classes;
    }
}

此类在Jersey 2.x下注册我的REST Web服务。最后,我删除了web.xml,我可以访问http://localhost:8080/restful-webservice/app/jms。显然,泽西岛1.x需要web.xml,泽西岛2.x不需要。

两种不同的机制!