2013-04-24 161 views
0

我有一个奇怪的问题。@InjectParam在tomcat上工作,但不在glassfish上工作。@InjectParam不按预期工作

这只是在玻璃鱼无效。 有什么原因?

公共类RestControllers {

private static Log log=LogFactory.getLog(RestControllers.class.getName()); 
@InjectParam 
private RulesController controller; 

当我说controller.getSomething()抛出NPE。

controller.getSomething仅在glassfish上抛出空指针异常。像tomcat上的梦一样工作。

问候,

阿维纳什Ç

+0

请提供更多信息,因为您会收到任何错误或内容。还提供一些相关的代码。 – 2013-04-24 10:26:05

回答

0

修正自己的问题。 GlassFish显然不支持泽西标注。

只是使用Spring的ApplicationContextAware接口来解决问题。在您的应用程序的context.xml

问候, 阿维纳什

0

如果您在使用Spring

1)请提及该注解驱动

<context:component-scan base-package="com.test.reports.controller"/> 
<context:annotation-config/> 
<mvc:annotation-driven/> 

2)使用Spring @Autowired 尝试在控制器中声明您的服务如下:

@Autowired ReportService reportService [如应用程序上下文的bean id]