GWT:Log4j问题

时间:2012-04-30 14:27:45

标签: java gwt log4j

我一直在与这个问题作斗争超过48小时。所以我开发了一个gwt应用程序,然后我决定使用GAE数据存储(实体)为它添加持久性,一切运行良好,所以我决定使用JPA来减少我使用实体编写的代码量。

我遇到了datanucleus的问题,很多!!直到我甚至无法启动我的应用程序。我已经尝试了很多新的配置,现在我陷入了困境之中。

我碰到了这个pom所以我决定使用,我删除了我不需要的东西,因为它们在编译时打破了。

此刻。我可以编译并运行没有问题但是当请求通过GWT时,我得到了这个奇怪的异常

2012-04-30 14:02:45.175:WARN::Error for /LottoShop/lottoService
java.lang.Error: Unresolved compilation problem: |?The import org.apache.log4j cannot be resolved|
        at co.za.cre8.web.lottoShop.server.LottoServiceImpl.<init>(LottoServiceImpl.java:11)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
        at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
        at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
        at co.za.cre8.web.lottoShop.server.GWTCacheControlFilter.doFilter(GWTCacheControlFilter.java:49)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
        at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:351
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
2012-04-30 14:02:45.195:WARN::Error for /LottoShop/lottoService

只有一个import org.apache.log4j导入,因为该类LottoService中没有。

这就是我的dependecy树的样子:

[INFO] Building GWT Maven Archetype
[INFO]    task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree {execution: default-cli}]
[INFO] co.za.cre8.web:lottoShop:war:0.0.1-SNAPSHOT
[INFO] +- net.sourceforge:rsslib4j:jar:0.2:compile
[INFO] +- org.jsoup:jsoup:jar:1.6.2:compile
[INFO] +- com.google.appengine:appengine-api-1.0-sdk:jar:1.5.3:compile
[INFO] +- com.allen-sauer.gwt.log:gwt-log:jar:3.1.6:compile
[INFO] |  \- com.google.gwt:gwt-user:jar:2.4.0:compile
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- org.apache.commons:commons-math:jar:2.2:compile
[INFO] +- junit:junit:jar:4.7:test
[INFO] +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] +- javax.validation:validation-api:jar:sources:1.0.0.GA:compile
[INFO] +- log4j:log4j:jar:1.2.16:compile
[INFO] +- org.scribe:scribe:jar:1.3.0:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.4:compile
[INFO] +- com.google.appengine.orm:datanucleus-appengine:jar:1.0.8:compile
[INFO] +- org.datanucleus:datanucleus-core:jar:1.1.5:compile
[INFO] +- org.datanucleus:datanucleus-jpa:jar:1.1.5:compile
[INFO] |  \- org.apache.geronimo.specs:geronimo-jpa_3.0_spec:jar:1.1.1:compile
[INFO] +- org.datanucleus:datanucleus-rdbms:jar:1.1.5:compile
[INFO] |  \- javax.transaction:transaction-api:jar:1.1:compile
[INFO] +- org.datanucleus:datanucleus-enhancer:jar:1.1.4:compile
[INFO] |  \- asm:asm:jar:3.3.1:compile
[INFO] +- javax.jdo:jdo2-api:jar:2.3-eb:compile
[INFO] +- org.hibernate:hibernate-validator:jar:4.0.2.GA:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.5.6:compile
[INFO] +- cglib:cglib-nodep:jar:2.2:compile
[INFO] +- javax.transaction:jta:jar:1.1:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.0.3.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:3.0.3.RELEASE:compile
[INFO] |  +- org.springframework:spring-core:jar:3.0.3.RELEASE:compile
[INFO] |  |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] |  \- org.springframework:spring-tx:jar:3.0.3.RELEASE:compile
[INFO] |     \- org.springframework:spring-aop:jar:3.0.3.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.0.3.RELEASE:compile
[INFO] +- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] +- commons-dbcp:commons-dbcp:jar:1.3:compile
[INFO] +- org.springframework:spring-web:jar:3.0.3.RELEASE:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  \- org.springframework:spring-context:jar:3.0.3.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.0.3.RELEASE:compile
[INFO] |  +- org.springframework:spring-asm:jar:3.0.3.RELEASE:compile
[INFO] |  +- org.springframework:spring-context-support:jar:3.0.3.RELEASE:compile
[INFO] |  \- org.springframework:spring-expression:jar:3.0.3.RELEASE:compile
[INFO] +- org.springframework.webflow:spring-js:jar:2.0.8.RELEASE:compile
[INFO] +- commons-digester:commons-digester:jar:2.0:compile
[INFO] |  \- commons-beanutils:commons-beanutils:jar:1.8.0:compile
[INFO] +- commons-fileupload:commons-fileupload:jar:1.2.1:compile
[INFO] +- org.tuckey:urlrewritefilter:jar:3.1.0:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- javax.el:el-api:jar:1.0:provided
[INFO] \- joda-time:joda-time:jar:1.6:compile

即使我通过删除依赖项中的log4j来使用slf4j,我也添加了以下内容:没有任何作用,同样的问题,当我查看Eclipse mvn依赖项时,日志库就在那里,甚至在

 <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.5.10</version>
</dependency>                
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>1.5.10</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.5.10</version>
</dependency>

添加了slf4j在WEB-INF / lib

中的证明

WEB-INF lib Folder

非常感谢您的协助,谢谢

1 个答案:

答案 0 :(得分:0)

你在类路径中添加了log4j吗? Slf4j只是一个Facade接口,从您使用的jar文件中,Slf4j需要找到log4j来生成日志信息。