我刚刚开始学习Apache Tomcat,我刚刚安装它,我试图运行一个特定的Java程序/类来等待/侦听来自php post请求的数据,下面是代码。我称这个班为Listener.java
package matchfaces;
public class Listener {
public static final String JAVABRIDGE_PORT = "1699";//8080
static final php.java.bridge.JavaBridgeRunner runner =
php.java.bridge.JavaBridgeRunner.getInstance(JAVABRIDGE_PORT);
public static void main() {
// TODO code application logic here
try {
System.loadLibrary("facesdk");
int res = FSDK
.ActivateLibrary("LICENCE KEY");
FSDK.Initialize();
FSDK.SetFaceDetectionParameters(true, true, 384);
FSDK.SetFaceDetectionThreshold(5);
if (res == FSDK.FSDKE_OK) {
System.out.println("FaceSDK activated\n");
} else {
System.out.println("Error activating FaceSDK: " + res + "\n");
}
} catch (java.lang.UnsatisfiedLinkError e) {
System.out.println("exception " + e.getMessage());
}
runner.waitFor();
}
}
经过大量研究后,我尝试了几件事,但现在看来,我需要的库不会被加载,从而引发异常。我的web.xml
如下
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Match Faces</servlet-name>
<servlet-class>matchfaces.Listener</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Match Faces</servlet-name>
<url-pattern>/matchfaces</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<listener>
<listener-class>ViewHandler.handler</listener-class>
</listener>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
所以我使用了一个监听器,所以在Tomcat启动服务器上它会触发Web应用程序java类Listener.java
public class handler implements javax.servlet.ServletContextListener{
@Override
public void contextInitialized(ServletContextEvent sce) {
try {
Listener listen = new Listener();
listen.main();
} catch (InterruptedException ex) {
Logger.getLogger(Listener.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
我得到的错误就是这个
异常没有java.library.path中的facesdk
答案 0 :(得分:1)
您遇到的主要问题是facesdk.dll
,似乎您没有提供loadLibrary
库的路径。但是,不要在catalina.bat
方法中说明路径,只需转到:noJuliManager
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%
文件,然后在set JAVA_OPTS="-Djava.library.path=%CATALINA_BASE%\lib"
下方添加$(function() {
var chart = new Highcharts.Chart({
chart: {
renderTo: "container",
type: "column",
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [{
data: [4, 14, 18, 5, 6, 5]
}, {
data: [4, 14, 18, 5, 6, 5]
}, {
data: [4, 14, 18, 5, 6, 5]
}],
xAxis: {
categories: [{
name: "Fruit",
categories: ["Apple", "Banana"]
}, {
name: "Vegetable",
categories: ["Carrot", "Potato"]
}, {
name: "Fish",
categories: ["Cod", "Salmon"]
}]
}
});
});
这应该可以正常工作。