java-ee-6

How to clean HornetQ messaging journal before/after performing a test?

不打扰是莪最后的温柔 提交于 2020-01-02 06:57:12
问题 There's an Arquillian integration test using JMS HornetQ with persisted messages. Some test leave the messaging journal filled with unhandled messages that break other tests expecting no data. Is there a way of telling JMS to clean its messaging journal before or after executing a test? 回答1: This does not exist in the JMS API itself, but there's a method 'removeMessages(filter)' in the HornetQ QueueControl management object. This method can be found in the JMX Bean for the Queue, but I wouldn

RESTful Web Development With Java EE 6 - what are the options?

▼魔方 西西 提交于 2020-01-01 05:14:13
问题 I'm trying to figure out what the best options are for developing a RESTful web application with Java EE 6. For example, I want to be able to interpret a URL like so: GET www.myapp.com/customers/1 - returns a web page displaying details about a customer with id 1. The only two options I can think of are Using Spring MVC 3 Using a JAX-RS specification that allows you to render views - I heard RESTEasy integrates with Spring MVC? Are there any other frameworks that will allow you to develop web

How to create instances on the fly in CDI

Deadly 提交于 2020-01-01 04:22:05
问题 Let's assume I have a Car class. In my code I want to create 10 cars. Car class has some @Inject annotated dependencies. What would be the best approach to do this? CDI has a Provider interface which I can use to create the cars: @Inject Provider<Car> carProvider; public void businessMethod(){ Car car = carProvider.get(); } Unfortunately that doesn't work if I don't have a CarFactory that has a method with @Produces annotation which creates the car. As much as it reflects real world that I

How singleton is javax.ejb.Singleton in a clustered environment?

↘锁芯ラ 提交于 2020-01-01 03:03:18
问题 I need to maintain a simple counter that is unique within the application, for all users and all nodes in a clustered environment. I thought about using the singleton session bean annotation javax.ejb.Singleton like so: package foo; import javax.ejb.Singleton; @Singleton public class Bean { private int counter; [...] } This looks simple, but I could not find an answer if this works as desired in a clustered environment. Would every node of the cluster have it's own instance or not? Of course

What is the Spring DI equivalent of CDI's InjectionPoint?

烈酒焚心 提交于 2019-12-30 04:06:34
问题 I would like to create a Spring's bean producer method which is aware who invoked it, so I've started with the following code: @Configuration public class LoggerProvider { @Bean @Scope("prototype") public Logger produceLogger() { // get known WHAT bean/component invoked this producer Class<?> clazz = ... return LoggerFactory.getLogger(clazz); } } How can I get the information who wants to get the bean injected? I'm looking for some equivalent of CDI's InjectionPoint in Spring world. 回答1: As

h:commandbutton, how to redirect to external site?(JSF 2) [duplicate]

北慕城南 提交于 2019-12-28 06:49:08
问题 This question already has an answer here : Redirect to external URL in JSF (1 answer) Closed 4 years ago . When i use command button to redirect to pages, inside my project, u just need to give the name of the page with no extention, followed by ?faces-redirect=true in the action attribute and i will get redirected. But what if i want to get redirected to an external page(example:www.google.com)? I tried in many ways: www.google.com, google.com, http://google.com but i failed. This is what i

What is the meaning of @Priority for CDI @Interceptor?

时间秒杀一切 提交于 2019-12-25 16:53:57
问题 1) What is the meaning of @Priority for CDI @Interceptor ? 2) How does it relate to order of interceptors declared in beans.xml ? 3) Can @Priority be overwritten in xml file ? 回答1: 1) Well, as the name suggests, it's meant to set priority (order) to the interceptors within Java EE application. Such interceptor will also be automatically registered so you don't have to define it in beans.xml . 2, 3) JBoss documentation says that interceptors annotated with @Priority ale called before ones

CDI Weld and AspectJ - org.jboss.weld.exceptions.UnproxyableResolutionException

空扰寡人 提交于 2019-12-25 06:32:10
问题 I get this error when using AspectJ and CDI. org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001437 Normal scoped bean class myPackageName.myClassName is not proxyable because the type is final or it contains a final method static final java.lang.String myPackageName.myClassName.myMethodName_aroundBody0(myPackageName.myClassName.,org.aspectj.lang.JoinPoint). If I remove AspectJ it works, but I don't want that. Please Help. 回答1: I got an answer from AspectJ's mailing list, they

How to find the path to a .txt file in glassfish v3.0

十年热恋 提交于 2019-12-25 03:57:16
问题 In my aplication i want to send a html template to the users email. Everithing works correctly when i programatically create the html, but what i want to do now, is read the html text from within a file in my application and send it. I get a FileNotFoundException, and i dont know how to find that .txt file. See the code: public void sendAccountActivationLinkToBuyer(String destinationEmail, String name) { // Destination of the email String to = destinationEmail; String from = "myEmail@gmail

Number format exception when returning values from database(JPA)

倖福魔咒の 提交于 2019-12-25 03:51:30
问题 I want to fill a simple h:datatable tag with some values from a database. But i get an exception and i cant find what is the reason: java.lang.NumberFormatException: For input string: "url" This is how i create the datatable: <h:form> <h:dataTable value="#{managementBB.retrieveRecords()}" var="record"> <h:column> <f:facet name="header">URL</f:facet> #{record.url} </h:column> <h:column> <f:facet name="header">Submition date</f:facet> #{record.submitionDate} </h:column> <h:column> <f:facet name