gpt4 book ai didi

Java Wurfl 实现异常

转载 作者:行者123 更新时间:2023-11-30 08:18:47 25 4
gpt4 key购买 nike

我遇到了以下错误,请帮助我哪里做错了

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 在/web-inf/里面,我的 wurfl spring 配置在下面

    <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" />

上面实现的代码是

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());

显示的输出:

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

但是下面的代码报错了

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

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

请指教。

最佳答案

/web-inf/目录不在classpath中,导致抛出异常。

尝试将您的 wurfl.zip 放在 /web-inf/classes 中,以便正确加载它。

关于Java Wurfl 实现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27212851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com