2

我在使用ConfigurableWroManagerFactorywroManagerFactory 时遇到了 NPE,似乎无法追查原因。似乎Context.get().getFilterConfig();返回null..

Stacktrace(这是 a 的根本原因WroRuntimeException

Caused by: java.lang.NullPointerException
    at ro.isdc.wro.manager.factory.ConfigurableWroManagerFactory.updatePropertiesWithConfiguration(ConfigurableWroManagerFactory.java:202)
    at ro.isdc.wro.manager.factory.ConfigurableWroManagerFactory.access$000(ConfigurableWroManagerFactory.java:45)
    at ro.isdc.wro.manager.factory.ConfigurableWroManagerFactory$1.newProperties(ConfigurableWroManagerFactory.java:86)
    at ro.isdc.wro.model.resource.support.AbstractConfigurableStrategySupport.getProperties(AbstractConfigurableStrategySupport.java:136)
    at ro.isdc.wro.model.resource.support.AbstractConfigurableStrategySupport.getConfiguredValue(AbstractConfigurableStrategySupport.java:52)
    at ro.isdc.wro.model.resource.support.AbstractConfigurableMultipleStrategy.getConfiguredStrategies(AbstractConfigurableMultipleStrategy.java:52)
    at ro.isdc.wro.model.resource.locator.factory.ConfigurableLocatorFactory.newLocatorFactory(ConfigurableLocatorFactory.java:69)
    at ro.isdc.wro.model.resource.locator.factory.ConfigurableLocatorFactory.<init>(ConfigurableLocatorFactory.java:38)
    at ro.isdc.wro.manager.factory.ConfigurableWroManagerFactory$1.<init>(ConfigurableWroManagerFactory.java:82)
    at ro.isdc.wro.manager.factory.ConfigurableWroManagerFactory.newUriLocatorFactory(ConfigurableWroManagerFactory.java:82)
    at ro.isdc.wro.manager.factory.BaseWroManagerFactory$1.initialize(BaseWroManagerFactory.java:96)
    at ro.isdc.wro.manager.factory.BaseWroManagerFactory$1.initialize(BaseWroManagerFactory.java:73)
    at ro.isdc.wro.util.LazyInitializer.get(LazyInitializer.java:32)
    at ro.isdc.wro.manager.factory.BaseWroManagerFactory.create(BaseWroManagerFactory.java:156)
    at ro.isdc.wro.manager.factory.BaseWroManagerFactory.create(BaseWroManagerFactory.java:51)
    at ro.isdc.wro.maven.plugin.AbstractWro4jMojo.getWroManager(AbstractWro4jMojo.java:452)
    ... 26 more

wro4j.version是 1.7.0

我的插件条目pom.xml

        <plugin>
            <groupId>ro.isdc.wro4j</groupId>
            <artifactId>wro4j-maven-plugin</artifactId>
            <version>${wro4j.version}</version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <jsDestinationFolder>${project.build.directory}/${project.build.finalName}/static/js</jsDestinationFolder>
                <cssDestinationFolder>${project.build.directory}/${project.build.finalName}/static/css</cssDestinationFolder>
                <ignoreMissingResources>false</ignoreMissingResources>
                <wroManagerFactory>ro.isdc.wro.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
            </configuration>
        </plugin>

和我的wro.properties

#If true, it is DEVELOPMENT mode, by default this value is true
debug=true
# Default is true
gzipEnabled=true

# MBean name to be used if JMX is enabled
#mbeanName=wro
#jmxEnabled=true

# Default is 0
cacheUpdatePeriod=0
# Default is 0
modelUpdatePeriod=0
# Default is false.
disableCache=false
# Default is UTF-8
encoding=UTF-8

managerFactoryClassName=ro.isdc.wro.manager.factory.ConfigurableWroManagerFactory
preProcessors=jsLint,lessCssImport,cssUrlRewriting,cssImport,semicolonAppender
postProcessors=googleClosureSimple,less4j

resourceWatcherUpdatePeriod=5
4

1 回答 1

2

使用构建时解决方案(maven 插件)时,您应该使用

ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory

请注意,此类位于与您使用的不同的包中。另外,尝试升级到版本 1.7.1。

于 2013-09-27T12:07:25.840 回答