java-ee

EJB3 - Inject a MDB into another MDB?

天大地大妈咪最大 提交于 2019-12-24 11:04:52
问题 Since a message driven bean is a type of EJB, I would expect that I would be able to inject one into another, but I am having issues. I have to MDBs and need to inject one into the other something like this: @MessageDriven(mappedName = "jms/QueueOne") public class MessageBeanOne { @EJB private EntityService service; @EJB private MessageBeanTwo mdbTwo; public void onMessage(Message message) { log.info("Received message from jms/QueueOne: " + message); String entityId= null; try { if (message

CDI inject into existing object

旧街凉风 提交于 2019-12-24 10:26:36
问题 Let's say I have the following class: public class MyRequestPayload implements RequestPayload { protected MyRequestPayload() {} @Override public ResponsePayload process() { String result = someService.doSomething(foo, bar); return new MyResponsePayload(result); } public final String foo; public final Integer bar; @Inject private SomeService someService; } Is there some CDI service I can invoke that will process all the @Inject annotations on an instance of this class, injecting all the

JPA inheritance using SINGLE_TABLE - discriminator value doesn't match class

霸气de小男生 提交于 2019-12-24 10:25:04
问题 I've got a strange behaviour with a JPA class hierarchy using a single table. Basically I have two entities EntityMapA and EntityMapB which both extend EntityMap. The discriminator value is 'ENTITY_TYPE' and it is A for EntityMapA and B for EntityMapB. Somehow I get Objects of type EntityMapA where the discriminator value is set to 'B'! I am using Hibernate 3.3 as the JPA provider. Here is the code: @Entity @Table(name="ENTITY_MAP") @DiscriminatorColumn(name = "ENTITY_TYPE") @Inheritance

java.lang.NoSuchFieldError exception while the field is defined

只愿长相守 提交于 2019-12-24 10:19:03
问题 I'm working on a web application for Apache Tomcat. I'm using a class called Location in which i defined a field called ipAddresses. Here it is: package com.maxmind.geoip; import java.util.HashSet; import java.util.Set; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; public class Location { private final static double EARTH_DIAMETER = 2 * 6378.2; private final static double PI = 3.14159265; private final static double RAD_CONVERT

Selecting a class dynamically at runtime

别来无恙 提交于 2019-12-24 10:05:01
问题 Im trying to come up with a solution where the class that processes a "message" is selected at runtime depending on the message type. I know that i can use something like this if msg_type = "A" MsgAProcessor.execute(message); else if msg_type = "B" MsgBProcessoror = execute(message); .... .... .... I dont want to use the above approach as i dont want the code to know anything about the message types that i could be processing. I want to be able to in the future add a new message processor for

Why am I getting a TransactionRequiredException in @PostConstruct method in JTA EJB?

风流意气都作罢 提交于 2019-12-24 10:03:50
问题 I have Java EE project where I want to use an injected JTA EntityManager in the @PostConstruct method. EntityManager.persist fails due to javax.persistence.TransactionRequiredException . It succeeds when called through an EJB instance injected into a JSF managed bean. Manually starting a transaction with @Resource UserTransaction and UserTransaction.begin/commit or EntityManager.getTransaction.begin/commit because it's a JTA EntityManager . The EJB interface @Local public interface

WebServiceContext: Is it there a way to inject it any where appart from my WebService?

别来无恙 提交于 2019-12-24 09:58:23
问题 I'm trying get the jax-ws javax.xml.ws.WebServiceContext . I'm able to do it in my Web service this way: @WebService public class Service extends BaseService { @Resource WebServiceContext wsContext; @WebMethod public responseExample example(....) {...} } I want to get this bean any where else in my code. Would it work if I use spring? 回答1: After a long time trying different ways, this is how I managed to do it like this: WebServiceContext wscontext = null; try { Context ctx = new

Any library for authentication in a java web-app?

人盡茶涼 提交于 2019-12-24 09:57:24
问题 Hi I am look for a proven java security web-library which is a bit more low-level and therefore less intrusive than the well known frameworks spring-security and apache shiro. Just something which has best-practive utility-apis for example to encode a remember-me cookie or for dighest authentication, accessing ldap. All the sutff which is so useful in the above frameworks but without needing to follow the frameworks filters and indriections an application-context or yet another ini file etc.

Want to call C++ code from Java code using JavaCPP?

对着背影说爱祢 提交于 2019-12-24 09:54:05
问题 I want to call c++ code from java code by using JavaCPP. I am trying to run there own example of LegacyLibrary on http://code.google.com/p/javacpp/ when I try to compile code with following command mentioned at site only javac -cp javacpp.jar:. LegacyLibrary.java I get the following exception on console I don't under where I am wrong. I am specifying the path of jar which contains com.google.javacpp.* classes. 回答1: You're on Windows, so you should be using ; , not : as a separator for the

What's the right way to integrate SQLite with my Java EE app?

折月煮酒 提交于 2019-12-24 09:29:19
问题 I'm looking to add a pretty simple SQLite database to an existing Java EE application. I'm very used to using EJBs, ORMs, EntityManager , etc. to work with SQL databases. I've never not used some sort of ORM to work with relational DBs in Java. I've been "recommended" to use a Java wrapper for SQLite, rather than a JDBC driver - so I'm kind of naked and ORM-less (right?). I'd like to get this up and running quickly. Context I've been using an in-memory cache, implemented as a Map , which gets