成功部署到Glassfish。去运行它和
com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class com.wellpoint.mobility.aggregation.admin.HomeServlet
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:329)
at com.sun.enterprise.web.WebContainer.createServletInstance(WebContainer.java:983)
at com.sun.enterprise.web.WebModule.createServletInstance(WebModule.java:2130)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1404)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1211)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:237)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Env-Prop: com.wellpoint.mobility.aggregation.admin.FireboltServlet/entityManager@Field-Injectable Resource. Class name = com.wellpoint.mobility.aggregation.admin.FireboltServlet Field name=entityManager@java.lang.String@@@ into class com.wellpoint.mobility.aggregation.admin.FireboltServlet: Can not set javax.persistence.EntityManager field com.wellpoint.mobility.aggregation.admin.FireboltServlet.entityManager to com.wellpoint.mobility.aggregation.admin.HomeServlet
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:717)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:484)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:141)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:127)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:324)
... 30 more
Caused by: java.lang.IllegalArgumentException: Can not set javax.persistence.EntityManager field com.wellpoint.mobility.aggregation.admin.FireboltServlet.entityManager to com.wellpoint.mobility.aggregation.admin.HomeServlet
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:55)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:75)
at java.lang.reflect.Field.set(Field.java:741)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:665)
... 34 more
FireboltServlet是我们对HttpServlet的实现,我们所有的Servlet都扩展了该类。它有一个字段entityManager
@PersistenceContext(unitName = "persistenceUnit", type = PersistenceContextType.TRANSACTION)
private EntityManager entityManager;
...
public EntityManager getEntityManager()
{
if (entityManager == null)
{
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("persistenceUnit");
entityManager = entityManagerFactory.createEntityManager();
}
return entityManager;
}
public void setEntityManager(EntityManager entityManager)
{
this.entityManager = entityManager;
}
但我无法找到任何试图将HomeServlet映射到该字段的内容,也无法想象为什么会这样。这个例外似乎突然冒出来了,我还没有做出任何我能想象到的最近的变化。谢谢你的帮助!
答案 0 :(得分:-1)
有时服务器会冻结对象,主要是后者,因为它无法识别它,我所做的是创建一个幽灵方法来锁定和释放我需要编译和识别的对象。
当我不认识某种方法时,我会这样做。