java.lang.SecurityException:类“org.apache.log4j.Logger”与同一包中其他类的信任级别不匹配

对于java Web应用程序,使用JRE 1.6.0_22时出现此错误 java.lang.SecurityException:类“org.apache.log4j.Logger”与同一包中其他类的信任级别不匹配 但是,使用JRE 1.6.0_13时它可以正常工作。 我在谷歌搜索过,发现自更新19以来有一个安全增强function。 对于这个例外,它说, 在先前检测到混合组件并且决定允许它们共存之后,抛出以下两个SecurityExceptions。 exception表示在受信任组件和不受信任组件之间检测到组件名称冲突(资源名称或类包名称),并且拒绝加载资源或类的请求。 现在的问题是,我怎么能找到哪些类(可能是org.apache.log4j.Logger?)有碰撞以及它们在哪些包中? 我发现Oracle论坛中存在类似的问题

java.lang.IllegalStateException:在提交响应后无法调用sendRedirect()

有两天我试过找出出了什么问题。 我在这里读到我应该在代码中添加一个返回,我做到了,我仍然得到 java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed, Error. 我怎么解决这个问题? 每次我连接数据库时都会发生这种情况。 这是连接方法: 像在这个代码块中: String post = request.getParameter(“send”); if(post != null ) { connect(); statement.execute(add); con.close(); response.sendRedirect(“fourm.jsp”); return; } 但在这段代码中,它的工作完美无缺: String back = request.getParameter(“retrun”); if(back != null) { response.sendRedirect(“fourm.jsp”); return; }

HttpClient:如何从现有连接获取底层套接字?

我正在使用HttpClient 4.02通过代理创建连接(使用CONNECT方法)来连接到远程服务器的连接。 HttpClient非常方便,但我是API的新手,无法看到如何获取隧道连接的底层Socket 。 以下代码取自: http : //svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java // make sure to use a proxy that supports CONNECT HttpHost target = new HttpHost(“target.server.net”, 443, “https”); HttpHost proxy = new HttpHost(“some.proxy.net”, 8080, “http”); // general setup SchemeRegistry supportedSchemes = new SchemeRegistry(); // Register the “http” and “https” protocol schemes, they are // required by the default […]

是否可以在eclipse中更改android项目中的包名?

我的项目的包名是org.consulting.keno ,我能以某种方式将其更改为org.consulting.keno2吗? 问题是我向谷歌商店提交了一个免费的应用程序,并希望将其更改为收费。 谷歌商店说,我将不得不删除旧的,并重新提交一个新的apx文件。 但我得到一个错误说包装名称冲突。

在Netbeans中运行/调试Maven JavaSE应用程序

我有一个JavaSE多模块应用程序,我想在调试模式下构建和运行。 然后,一旦应用程序运行(在我的本地计算机上),我希望能够附加到该进程。 我们使用的是Maven,IDE是Netbeans。 我已经找到了这个信息: 您可以调试NetBeans中的任何Maven目标转到/Project Properties/Actions/ ,选择您要调试的目标,在最后一个选项Set Properties选择Add ,然后选择Debug Maven build 。 但是,我不知道要为Execute Goals输入什么以使其在Debug模式下运行。 我可以选择Run – > Clean and Build Maven Project ,看看我的项目是在调试模式下构建的(即[debug] execute contextualize)。 我在这里找到了一个答案,说明了8000本地机器的默认端口。 那么如何在该端口上运行应用程序,以便我可以附加到它?

Java中的命令行查询

我正在访问MongoDB,并希望在Java中重用典型的命令行查询。 我知道可以使用BasicDBObject,但我想使用这样的命令行查询: db.MyCollection.find() 我现在尝试使用数据库的command()方法: MongoClient mongoClient = new MongoClient(“localhost”, 27017); DB db = mongoClient.getDB(“MyDatabase”); CommandResult result= db.command(“db.MyCollection.find()”); JSONObject resultJson = new JSONObject(result.toString()); System.out.println(resultJson.toString(4)); 但是这会给我带来以下结果。 “ok”: 0, “code”: 59, “errmsg”: “no such cmd: db.MyCollection.find()”, “bad cmd”: {“db.MyCollection.find()”: true}, “serverUsed”: “localhost:27017” 如何在Java中运行命令行查询? 我不想使用DBCollection类 – 因为它不再可能为不同的集合运行查询。 DBCollection collection = db.getCollection(“MyCollection”); collection.find(); //NOT THIS

Javaexception处理 – 捕获超类exception

我有一个关于在Web应用程序中处理exception的问题。 我经常听到抓住超类exception是一个坏主意。 我经常编写代码来捕获struts action / java servlet类中的所有exception。 try { // call business facade // business facade calls DAO // any exception from DAO bubbles up } catch (Exception e) { log.error(“error”, e); } 如果我们不捕获超类Exception。 我们如何处理任何意外的运行时错误并适当地记录它们

在Jar文件中运行ANT build.xml文件

我需要使用存储在jar文件中的build.xml文件来运行ANT构建。 此jar文件在类路径中可用。 是否可以这样做,而不会爆炸jar文件并将build.xml保存到本地目录? 如果是这样我怎么能这样做。 更新: jar文件是一个ant构建项目,其中classpath中的build.xml是使用ANT库通过java程序运行的。 前端是一个Web应用程序,它将此构建项目jar作为依赖项加载。 用户将单击“构建应用程序”按钮以​​运行ANT构建。 因此,当用户单击Build App时,我需要在jar中运行build.xml文件。 用于读取build.xml文件的代码 URL preBuildFileUrl = getClass().getClassLoader().getResource(“build.xml”); Project p = new Project(); p.setUserProperty(“ant.file”, preBuildFileUrl.toURI().getPath()); p.init(); ProjectHelper helper = ProjectHelper.getProjectHelper(); p.addReference(“ant.projectHelper”, helper); helper.parse(p, new File(preBuildFileUrl.toURI().getPath())); p.executeTarget(p.getDefaultTarget());

JSF / Seam:如何在没有用户干预的情况下下载和打印动态生成的PDF文件?

我有一个JSF / Seam Web应用程序,其中有一个页面,其中包含一个表单,当提交(按钮单击)时,会根据表单输入动态创建PDF文件(在Java,服务器端)。 目前我的工作是将生成的PDF作为文件下载返回到浏览器,因此用户可以选择保存或在Acrobat Reader中打开它以进行后续打印。 我想要发生的是PDF被发送到浏览器并打印(客户端)而无需进一步的用户干预(好吧,除了可能出现的Windows打印机选项对话框,我无能为力)。 该解决方案似乎基于在加载PDF的页面上隐藏iframe ,然后在iframe上调用.contentWindow.print() 。 但是,我不知道如何通过HttpServletResponse (在Java中)将PDF放入iframe,更不用说在加载pdf后如何在iframe上自动调用print()了。

InsufficientAuthenticationException:没有客户端身份validation。 尝试添加适当的身份validation筛选器

我只是将Oauth的一个例子集成到我的项目中,但似乎没有正常工作。 这是我的WebAppConfig.java: package com.sprhib.init; import java.util.Properties; import javax.annotation.Resource; import javax.sql.DataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.hibernate4.HibernateTransactionManager; import org.springframework.orm.hibernate4.LocalSessionFactoryBean; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.view.JstlView; import org.springframework.web.servlet.view.UrlBasedViewResolver; @Configuration @EnableWebMvc @ComponentScan(“com.sprhib”) @EnableTransactionManagement @ImportResource({ “classpath:spring-security.xml” }) @PropertySource(“classpath:application.properties”) public class WebAppConfig { private static final String PROPERTY_NAME_DATABASE_DRIVER = “db.driver”; […]