8

我正在尝试使用 Spring 和 Quartz 的基本示例。这是我正在关注的教程:http ://www.mkyong.com/spring/spring-quartz-scheduler-example/

我已尽我所能复制所有内容,但在输出窗口中看不到任何内容。

spring-quartz.xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <bean id="runMeTask" class="com.ksc.jobs.RunMeTask" />

    <!-- Spring Quartz -->
    <bean name="runMeJob" class="org.springframework.scheduling.quartz.JobDetailBean">
        <property name="jobClass" value="com.ksc.jobs.RunMeJob" />
        <property name="jobDataAsMap">
            <map>
                <entry key="runMeTask" value-ref="runMeTask" />
            </map>
        </property>

    </bean>

    <bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        <property name="jobDetail" ref="runMeJob" />
        <property name="repeatInterval" value="5000" />
        <property name="startDelay" value="1000" />

    </bean>

    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="jobDetails">
            <list>
                <ref bean="runMeJob" />
            </list>
        </property>

        <property name="triggers">
            <list>
                <ref bean="simpleTrigger" />
            </list>
        </property>
    </bean>

</beans>

应用程序上下文.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <import resource="spring-quartz.xml"/>
</beans>

项目结构

在此处输入图像描述

编辑

我是否需要以某种方式手动启动工作?我在那个教程和其他教程中看到,他们通常在一个main()方法中开始一个石英工作。来自 .NET 背景,这对我来说有点奇怪,因为我只知道main桌面应用程序中的方法;不是网络应用程序。在 ASP.NET 中Global.asax,我们可以在 Web 应用程序启动时调用代码来运行。Java中有一些等价物吗?或者也许这根本不是问题?我只是在这里猜测。如果有人对如何解决这个问题有任何想法,甚至只是给我一个工作样本(甚至可以与上面的样本不同;我并不挑剔)......那么我将不胜感激。我只需要一个基本的工作示例,然后我可以根据我的要求进行修改。

编辑 2

这是 glassfish 服务器的输出,如果有帮助的话:

[注:由于本文正文长度过长,已删除。否则我将无法在下面发布编辑#3。]

编辑 3

取得了一些进展,但仍然没有工作。我已按照@shuttsy 的建议添加了 log4j 文件,这是 glassfish 的新输出:

Launching GlassFish on Felix platform
INFO: Running GlassFish Version: GlassFish Server Open Source Edition 3.1.2.2 (build 5)
INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
INFO: Grizzly Framework 1.9.50 started in: 0ms - bound to [0.0.0.0:3700]
INFO: Grizzly Framework 1.9.50 started in: 31ms - bound to [0.0.0.0:8080]
INFO: Grizzly Framework 1.9.50 started in: 15ms - bound to [0.0.0.0:8181]
INFO: Grizzly Framework 1.9.50 started in: 15ms - bound to [0.0.0.0:4848]
INFO: Grizzly Framework 1.9.50 started in: 0ms - bound to [0.0.0.0:7676]
INFO: The Admin Console is already installed, but not yet loaded.
INFO: GlassFish Server Open Source Edition 3.1.2.2 (5) startup time : Felix (1,750ms), startup services(771ms), total(2,521ms)
INFO: HV000001: Hibernate Validator 4.3.0.Final
INFO: JMX005: JMXStartupService had Started JMXConnector on JMXService URL service:jmx:rmi://Matt-Laptop:8686/jndi/rmi://Matt-Laptop:8686/jmxrmi
INFO: Grizzly Framework 1.9.50 started in: 0ms - bound to [0.0.0.0:8080]
INFO: Grizzly Framework 1.9.50 started in: 0ms - bound to [0.0.0.0:8181]
INFO: Created EjbThreadPoolExecutor with thread-core-pool-size 16 thread-max-pool-size 32 thread-keep-alive-seconds 60 thread-queue-capacity 2147483647 allow-core-thread-timeout false 
INFO: SEC1002: Security Manager is OFF.
INFO: SEC1010: Entering Security Startup Service
INFO: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
INFO: SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
INFO: SEC1011: Security Service(s) Started Successfully
INFO: WEB0169: Created HTTP listener [http-listener-1] on host/port [0.0.0.0:8080]
INFO: WEB0169: Created HTTP listener [http-listener-2] on host/port [0.0.0.0:8181]
INFO: WEB0169: Created HTTP listener [admin-listener] on host/port [0.0.0.0:4848]
INFO: WEB0171: Created virtual server [server]
INFO: WEB0171: Created virtual server [__asadmin]
INFO: WEB0172: Virtual server [server] loaded default web module []
SEVERE: Exception while visiting com/sun/gjc/spi/JdbcObjectsFactory.class of size 3615
java.lang.NullPointerException
    at org.glassfish.hk2.classmodel.reflect.impl.TypesImpl.getType(TypesImpl.java:78)
    at org.glassfish.hk2.classmodel.reflect.impl.ModelClassVisitor.visit(ModelClassVisitor.java:119)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:363)
    at org.glassfish.hk2.classmodel.reflect.util.JarArchive.onSelectedEntries(JarArchive.java:125)
    at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:348)
    at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:70)
    at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:307)
    at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:296)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

INFO: EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461
INFO: file:/C:/Users/Matt/Documents/NetBeansProjects/KSC/build/web/WEB-INF/classes/_KSCPU login successful
WARNING: Multiple [2] JMX MBeanServer instances exist, we will use the server at index [0] : [com.sun.enterprise.v3.admin.DynamicInterceptor@28245558].
WARNING: JMX MBeanServer in use: [com.sun.enterprise.v3.admin.DynamicInterceptor@28245558] from index [0] 
WARNING: JMX MBeanServer in use: [com.sun.jmx.mbeanserver.JmxMBeanServer@3a683b33] from index [1] 
SEVERE: log4j:ERROR log4j called after unloading, see http://logging.apache.org/log4j/1.2/faq.html#unload.
SEVERE: java.lang.IllegalStateException: Class invariant violation
    at org.apache.log4j.LogManager.getLoggerRepository(LogManager.java:199)
    at org.apache.log4j.LogManager.getLogger(LogManager.java:228)
    at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
    at org.springframework.beans.TypeConverterDelegate.<clinit>(TypeConverterDelegate.java:53)
    at sun.misc.Unsafe.ensureClassInitialized(Native Method)
    at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
    at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:140)
    at java.lang.reflect.Field.acquireFieldAccessor(Field.java:949)
    at java.lang.reflect.Field.getFieldAccessor(Field.java:930)
    at java.lang.reflect.Field.get(Field.java:372)
    at org.glassfish.web.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1833)
    at org.glassfish.web.loader.WebappClassLoader.stop(WebappClassLoader.java:1662)
    at org.glassfish.web.loader.WebappClassLoader.preDestroy(WebappClassLoader.java:1631)
    at org.glassfish.deployment.common.DeploymentContextImpl.getClassLoader(DeploymentContextImpl.java:236)
    at org.glassfish.deployment.common.DeploymentContextImpl.getClassLoader(DeploymentContextImpl.java:186)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:450)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.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(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)

SEVERE:     at org.apache.log4j.LogManager.getLoggerRepository(LogManager.java:199)
SEVERE:     at org.apache.log4j.LogManager.getLogger(LogManager.java:228)
SEVERE:     at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
SEVERE:     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
SEVERE:     at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
SEVERE:     at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
SEVERE:     at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
SEVERE:     at org.springframework.beans.TypeConverterDelegate.<clinit>(TypeConverterDelegate.java:53)
SEVERE:     at sun.misc.Unsafe.ensureClassInitialized(Native Method)
SEVERE:     at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
SEVERE:     at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:140)
SEVERE:     at java.lang.reflect.Field.acquireFieldAccessor(Field.java:949)
SEVERE:     at java.lang.reflect.Field.getFieldAccessor(Field.java:930)
SEVERE:     at java.lang.reflect.Field.get(Field.java:372)
SEVERE:     at org.glassfish.web.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1833)
SEVERE:     at org.glassfish.web.loader.WebappClassLoader.stop(WebappClassLoader.java:1662)
SEVERE:     at org.glassfish.web.loader.WebappClassLoader.preDestroy(WebappClassLoader.java:1631)
SEVERE:     at org.glassfish.deployment.common.DeploymentContextImpl.getClassLoader(DeploymentContextImpl.java:236)
SEVERE:     at org.glassfish.deployment.common.DeploymentContextImpl.getClassLoader(DeploymentContextImpl.java:186)
SEVERE:     at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:450)
SEVERE:     at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
SEVERE:     at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
SEVERE:     at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
SEVERE:     at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
SEVERE:     at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
SEVERE:     at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
SEVERE:     at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
SEVERE:     at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
SEVERE:     at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
SEVERE:     at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
SEVERE:     at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
SEVERE:     at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
SEVERE:     at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
SEVERE:     at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
SEVERE:     at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
SEVERE:     at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
SEVERE:     at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
SEVERE:     at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
SEVERE:     at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
SEVERE:     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
SEVERE:     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
SEVERE:     at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
SEVERE:     at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
SEVERE:     at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
SEVERE:     at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
SEVERE:     at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
SEVERE:     at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
SEVERE:     at java.lang.Thread.run(Thread.java:722)
INFO: EJB5181:Portable JNDI names for EJB EventApplicationService: [java:global/KSC/EventApplicationService!com.ksc.services.EventApplicationService, java:global/KSC/EventApplicationService]
INFO: EJB5181:Portable JNDI names for EJB SiteSettingService: [java:global/KSC/SiteSettingService!com.ksc.services.SiteSettingService, java:global/KSC/SiteSettingService]
INFO: EJB5181:Portable JNDI names for EJB EventsService: [java:global/KSC/EventsService, java:global/KSC/EventsService!com.ksc.services.EventsService]
INFO: EJB5181:Portable JNDI names for EJB UserService: [java:global/KSC/UserService, java:global/KSC/UserService!com.ksc.services.UserService]
INFO: EJB5181:Portable JNDI names for EJB RoleService: [java:global/KSC/RoleService!com.ksc.services.RoleService, java:global/KSC/RoleService]
INFO: EJB5181:Portable JNDI names for EJB AnnouncementService: [java:global/KSC/AnnouncementService!com.ksc.services.AnnouncementService, java:global/KSC/AnnouncementService]
INFO: EJB5181:Portable JNDI names for EJB UserInRoleService: [java:global/KSC/UserInRoleService, java:global/KSC/UserInRoleService!com.ksc.services.UserInRoleService]
INFO: WELD-000900 1.1.8 (Final)
INFO: PWC1412: WebModule[null] ServletContext.log():No Spring WebApplicationInitializer types detected on classpath
INFO: PWC1412: WebModule[null] ServletContext.log():Initializing Spring root WebApplicationContext
SEVERE: log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
SEVERE: log4j:WARN Please initialize the log4j system properly.
SEVERE: log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
INFO: PWC1412: WebModule[null] ServletContext.log():Initializing Spring FrameworkServlet 'dispatcher'
INFO: WEB0671: Loading application [KSC] at [/KSC]
INFO: KSC was successfully deployed in 10,070 milliseconds.

所以,我们这里有一个关于 Quartz 的新错误(可能与我原来的问题有关,也可能无关)。似乎该错误与 JDBC 相关。我正在使用 sqljdbc4 驱动程序: http: //www.microsoft.com/en-us/download/details.aspx? displaylang=en&id=11774

4

6 回答 6

2

您的 glassfish 输出表明您的 log4j 配置不正确。你有 log4j.properties 文件吗?尝试添加一个基本内容为:

log4j.rootLogger=INFO,stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %-5p - %m (%c)%n

Spring 将记录加载的 xml 文件和创建的 bean,但由于 log4j 问题,您没有获得此信息。

注意:您可以使用更简单的 Spring xml 获得相同的结果(即每 5 秒触发一次任务):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">

<bean id="runMeTask" class="com.mkyong.common.RunMeTask" />

<task:scheduled-tasks>
    <task:scheduled ref="runMeTask" method="printMe" cron="0/5 * * * * * " />
</task:scheduled-tasks>

试试这个,你现在得到你的输出了吗?

于 2012-12-19T14:21:20.433 回答
1

最后我找到了一个可行的解决方案!!!

基本上,我把里面的所有东西都拿走了,spring-quartz.xml然后把它卡在了我的dispatcher-servlet.xml里面……现在它正在运行……可爱……

我仍然想知道为什么其他方式不起作用。我猜要么:

  1. 该行:<import resource="spring-quartz.xml"/>没有工作..或:
  2. applicationContext.xml文件本身没有被加载..

我不是java专家,所以我不知道那个答案。如果有人有想法,请在此处发布。不管怎样,谢谢大家的尝试。:-)

于 2012-12-21T08:11:17.393 回答
1

是的,问题是 applicationContext.xml 文件没有加载。

在作为 Web 应用程序中,加载的默认配置文件是 -servlet.xml 文件。

通常,所有与 web 轮胎相关的 bean 都将在此配置文件中声明。

如果要加载单独的上下文文件,则需要在 web.xml 文件中指定它,例如:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/applicationContext.xml 
    </param-value>
</context-param>

<context-param>
    <param-name>contextClass</param-name>
    <param-value>
        org.springframework.web.context.support.XmlWebApplicationContext
    </param-value>
</context-param>

<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>

在您的情况下,您可以将其<import resource="spring-quartz.xml"/>移至dispatcher-servlet.xml或添加对applicationContext.xml文件的支持

于 2012-12-21T09:32:08.397 回答
0

我是否需要以某种方式手动启动工作?

不,您不需要手动启动它们。

于 2012-12-19T13:13:33.607 回答
0

尝试改变

<import resource="spring-quartz.xml"/>

<import resource="/WEB-INF/spring-quartz.xml"/>
于 2012-12-20T10:02:26.280 回答
0

在 Spring 配置之前,服务器跟踪中会出现异常。问题来自被窃听的 Glassfish 版本 3.1.2.2:看这里,您会发现与您的问题相同的问题: https : //java.net/jira/browse/GLASSFISH-18609 Glassfish 在启动时抛出 NullPointerException

另一个线索是地址http://logging.apache.org/log4j/1.2/faq.html#unload Apache log4j 团队正在讨论这个问题。他们建议:

  • 将 org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES 系统属性设置为 false。
  • 应用来自错误 40212 的补丁或升级到应用了该补丁的版本。
  • 升级到 log4j 1.2.16 或更高版本以更好地防御类加载器攻击或在它发生时提供更好的诊断消息。

我认为您将不得不使用更新版本的 Glashfish 和 Log4j。

希望它会有所帮助

于 2015-02-18T10:22:33.440 回答