JNI获取exception信息 – 尝试读取或写入受保护的内存

我正在使用以下代码尝试在java中获取类RWException(它扩展了Exception),以便我可以调用方法“getCode()”来检索错误代码(int)并正确处理错误。 我浏览了JNI文档并创建了以下代码…问题是当我尝试调用无参数方法getCode()时,我得到一个AccessViolationexception。 我得到了类的有效句柄和我正在寻找的方法ID。 jstring o = (jstring)envLoc->CallStaticObjectMethod(cls, mid, jstrUser, jstrPass, jstrGroup); jthrowable exc = envLoc->ExceptionOccurred(); if (exc) { // Get the class jclass mvclass = env->GetObjectClass( exc ); // Get method ID for method jmethodID mid = env->GetMethodID(mvclass, “getCode”, “()I”); // Call the method jint code = env->CallIntMethod(mvclass, mid); } 这个代码在使用以下信息调试inVS.NET时给了我一个例外: 尝试读取或写入受保护的内存 UPDATE这是我希望通过上面的JNI代码调用的java方法: public int […]

无法从Node 转换为Node ?

我只是从我的一本书中做了一些练习,我很好奇为什么我在eclipse中得到以下错误: Type mismatch: cannot convert from type DoublyLinkedList.Node to DoublyLinkedList.Node 码: import java.util.Iterator; import java.util.ListIterator; import java.util.NoSuchElementException; public class DoublyLinkedList<E extends Comparable> implements Iterable{ private int size = 0; private Node head; private Node tail; /** Returns a list iterator object for the list at * the specified index */ public DoublyLinkedList(){ } private static […]

无法连接Microsoft Azure Vm中的端口

我在Microsoft Azure中创建了Red Hat VM,并且能够通过ssh进行连接。 我已经在VM中使用端口8081启动了Java服务器并且它已成功启动。 但是我无法在浏览器中查看它。 它没有加载。 我尝试过以下内容,但所有内容都没有加载: – host:80 host:8080 host:8081 我已在网络安全组和相关子网中添加了入站安全规则。 我仍然无法在浏览器中查看我的服务器。 我已遵循此文档的入站安全规则 这是我的入境规则 netstat -tuplen (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State User […]

WSO2 Identity Server AuthenticationAdmin API身份validation失败

我正在按照这里提到的教程: https : //docs.wso2.com/display/IS500/Managing+Users+and+Roles+with+APIs 并使用页面上提供的示例代码: http : //cache.facilelogin.com/org.wso2.identity.um.sample.zip 我已将所需的JAR添加到eclipse项目中。 该项目成功构建,没有任何问题。 但是,当我运行该项目时,我收到以下错误: log4j:WARN找不到logger(org.apache.axiom.om.util.StAXUtils)的appender。 log4j:WARN请正确初始化log4j系统。 org.apache.axis2.AxisFault:身份validation失败:在org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation)上传递了无效的远程地址 – org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:508)中的myapp .java:375)org.apache.axis.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)位于org.apache.axis上的org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)。 client.OperationClient.execute(OperationClient.java:165)org.wso2.carbon.authenticator.proxy.AuthenticationAdminStub.login(AuthenticationAdminStub.java:311)at org.wso2.identity.um.sample.IdentityServerClient.main(IdentityServerClient。 Java的:67) 这是代码: package org.wso2.identity.um.sample; import java.util.HashMap; import java.util.Map; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ConfigurationContextFactory; import org.apache.axis2.transport.http.HTTPConstants; import org.wso2.carbon.authenticator.proxy.AuthenticationAdminStub; import org.wso2.carbon.um.ws.api.WSRealmBuilder; import org.wso2.carbon.user.core.UserRealm; import org.wso2.carbon.user.core.UserStoreManager; public class IdentityServerClient { // ONE TIME TASKS WE NEED TO DO BEFORE EXECUTING […]

APDU读取文件java卡程序

我用netbeans制作了java卡经典applet 当我编程读取操作时,我检查APDU中的第一个字节是0x80然后第二个是0xB0然后从字节2和3获取我将从文件中读取的偏移量然后取字节数为从字节4读取 将APDU作为默认值 0x80 0xB0 0x00 0x03 0x60这从当前文件读取60个字节,以偏移号3开始 当我尝试这个命令时它返回错误Input data length != Lc around line 12 。 经过一些重试,我发现了问题 问题是编译器假设字节4是数据的长度,所以在我的命令中他等待60个字节 当我搜索时,我发现当INS=B0时,字节4并不意味着发送数据长度 我不知道为什么它这样做,当我尝试调试编译器时甚至没有进入过程函数。 我的脚本文件是 0x00 0xA4 0x04 0x00 0X06 0X87 0XF1 0X3F 0X5E 0X22 0X47 0x7F; 0x80 0xA4 0x00 0x00 0x02 0x3F 0x00 0x7F; 0x80 0xA4 0x00 0x00 0x02 0x50 0x15 0x7F; 0x80 0xA4 0x00 0x00 0x02 […]

解耦模型和输入检查

将输入检查与模型分离并将其处理到其他地方(例如控制器)是一种好的做法吗? 如果是这样,怎么可以从MVC或DDD的角度来做呢?

如何在Android下获取桌面版网页?

我尝试使用HttpURLConnection获取网页,并获得移动版页面的结果。 现在我想获得一个桌面版本页面,并尝试使用: System.setProperty(“http.agent”, “Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0”); 或setRequestProperty(“User-Agent”, “Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0”); 但我仍然得到移动版页面的结果。 有谁知道如何获得网页的桌面版源代码而不是移动版? PS:我的Android是2.3.7

将Selenium WebDriver连接到现有的浏览器会话

我正在使用selenium,如果现有浏览器会话(对我来说Chrome)当前存在,我想附加一个webdriver实例。 我不想打开新的浏览器窗口/会话。 我用google搜索并看到,有一些方法可以使用这些网站上的描述: 通过扩展RemoteWebDriver重用现有的浏览器会话 ChromeDriverService的基本资料 我在最新版本中使用ChromeDriver 2.29 。 我的代码现在看起来如下: public static void main(String[] args) throws Exception { // starting Chrome Webdriver server ChromeDriverService service = new ChromeDriverService.Builder() .usingDriverExecutable(new File(“D:\\Development\\chromedriver\\chromedriver.exe”)) .usingAnyFreePort() .build(); service.start(); WebDriver driver = new CustomRemoteWebDriver(service.getUrl(),DesiredCapabilities.chrome()); driver.get(“http://www.google.com”); WebDriver driver2 = new CustomRemoteWebDriver(service.getUrl(),DesiredCapabilities.chrome()); // here I am expecting www.google.com from last driver instance, because it […]

使用JDT获取startPosition和方法调用的长度

假设我有这个Java源代码。 如何获取startPosition和“extractedMethod(amount)”调用的长度? package smcho; public class Extract { String _name = “”; public int extractedMethod(int amount) { …. } public int getValue(int amount) { if (amount > 10) { int z = extractedMethod(amount); return z; } …. } 我可以使用hexa查看器来查找起始位置是0x1FA,长度是len(“extract(method)”)== 17,但我想用编程方式使用JDT。 一旦我可以获得CompilationUnit,但我需要知道如何在CompilationUnit中获取调用引用。 IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject orig = root.getProject(this.projectName); orig.open(pm); javaProject = JavaCore.create(orig); IType type […]

如何将JSF RI(Mojarra)日志转发到slf4j或log4j?

如何教Mojarra使用slf4j或log4j? 根据slf4j文档,我必须打电话: org.slf4j.bridge.SLF4JBridgeHandler.install(); 在我的项目的某个地方。 但是我不能在Mojarra中调用它…所以,问题是我何时以及如何执行这个install()方法?