java-ee-6

Expose current progress of an @Asynchronous function to use in View

孤街浪徒 提交于 2019-12-07 17:55:29
In my JEE6-App (running on Glassfish 3.0.1) I have an EmailEJB which has to send lots of mails. The mails are sent asynchronously, so its annotated with the new EJB3.1 @Asynchronous, letting it be run in a separate Thread. Now i want the user to be informed about the current status of the method: How many mails have already been sent? Sending the mails asynchronously works fine, but i can't figure out how to let the progress be accessible from outside. Seems like my approach to do that is quite wrong, but somehow it has to be possible (maybe another approach). This is how my EmailEJB currently

how create a Word document from a template or existing document with Java?

谁都会走 提交于 2019-12-07 17:52:16
问题 I have a document template where some fields are static and others are dynamic. I need to replace some data (name, last name, salary) and generate the new file. What library do you recommend to do this? Is POI appropriate? I am working with Spring, Java EE6 and Oracle. 回答1: You can give Apache POI a try but the HWPF and XWPF part of POI which are required to manipulate word files are really complicated to use - you need to have at least a good understanding how a word file is structured!

Where to put composition components?(JSF 2.0)

落爺英雄遲暮 提交于 2019-12-07 17:22:24
问题 I am continuing my practices with JSF 2.0. I see templating is a great thing to do, and it has lots of advantages. But today i got a new doubt related to it. I created a template for my pages. In the template, i use tags for the parts that are different(Those parts will be implemented later in a page using the composition tag in combination one or more define tags). <ui:insert name="content" /> Also inside the template, to avoid putting to much code in the template, i create tags to add some

Learning resource for Configuring Hibernate JPA 2.0 on Glassfish server

泄露秘密 提交于 2019-12-07 15:44:53
问题 I am trying to create a new Java EE project using hibernate and JPA 2.0 on the glass fish server. Can you guys provide me some resources to configure the above so that they work seamlessly? I have tried using netbeans and generated the persistence unit by using the hibernate provider, but I end up getting this error: javax.persistence.PersistenceException: [PersistenceUnit: DBAppPU] Unable to build EntityManagerFactory 回答1: First, install Hibernate support via the update tool (or follow the

@Startup @Singleton instantiated twice in WebLogic (EJB 3.1)

烂漫一生 提交于 2019-12-07 14:35:55
问题 I have a class marked @Startup and @Singleton and the constructor is being called twice. Why is it being called twice? WebLogic 12.1.1 Running Locally (not cluster) @PostConstruct is also called twice when it is there Nothing relevant in XML configuration (weblogic-ejb-jar.xml et al) Here is the class: import java.util.concurrent.atomic.AtomicInteger; import javax.ejb.Singleton; import javax.ejb.Startup; @Startup @Singleton public class CacheStartupListener { static AtomicInteger count= new

JSF get current action in managed bean

心已入冬 提交于 2019-12-07 14:04:47
问题 When user clicks any commandButton , then corresponding action is called in managed bean. Is it possible to get this action name from @PostConstruct method or from event listener method ? 回答1: The button's name=value pair is by itself available as HTTP request parameter the usual way. Imagine that the generated HTML representation of the command button look like this <input type="submit" name="formId:buttonId" value="Submit" ... /> Then it's present as a request parameter with name formId

It is possible to override properties in a persistence.xml that is located in a jar dependency

烈酒焚心 提交于 2019-12-07 13:34:05
问题 I have a java-ee web application that uses a persistence unit that is packaged as a jar dependency (Entity classes, EJB repositories, persistence.xml). In order to get some acceptance tests running for the web application i need to override a property in the packaged persistence.xml. To be specific i need to disable the by default active eclipselink shared object cache by setting the following property. <property name="eclipselink.cache.shared.default" value="false"/> This is necessary

Disable @WebFilter (embedded in dependency jar)

微笑、不失礼 提交于 2019-12-07 10:33:05
问题 Is there a way to disable a embedded Servlet Filter? My project has a dependency jar that contains (inside the jar) a @WebFilter mapped to "/*" . I need the jar (it has a lot of commons class of my company), but this new project does not need this WebFilter, actually this new project will not work because this Filter checks user authentication and the new project has no "loggedUser". It's like a website Thanks 回答1: web.xml takes precedence over annotations for precisely this reason. Simply

@javax.persistence.Column( updatable=false )

不打扰是莪最后的温柔 提交于 2019-12-07 09:00:46
问题 If I define a field as non-updatable, does that mean that the field can't be updated at all, ever? What I'd like to do is prevent the field from getting updated when I save an entire entity object, but still be able to write queries that explicitly update this field. Is this possible? I'm using Hibernate and MySQL, but I'd prefer to write portable code. 回答1: As documented, setting updatable=false affects only SQL UPDATE statements generated by persistence provider: Whether the column is

@RequestScoped CDI injection into @MessageDriven bean

空扰寡人 提交于 2019-12-07 02:50:49
问题 If I have a request scoped CDI bean injected into a @MessageDriven EJB using JMS, as below, can I assume that any given Foo instance will only be used by a single onMessage invocation at a time? In other words, in the below example, can I safely use member variables in the Foo object to store state across subroutines, analogously to a JSF @RequestScoped managed bean? Note that it's ok if the same Foo object gets recycled sequentially from one onMessage call to the next, as long as each