0

我正在尝试在 glassfish 上部署由模块 ejb 和战争组成的 EAR 应用程序。应用程序已部署,但有一个异常连接到我的 Web 模块中的过滤器。每次服务器尝试启动过滤器时都会抛出它。

但为什么?我看不出有任何明显的原因!任何帮助将非常感激。

添加信息:我用 maven 编译和部署

过滤器类和映射:

public class FrontControllerFilter implements Filter {


@Override
public void init(FilterConfig fc) throws ServletException {
}

@Override
public void doFilter(ServletRequest request,
        ServletResponse response,
        FilterChain filterChain)
        throws IOException, ServletException {
    // Přetypujeme na HTTP objekty
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    HttpServletResponse httpResponse = (HttpServletResponse) response;
    //some code
}
//some code
}

<filter>
    <filter-name>FrontControllerFilter</filter-name>
    <filter-class>com.myapp.controller.FrontControllerFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>FrontControllerFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

异常跟踪:

[#|2011-06-21T12:25:18.545+0200|SEVERE|glassfish3.1|javax.enterprise.system.cont
ainer.web.com.sun.enterprise.web|_ThreadID=100;_ThreadName=admin-thread-pool-484
8(2);|WebModule[/web]PWC1270: Exception starting filter FrontControllerFilter
java.lang.InstantiationException
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFi
lterConfig.java:124)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.
java:4625)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:5
316)
        at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:917)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:90
1)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
        at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1
980)
        at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1
630)
        at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
        at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
        at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.jav
a:286)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationL
ifecycle.java:461)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationL
ifecycle.java:240)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.ja
va:370)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunner
Impl.java:360)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunner
Impl.java:370)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunner
Impl.java:1067)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunn
erImpl.java:96)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execut
e(CommandRunnerImpl.java:1247)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execut
e(CommandRunnerImpl.java:1235)
        at org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployComman
d.java:126)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunner
Impl.java:355)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunner
Impl.java:370)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunner
Impl.java:1067)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunn
erImpl.java:96)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execut
e(CommandRunnerImpl.java:1247)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execut
e(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
465)
        at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:22
2)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java
:168)
        at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java
:117)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(Container
Mapper.java:234)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:8
22)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFil
ter.java:225)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultPro
tocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.jav
a:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.jav
a:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java
:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextT
ask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.
java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadP
ool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool
.java:513)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: cz.pavel.javaee.webmail.controller.
FrontControllerFilter
        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoade
r.java:1518)
        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoade
r.java:1368)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(Applicatio
nFilterConfig.java:252)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFi
lterConfig.java:120)
        ... 47 more
|#]
4

2 回答 2

2

引起:java.lang.ClassNotFoundException:cz.pavel.javaee.webmail.controller。前端控制器过滤器

您的过滤器可能不在类路径上(或其名称错误)。

于 2011-06-21T11:03:53.923 回答
0

这可能是因为过滤器接口的导入错误。确保您已使用以下导入类

import javax.servlet.Filter

不是任何其他过滤器类。还有许多其他过滤器类在您使用它们时不会在编译时遇到错误。

于 2014-10-21T12:44:47.040 回答