ejb-3.0

@EJB injection with Arquillian on WebLogic 10.3.5 doesn't work

蹲街弑〆低调 提交于 2019-12-11 02:01:52
问题 I am using Arquillian to run a basic unit test on WebLogic 10.3.5. Unfortunately, @EJB injection does not work for me, and get a NullPointerException when the EJB is invoked. The examples I found don't require an ejb-jar.xml to be added, but I added one. In any case, a NullPointerException is thrown. Any ideas? The unit test: import static org.testng.Assert.assertEquals; import java.io.File; import javax.ejb.EJB; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss

Accessing the clients principal inside an ejb method

萝らか妹 提交于 2019-12-11 01:50:10
问题 I need to access the clients principal (username ) inside a ejb method. I don't want to add it as a parameter. Tryed adding them to Context object like ; prop.add(Context.SECURITY_AUTHENTICATION,"user") prop.add(Context.SECURITY_CREDENTIALS,"pass") but trying to access them inside the method like; @Resource private SessionContext ctx; public void someMethod() { Principal principal = ctx.getCallerPrincipal(); //returns anonymous still give me the annoymous user. Working on weblogic, any

declare a transaction in ejb 3.0

这一生的挚爱 提交于 2019-12-11 01:39:44
问题 how can I force the EJB to not flush everything after every single command, I want to do a transaction. I've read that this is done somehow declaratively. But how exactly? @Stateless public class SomeBean{ @PersistenceContext EntityManager em; public void doSomeStuffAndThenFlushToTheDb(){ em.persist(entity); // it's flushed by now, I don't want that em.persist(somethingElse); // now I want to flush both em.flush(); } } 回答1: Hi, how can I force the EJB to not flush everything after every

it's possible configure a persistence.xml for multiple data sources?

北慕城南 提交于 2019-12-10 23:58:13
问题 hi i just want to know how configure in a persistence.xml two datasources one of the data sources have a jar outside from the other. I'm tried but i really don't if it's possible 回答1: Yeah, you can have two datasources configured in a persistence.xml. You would just need two separate elements. <persistence> <persistence-unit name="datasourceOne"> <jta-data-source>java:/DefaultDS</jta-data-source> <jar-file>../MyApp.jar</jar-file> <class>org.acme.Employee</class> <class>org.acme.Person</class>

How to create a custom Annotation and processing it using APT?

纵然是瞬间 提交于 2019-12-10 23:53:40
问题 I'm new to Java Annotation. I know how to create custom annotation but I don't know how to process that Annotation to generate the dynamic code just like ejb 3.0 and hibernate does. I read some articles based on APT but no one gives the details about how to process the Annotation. Are there any tutorials with sample code for processing custom Annotations? Thanks 回答1: Start with... the apt getting started guide. To go further, you could maybe have a look at the sources of annotation processor

java.lang.IllegalArgumentException: Named query not found:

戏子无情 提交于 2019-12-10 17:30:54
问题 I got the following code @Stateless public class BondecomandeDAO { @PersistenceContext private EntityManager em; public Bondecommande findBCbyid(int id) { Query q =em.createNamedQuery("select bc from Bondecommande bc where bc.idbc = :idbc"); q.setParameter("idbc", id); return (Bondecommande) q.getResultList().get(0); } } and @Entity @Table(name="bondecommande") public class Bondecommande implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy =

ClassNotFoundException marshaling EJB parameters

ぐ巨炮叔叔 提交于 2019-12-10 17:01:45
问题 I am making a project with distributed architectures, but I am having problem in returning a java.util.Collection to the client application. I am calling an EJB in a Managed Bean to bring a Collection of persisted entities. I am using Java7 and JBoss7.1.1. The ManagedBean method: public Collection<Cliente> getClientes() { clientes=new ArrayList<Cliente>(); try { Context ctx = new InitialContext(); facade = (ClienteFacadeRemote) ctx.lookup(ClienteFacadeBean.NOME_EJB); } catch (NamingException

Tables not getting auto-created in Apache Derby when using EJB3/Hibernate

穿精又带淫゛_ 提交于 2019-12-10 16:04:08
问题 I have an EJB3 entity bean Player which is annotated as given below: @Entity @Table(name = "PLAYER") public class Player { public Player() { super(); } @Id @GeneratedValue private String id; @Column(nullable = false) private String firstName; private String lastName; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String

A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property “How to solve it?”

时光怂恿深爱的人放手 提交于 2019-12-10 13:03:54
问题 overview : This my first tutorial by Websphere 7 Server & JPA 1.0 & EJB & Derby Database. First : My data source name is EJB3BANK & my target database is SHOP . Second : This the persistence.xml file <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

javax.naming.NoInitialContextException: Cannot instantiate class:

流过昼夜 提交于 2019-12-10 12:06:43
问题 I'm trying to implement Simple EJB Application Described in tutorialpoint and I’m using JBoss 5.1 and eclipse as IDE and i created project as EJB 3. but I’m getting the below error javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674) at javax.naming.InitialContext