2

I'm getting an NPE when using the ConfigurableWroManagerFactory wroManagerFactory and can't seem to trace down the cause. It seems that Context.get().getFilterConfig(); returns null..

Stacktrace (this is the root cause of 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 is 1.7.0

Plugin entry in my 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>

and my 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
jlb
  • 19,090
  • 8
  • 34
  • 65

1 Answers1

2

When using the build-time solution (maven plugin), you should use

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

Notice that this class is in a different package the the one used by you. Also, try upgrading to version 1.7.1.

Alex Objelean
  • 3,893
  • 2
  • 27
  • 36
  • Thanks. Changing to use the `...maven.plugin.manager.` package did the trick~ – jlb Sep 27 '13 at 13:04
  • How much of the `wro.properties` configuration is shared with the maven plugin? For example, do I need to specify `` in the pom plugin if it already exists in `wro.properties`? – jlb Sep 27 '13 at 13:08
  • The one from the pom plugin configuration takes precedence to the one from wro.properties. I know this is confusing and probably this is something can be improved in the future. – Alex Objelean Sep 27 '13 at 13:13
  • Update: even more, the property from wro.properties is always overriden by the one from plugin configuration in pom.xml. – Alex Objelean Sep 27 '13 at 13:16
  • Ok, that makes sense. Just to confirm -- does it fall back on the `wro.properties` option if it doesn't exist in the `pom.xml` plugin configuration? – jlb Sep 27 '13 at 13:28
  • When this property doesn't exist in pom.xml, it is defaulted to true. In the end, it doesn't matter what you put in wro.properties, since the default value will override it. – Alex Objelean Sep 27 '13 at 14:05
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/38186/discussion-between-alex-objelean-and-jlb) – Alex Objelean Sep 27 '13 at 14:16