java-ee-6

javax.ejb.EJBException java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName

会有一股神秘感。 提交于 2019-12-06 05:44:07
I'm working on a JavaEE application with EJB. I have an Entity called Medico which code is: @Entity public class Medico implements Serializable{ /** * */ private static final long serialVersionUID = 1L; /** * */ public Medico(String nome_medico, String morada_medico, String esp, GregorianCalendar dnasc_medico, int tel_medico) { //construtor parametrico super(); this.nome_medico = nome_medico; this.morada_medico = morada_medico; this.esp = esp; this.dnasc_medico = dnasc_medico; this.tel_medico = tel_medico; } @Id @GeneratedValue private int cod_medico; //bi private String nome_medico; private

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

旧时模样 提交于 2019-12-06 05:12:42
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? 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't know how to get that in Arquillian. Luckily, you can invoke management operations via the 'hornetq

JMS Timeout or TimeToLive

会有一股神秘感。 提交于 2019-12-06 05:09:24
I am fairly new to Java EE and JMS and am looking at doing an implementation using JMS. Think of the following scenario: Scenario A user hits a servlet. A message is then put into a JMS server/Queue from this servlet. A response is then sent back to the user saying "Message Queued". Option 1 The consumer/MDB receives the message from the JMS queue and processes it. This is normal operation and pretty standard. Option 2 There is no consumer(for what ever reason) or the receiver is processing messages too slow. So what I would like is for the message in the queue to timeout. Once timed out, and

Deploy Java web application to root context for glassfish in eclipse?

我们两清 提交于 2019-12-06 04:09:40
I have an application that I only ever intend to deploy to the the root ('/') context using glassfish. Unlike with tomcat in eclipse, there are no application specific settings when I double-click the server in the server browser. I can go to http://localhost:4848 and accomplish this, but when I redeploy after making a change, eclipse deploys the application to '/myapp'. How can I do this? For WAR-only deployments you must do this with a vendor specific configuration file. For Glassfish you need to set the <context-root> tag inside sun-web.xml next to the web.xml file. From http://www.sun.com

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

泄露秘密 提交于 2019-12-06 03:51:48
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 AtomicInteger(0); public CacheStartupListener() { System.err.println("Singleton invoked " + count

Shiro UnknownSessionException after logout

孤街浪徒 提交于 2019-12-06 02:26:18
I'm currently working on a web application in JavaEE6 stack and I've integrated Shiro for security. I think the authentication and authorization is working properly now and I have 1 last problem. When I logout, I'm encountering UnknownSessionException, here are my config and codes for inspection: web.xml <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <!-- Welcome page --> <welcome-file-list> <welcome-file>home.xhtml<

Java EE 6 @Inject lazy? [duplicate]

我的未来我决定 提交于 2019-12-06 02:21:57
问题 This question already has answers here : How to make a CDI bean lazily initialized? (3 answers) Closed 6 years ago . I am doing some refactoring and reviewing of the application that we are currently developing. While doing this I found that more beans are injected and I think making they loading in an lazy manner would be better suited for their purpose. I am using Java EE 6 and tend to use more CDI than EJB injection. So the question is whether it is possible to inject the beans lazily and

CDI @TransactionAttribute for bean

拈花ヽ惹草 提交于 2019-12-06 02:19:22
I am experimenting with CDI on a test application. I have a DAO which injects a container managed JTA persistence context like this: public class TestDAO implements Serializable { @PersistenceContext private EntityManager entityManager; public void insertEntity(Test test) { entityManager.persist(test); } } Now I have a CDI controller bean like this: @Named @SessionScoped public class TestController implements Serializable { @Inject private TestDAO testDAO; public void finishGame() { testDAO.insertEntity(new Test(1, 2, 3)); } } If I run this, I receive an error in the DAO when trying to insert

Where to put composition components?(JSF 2.0)

╄→гoц情女王★ 提交于 2019-12-06 02:12:30
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 other chunks of xhtml. <ui:include src="/languageChanger.xhtml"/> This is how my folder structure looks

Java EE 6 and Singletons

删除回忆录丶 提交于 2019-12-06 02:04:00
问题 Can anyone explain the full process of implementing a Singleton in a Java EE 6 app? I'm assuming that I shouldn't be creating a singleton in the typical way of declaring a static variable and should be using the @Singleton annotation? Do I have to do it this way? Is it just a case of declaring it @Singleton and that's it? Do I have to do anymore to the class? What do I then need to do to access the singleton in my other classes? 回答1: Is it just a case of declaring it @Singleton and that's it?