该项目有一个EJB模块和一个Web模块.更改服务器很简单,但我也想切换到EJB 3.1,但我相信我需要更改所有类型的配置文件,因为我无法从项目属性窗口中执行此操作.
任何提示或链接做有用的文档将不胜感激.
谢谢!
基于这篇文章http://www.adam-bien.com/roller/abien/entry/ejb_3_1_killed_the我在我的应用程序@Named @Stateless bean中使用与数据库进行通信(在此处注入EntityManager)并在jsf页面上显示信息.自Java EE 5以来,这是很好的促进,但我有一个问题.
使用这样的bean来维护用户会话(购物车等)是否安全?我读了一本关于ejb 3.0的书,我知道同样的无状态bean可以用于许多客户端.
使用具有所有ejb功能(事务,线程安全等)的托管bean的最佳方法是什么?我的意思是除了托管bean + ejb接口以及Java EE 5中的实现+ ejb注入之外的任何其他方式?
我使用GlassFish 3.1 WebProfile
首先:我使用GlassFish 3.1 + Eclipse Java EE靛蓝。我想用javaee测试缓存解决方案,所以我做了一个虚拟应用程序。我有一个生成的大型数据库,并且列出,搜索,修改等一些数据。为此,我编写了一些基本的servlet,并使用GET参数进行调用。例如:/ app / list?page = product&pageSize = 100 ListServlet带有注释
@WebServlet({ "/ListServlet", "/list" })
Run Code Online (Sandbox Code Playgroud)
而且它就像一种魅力,我可以同时使用两个网址。因此,我需要一些其他的servlet(用于搜索,修改)。我创建了它们并以相同的方式注释。但是,当我键入url http://localhost/app/modify或/ app / search?id = 1时,出现错误404。我尝试编写一个非常虚拟的helloservlet,它打印了一个hello world消息,但没有用:错误404。我重新启动了玻璃鱼服务器和计算机,但没有帮助。
有什么问题?我错过了什么?
编辑:servlet是相同的程序包使用相同的导入...
我正在使用EJB 3和JBoss AS 6.0.0.Final。我有一个带注释@Stateless和的无状态会话bean @WebService。添加批注时@Singleton,部署错误,显示以下消息:
... name = ServiceBean,service = ejb3已安装
如何避免部署错误?
Glassfish 3.1.2,Mojarra 2.1.6,SSL激活
我有一个关于静态资源缓存的问题.我读过一些关于此的帖子,但我不确定应该使用哪些选项.这个
https://developers.google.com/speed/docs/best-practices/caching
关于资源缓存也是一篇很好的文章.在我们的应用程序服务器中激活SSL.我们看到静态资源(图像,脚本,css)没有被缓存.
这是我的测试过滤器:
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
String uri = httpRequest.getRequestURI();
if (GET_METHOD.equalsIgnoreCase(httpRequest.getMethod()) && uri.contains(ResourceHandler.RESOURCE_IDENTIFIER)) {
httpResponse.setDateHeader("Expires", System.currentTimeMillis() + 2419200000L); // 1 month in future.
httpResponse.setDateHeader("Last-Modified", System.currentTimeMillis() - 2419200000L); // 1 month in past.
httpResponse.setHeader("Cache-Control", "public"); // Secure caching
}
}
chain.doFilter(request, response);
}
Run Code Online (Sandbox Code Playgroud)
这个设置有什么影响吗?我还阅读了很多帖子,其中应通过过滤器禁用缓存.我看到的唯一问题是用户可能在新版本上遇到问题.样式和脚本可以在新版本中更改,但浏览器会忽略新版本并使用缓存中的文件.
我有一个Java EE 6应用程序,我使用Maven构建,代码在NetBeans 7中,并部署在GlassFish 3.1.2上.当我接近完成时,我发现自己正在部署演示版本.
问题是我没有任何简单的方法来构建不同的环境,如dev,QA,demo,prod等.对于某些东西,我一直在使用带有一堆静态getter返回的Java类基于环境常量值的值.但是这对条件设置没有帮助
可能还有许多我现在都想不到的其他东西分散在XML文件中.
有没有办法定义这些配置文件的多个版本,只需在构建时设置一个标志来选择环境,而在没有指定环境时默认为dev?在这种情况下,有没有办法让Maven为我工作?
我想从Maven项目中部署我的src/main/webapp文件夹作为JBoss7中的一个应用程序.我想做的是:
mvn prepare-package war:inplace完全部署这当然只是为了开发.我希望有与Maven Jetty插件类似的工作流程,但是对于JEE6应用程序.
部署扫描程序正在寻找*.war目录.
我目前的解决方案
war:exploded并将资源复制到war目录.完全重新部署需要使用antrun插件创建.dodeploy文件,这非常难看.我仍然需要在保存资源后运行maven.我不希望我的资源被复制到任何地方.我没有什么特别的pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pg</groupId>
<artifactId>jeesample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>jeesample</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
</dependencies>
<build>
<finalName>jeesample.war</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
Run Code Online (Sandbox Code Playgroud)
有一个Arquillian集成测试使用JMS HornetQ和持久消息.一些测试使消息日志充满了未处理的消息,这些消息打破了其他期望没有数据的测试.
有没有办法告诉JMS在执行测试之前或之后清理其消息日志?
我想编写用于从中提取消息的代码Activemq.我不想Activemq一次从所有消息中提取所有消息,因为我的要求是每当我的Java应用程序收到1条消息时Activemq,根据消息正文我将找到相应的HTTP Link并转发给链接.对于这整个逻辑,我写了2个.java文件名
MessageConsumer.java
MyListener.java
MessageConsumer.java文件仅用于连接建立.相应的代码如下.
package PackageName;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.jms.*;
import org.apache.activemq.ActiveMQConnectionFactory;
public class MessageConsumer extends HttpServlet {
@Override
protected void service(HttpServletRequest arg0, HttpServletResponse arg1)
throws ServletException, IOException {
try {
//creating connectionfactory object for way
ConnectionFactory connectionFactory=new
ActiveMQConnectionFactory("admin","admin","tcp://localhost:61617");
//establishing the connection b/w this Application and Activemq
Connection connection=connectionFactory.createConnection();
Session session=connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue=session.createQueue("MessageTesing");
javax.jms.MessageConsumer consumer=session.createConsumer(queue);
//fetching queues from Activemq
MessageListener …Run Code Online (Sandbox Code Playgroud) 我正在读Charles Lyon的OCWCD <jsp:attribute>,我无法理解这一部分.如果有人能帮助我,我将不胜感激.
在这里(摘自书中):
方法1:
<jsp:useBean>
<jsp:attribute name="id">bean_name<jsp:attribute>
<jsp:useBean>
Run Code Online (Sandbox Code Playgroud)
方法2:
<jsp:useBean id="bean_name"/>
Run Code Online (Sandbox Code Playgroud)
"两种方法的语义都是相同的,因为如果一个属性期望请求时间表达式的结果,那么容器将评估该
<jsp:attribute>动作的内容;否则如果主体内容<jsp:attribute>是请求时间表达式,则翻译异常将被抛出."
知道他想说什么吗?