无法在wro4j-maven-plugin(NPE)中使用ConfigurableWroManagerFactory

时间:2013-09-27 09:15:35

标签: java maven wro4j

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

Stacktrace(这是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

1 个答案:

答案 0 :(得分:2)

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

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

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