早上好,
我有一个Java Adapter和一个REST方法尝试进行SQL查询,但我在这一行中有一个正确的错误:Connection con = ds.getConnection ();
错误如下:
[6/17/15 10:05:51:577 CEST] 00000076 com.worklight.adapters.rest.JAXRSSandbox E FWLSE03030E:错误期间 处理Java Adapter请求(参见日志)[项目 IBMConfirmingProject] java.lang.NullPointerException at com.confirming.ws.rest.MyAdapterCustomerResource.getTotalFact(MyAdapterCustomerResource.java:89)
在lib(server)文件夹中,我有jar:mysql-connector-java-5.1.35-bin.jar 在文件server.xml中,我有以下配置:
<library id="MySQLLib">
<fileset dir="C:\Desarrollo\Java\juno-4.2.2\workspace5\MyProject\server\lib" includes="mysql-connector-java-5.1.35-bin.jar"/>
</library>
<dataSource jndiName="jdbc/mobilefirst_training">
<jdbcDriver libraryRef="MySQLLib"/>
<properties databaseName="mobilefirst_training" password="mobilefirst" portNumber="3306" serverName="localhost" user="mobilefirst"/>
</dataSource>
日志还显示跟踪:
[ERROR] FWLSE03030E:处理Java Adapter请求时出错(参见日志)[project IBMConfirmingProject] 显示java.lang.NullPointerException [INFO] FFDC1015I:已创建FFDC事件:ffdc_15.06.17_11.57.08.0.log上的“java.lang.NullPointerException com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters 1105” [错误] SRVE0315E:发生异常:com.ibm.ws.webcontainer.webapp.WebAppErrorReport:java.lang.NullPointerException at ibm.confirming.ws.rest.MyAdapterCustomerResource.getTotalFact(MyAdapterCustomerResource.java:89) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
谢谢,
答案 0 :(得分:0)
我建议您按照教程中所述的Java SQL适配器说明进行操作:https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/server-side-development/java-adapter/java-sql-adapter/。
特别是,请按原样保留对MySQL连接器的引用:<fileset dir="${shared.resource.dir}" includes="mysql-*.jar" />
将文件放在这里:
答案 1 :(得分:0)
我刚看到,我缺少MyAdapterCustomerResource.init();在MyAdapterCustomerApplication中,非常感谢