Hello Stackoverflow社区,
我做了一个jsf projekt。随着maven。它工作正常。 但我想把我的项目分成两部分。 这个想法是:制作一个ejb(ejb)和一个web(战争)项目。但现在我不需要ejb(在以后的版本中我会)。我有一个类从gl服务器解析csv文件。
public class CSVParser implements javax.servlet.ServletContextListener{
private Logger logger = Logger.getLogger(CSVParser.class);
private final String file = "data.csv";
private static String glassfishInstanceRootPropertyName = "com.sun.aas.instanceRoot";
private static String glassfishFolderName = "csv";
private BufferedReader br;
private String line = "";
private String cvsSplitBy = ",";
private List<String> columns;
private List<String> parametersActLine;
private Feeler actFeeler = new Feeler();
public CSVParser() {
}
public void parseCSV() {
...
...
...}
...
...
@Override
public void contextInitialized(ServletContextEvent sce) {
parseCSV();
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
// TODO Auto-generated method stub
}
这是我开始解析的方式(web.xml):
<listener>
<listener-class>com.saphirwerk.configurator.util.CSVParser
</listener-class>
</listener>
正如我所说:这适用于我的jsf项目,但是当我将我的应用程序作为企业应用程序(ear)启动时,我遇到以下异常:
cannot Deploy configurator_ear
deploy is failing=Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class com.saphirwerk.configurator.util.CSVParser. Please see server.log for more details.
我将ejb项目添加到Web项目的构建路径中。
它有什么用?
由于
更新
堆栈跟踪:
2015-05-04T19:10:43.932+0200|Information: Mojarra 2.2.7 ( 20140610-1547 https://svn.java.net/svn/mojarra~svn/tags/2.2.7@13362) für Kontext '/configurator_ejb' wird initialisiert.
2015-05-04T19:10:44.262+0200|Information: Loading application [configurator_ear#configurator_ejb.war] at [configurator_ejb]
2015-05-04T19:10:44.306+0200|Schwerwiegend: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class com.saphirwerk.configurator.util.CSVParser
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5898)
at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:500)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class com.saphirwerk.configurator.util.CSVParser
at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:3302)
at org.apache.catalina.core.StandardContext.addApplicationListener(StandardContext.java:2508)
at com.sun.enterprise.web.TomcatDeploymentConfig.configureApplicationListener(TomcatDeploymentConfig.java:251)
at com.sun.enterprise.web.TomcatDeploymentConfig.configureWebModule(TomcatDeploymentConfig.java:110)
at com.sun.enterprise.web.WebModuleContextConfig.start(WebModuleContextConfig.java:264)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:486)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:163)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5895)
... 49 more
Caused by: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class com.saphirwerk.configurator.util.CSVParser
at org.apache.catalina.core.StandardContext.createListener(StandardContext.java:3423)
at org.apache.catalina.core.StandardContext.loadListener(StandardContext.java:5446)
at com.sun.enterprise.web.WebModule.loadListener(WebModule.java:1788)
at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:3300)
... 56 more
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class com.saphirwerk.configurator.util.CSVParser
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:352)
at com.sun.enterprise.web.WebContainer.createListenerInstance(WebContainer.java:1023)
at com.sun.enterprise.web.WebModule.createListenerInstance(WebModule.java:2158)
at org.apache.catalina.core.StandardContext.createListener(StandardContext.java:3421)
... 59 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:344)
... 62 more
Caused by: java.lang.NoClassDefFoundError: com/saphirwerk/configurator/model/Feeler
at com.saphirwerk.configurator.util.CSVParser.<init>(CSVParser.java:38)
... 67 more
Caused by: java.lang.ClassNotFoundException: com.saphirwerk.configurator.model.Feeler
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1783)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633)
... 68 more
我使用gl 4.1