javaspringwurfl

Java Wurfl Implementation Exception


I am getting following error and please help me where I am doing wrong

ERROR n.s.wurfl.core.GeneralWURFLEngine - cannot initialize: java.lang.NullPointerException: in is null
java.lang.NullPointerException: in is null
    at java.util.zip.ZipInputStream.<init>(ZipInputStream.java:100) ~[na:1.7.0_72]
    at java.util.zip.ZipInputStream.<init>(ZipInputStream.java:79) ~[na:1.7.0_72]
    at net.sourceforge.wurfl.core.resource.FileLoader.fromZipFile(FileLoader.java:248) ~[wurfl-1.5.jar:na]
    at net.sourceforge.wurfl.core.resource.FileLoader.openInputStream(FileLoader.java:230) ~[wurfl-1.5.jar:na]

wurfl.zip is inside /web-inf/ and my spring configuration for wurfl is below

    <bean id="net.sourceforge.wurfl.core.WURFLEngine" class="net.sourceforge.wurfl.core.GeneralWURFLEngine">        
    <constructor-arg index="0" value="classpath:/wurfl.zip" />
    <property name="engineTarget" value="performance" />

Code which is implementing above is

WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
WURFLEngine holder = (WURFLEngine)wac.getBean(WURFLEngine.class.getName());
System.out.println("debugging request: "+request+"  ==wurflholder: "+holder+ " Holder String "+holder.toString());

Output displayed:

debugging request: org.apache.catalina.core.ApplicationHttpRequest@133b7e9
==wurflholder: net.sourceforge.wurfl.core.GeneralWURFLEngine@6f28c4 
==Holder: String net.sourceforge.wurfl.core.GeneralWURFLEngine@6f28c4

But It is giving error on the following code

try{
    device = holder.getDeviceForRequest(request); //This is giving exception 

    }
    catch(Exception e ){e.printStackTrace();}

Please advise.


Solution

  • The /web-inf/ directory is not in the classpath, which is causing the exception to be thrown.

    Try placing your wurfl.zip in /web-inf/classes for it to be loaded properly.