是否可以通过servlet 3.0注释从标准web.xml文件设置welcome-file标签?
<welcome-file-list>
<welcome-file>PageName.html</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud) 使用ejb 3.1,servlet 3.0(glassfish服务器v3)
场景:我有MDB,它监听jms消息并处理其他会话bean(无状态).Servelet注入jms资源.
问题1:为什么servlet在使用静态声明时不能注入jms资源?
@Resource(mappedName = "jms/Tarturus")
private static ConnectionFactory connectionFactory;
@Resource(mappedName = "jms/StyxMDB")
private static Queue queue;
private Connection connection;
Run Code Online (Sandbox Code Playgroud)
和
@PostConstruct
public void postConstruct() {
try {
connection = connectionFactory.createConnection();
} catch (JMSException e) {
e.printStackTrace();
}
}
@PreDestroy
public void preDestroy() {
try {
connection.close();
} catch (JMSException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
[#| 2010-05-03T15:18:17.118 + 0300 |警告| glassfish3.0 | javax.enterprise.system.container.web.com.sun.enterprise.web | _ThreadID = 35; _ThreadName =线程1; | StandardWrapperValve [WorkerServlet]:PWC1382:为servlet WorkerServlet分配异常com.sun.enterprise.container.common.spi.util.InjectionException:在com.sun上为类ua.co.rufous.server.services.WorkerServiceImpl创建托管对象时出错.企业.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:312)位于com.sun.enterprise.web.WebModule的com.sun.enterprise.web.WebContainer.createServletInstance(WebContainer.java:709). createServletInstance(WebModule.java:1937)at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1252)引起:com.sun.enterprise.container.common.spi.util.InjectionException:异常尝试注入未解决的Message-Destination-Ref ua.co.rufous.server.services.WorkerServiceImpl/queue @ …