- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用 java websocket api 实现两个 html 页面之间的简单视频传输。网络摄像头服务器捕获网络摄像头并将其发送到服务器端点,该端点向每个连接的客户端广播。网络摄像头服务器代码
<video autoplay id="vid" style="display: none;"></video>
<canvas id="canvas" width="640" height="480" style="border: 1px solid #d3d3d3;"></canvas>
<div id="data1"></div>
<script>
var video = document.querySelector("#vid");
var canvas = document.querySelector('#canvas');
var ctx = canvas.getContext('2d');
var localMediaStream = null;
var ws = new WebSocket("ws://127.0.0.1:8080/WebApplication5/endpointwcv");
ws.onopen = function () {
console.log("Openened connection to websocket");
};
ws.onerror = function (evt) {
writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
};
var onCameraFail = function (e) {
console.log('Camera did not work.', e);
};
timer = setInterval(function () {
ctx.drawImage(video, 0, 0, 640, 480);
var data = canvas.toDataURL('image/jpeg', 1.0);
ws.send(data);
}, 255);
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia({ video: true }, function (stream) {
video.src = window.URL.createObjectURL(stream);
}, onCameraFail);
服务器端点的代码 /* 在这里进口*/
@ServerEndpoint("/endpointwcv")
public class NewWSEndpoint {
private static Set<Session> peers = Collections.synchronizedSet(new HashSet<Session>());
@OnMessage
public String onMessage( Session session,byte[] data) {
try {
System.out.println(data);
for(Session s:peers){
s.getBasicRemote().sendObject(data);
}
} catch (IOException | EncodeException e) {
System.out.println("Error in facedetection, ignoring message:" + e.getMessage());
}
return null;
}
public String onMessage( Session session,String data) {
try {
System.out.println(data);
for(Session s:peers){
s.getBasicRemote().sendText(data);
}
} catch (IOException e) {
System.out.println("Error in facedetection, ignoring message:" + e.getMessage());
}
return null;
}
@OnOpen
public void onOpen(Session session) throws IOException {
peers.add(session);
session.getBasicRemote().sendText("hiiiiiii");
}
@OnClose
public void onClose() {
System.out.println("Closed");
}
@OnError
public void onError(Session s, Throwable t) {
System.out.println("error");
}
}
并且有一个接收客户端访问网络摄像头
<div id="d1"></div>
<canvas id="target" width="640" height="480" style="border: 1px solid #d3d3d3;"></canvas>
<script>
var ws = new WebSocket("ws://127.0.0.1:8080/WebApplication5/endpointwcv");
var myURL = window.URL || window.webkitURL;
ws.onopen = function () {
console.log("Openened connection to websocket");
};
ws.onmessage=function (msg) {
var target = document.getElementById("target");
url=myURL.createObjectURL(msg);
target.src = url;
};
</script>
使用 java ee 7 api 在 GlassFish 4.0 上运行项目时,没有任何反应。请帮助我。控制台上有一个警告
WARNING: Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
WARNING: Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled
......
Exception starting filter WebSocket filter
java.lang.InstantiationException
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:135)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:5297)
...
最佳答案
我在这里发现您的项目存在一些问题。首先,Struts 和 WebSocket 之间存在 URL 映射重叠。您的 WebSocket URL 是 /endpointwcv
。您的 Struts 映射是 /*
。当我最终部署您的应用程序时,我从 Struts 收到错误,说明操作 /endpointwcv
没有映射。
如果您将 Struts 过滤器 servlet 的映射更改为 /struts/*
(并且我必须将 filter-class
更改为 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
以避免有关 FilterDispatcher
已弃用的错误消息),您可以通过访问 http://localhost:808 来访问 WebSocket 端点0/WebApplication5/Conference.html
。在 GlassFish4 server.log 中,我看到来自 NewWSEndpoint
的输出:
INFO: aaaa
INFO: error
INFO: error
INFO: error
...
INFO: Closed
转到http://localhost:8080/WebApplication5/ConferenceClient.html
,我在server.log中看到:
INFO: aaaa
我不是 Struts 专家,但看起来您需要修复端点,然后弄清楚如何实现 Struts 前端,以便它不会干扰您的 WebSocket 端点 URL。
关于java - 异常启动过滤器WebSocket过滤器netbeans 7.3 glassfish 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17567021/
如何将 glassfish 服务器的所有配置保存到另一个 glassfish 服务器? 最佳答案 看到这个问题:GlassFish v3 - portability of settings glass
我安装了 JDK 1.6 b45 并尝试运行 glassfish v2.2。当我尝试启动它时,总是会抛出以下错误: [#|2013-06-18T08:50:20.196+0200|WARNING|su
glassfish 访问日志位于哪里?我希望它们位于domains/domainX/logs 中。我需要更改设置才能激活访问日志记录吗? 谢谢 最佳答案 路径似乎正确,请查看此链接 http://bl
我想在没有互联网连接的情况下升级 Glassfish。但我已经下载了最新版本。 我已完成以下步骤, 例如。 galssfish-3.0 是旧版本,glassfish-3.1 是新版本。 步骤:1我刚刚
我在 Windows 8.1 中启动 glassfishs 服务时遇到问题 我得到了这个错误: c:\glassfishv3\bin>asadmin 创建服务 Found the Windows Se
我们最近切换到 Glassfish 3.1.2.2,并将几个 Web 应用程序打包为 war 文件。有时,这些应用程序所需的上下文根不同于文件名。 回到我们使用 Weblogic 时,我们通过在 we
我只是测试在 glassfish 服务器队列上发送消息,因此我在 glassfish 服务器上创建了 JMSResource,如下所示: 现在我已经在 Netbeans IDE 中创建了一个 Java
我想知道 GlassFish 项目是死了还是还活着?从一开始,我就非常喜欢玻璃鱼。我开始使用 GlassFish2 进行项目,并且有很多客户使用 GlassFish3。 几个月以来,我尝试将我的一些项
我使用 Glassfish 应用服务器,根据 README 文件,它只是说打开 CMD,键入一些命令,但我得到了 Nullpointer。我需要有人帮助我。我在 Windows 上。 asadmin
我最近将 Glassfish 从 3.1.2 更新到 4.0,并想设置一个我以前在我的应用程序上使用过的 JDBCRealm,它使用基于 FORM 的身份验证。密码在数据库中使用 SHA-256 散列
您如何确定正在运行哪个版本的GlassFish服务器? 该命令: /var/glassfish/bin/asadmin version ...回: Version = Sun Java System
所以,基本上: 在 RHEL 6.2 和 Java 6 上有一个独立的(无集群)Glassfish 3.1.2 新安装,没有任何部署的应用程序(真正的新安装)。 我第一次在服务器上启动了默认域 dom
我有一个带有 Glassfish 应用程序服务器的 EJB WEB 应用程序。 现在我想要像这样“/”的上下文根。 我当前的网址是“http://localhost:8080/Make ” 但我想要这
我正在尝试在 Windows 7 64 位上安装带有 Eclipse 的 GlassFish 4。一切正常,但是当我尝试设置服务器 root 时会发生以下情况(目录存在): 最佳答案 Glassfis
如何使用密码文件更改 Glassfish 域的管理员密码?我知道在提示时手动输入密码的传统方法。 但是,我想使用脚本更改管理员密码,而无需手动输入密码。 最佳答案 这是可能的,但如果您想以最简单的方式
我想在Glassfish 3.1中设置JDBC领域,并且关注此博客http://blog.gamatam.com/2009/11/jdbc-realm-setup-with-glassfish-v3.
我在远程机器上运行 Glassfish。是否有从命令提示符以 Debug模式启动 GF 的命令?远程机器运行 Ubuntu 10.04,我的机器运行 Windows 7(不确定这是否重要)。 我连接没
我们每周都会发布新的生产代码,Glassfish 没有遇到任何问题。这个周末我们不得不在我们的托管服务提供商处移动机架。没有任何代码更改(它们只是关闭电源、移动、重新安装和打开电源)但是我们在一个新的
对于生产环境,Apache Geronimo 是否更适合使用 ActiveMQ、Derby、Solr 的应用程序? 最佳答案 简而言之,如果您想要一个轻量级部署容器,请使用 Geronimo(它基于
我正在尝试设置一个备用文档根目录,以便提供上传的文档。我已将以下内容包含在我的 glassfish web xml 中 /dom 然后,我在名为 cars.pdf 的 Test 文件夹中存储了一
我是一名优秀的程序员,十分优秀!