java-ee-6

How to setup JNDI for Glassfish 3.1.2 for a stand-alone client?

二次信任 提交于 2019-12-17 14:18:44
问题 I try to connect from a stand-alone swing client (running in a separate JVM on the client machine) to the Glassfish server. I currently use the following settings from Netbeans and everything works just fine: System.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory"); System.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming"); System.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi

Problems in injecting entity manager into stateless bean

有些话、适合烂在心里 提交于 2019-12-13 19:30:28
问题 I am developing an EJB3-app, where I use stateless beans. It seems like the EntityManager is not injected properly into my bean. Here is code for the stateless bean: @Stateless @LocalBean public class FirmEJB { @PersistenceContext(unitName = "Fr14_07_Nezdolij_lab3PU") private EntityManager em; @PersistenceUnit(unitName="Fr14_07_Nezdolij_lab3PU") private EntityManagerFactory emf; public FirmEJB() { emf = Persistence.createEntityManagerFactory("Fr14_07_Nezdolij_lab3PU"); em = emf

Looking up an EJB dynamically

百般思念 提交于 2019-12-13 16:23:02
问题 I'm developing an application on Glassfish 3. I have an EJB that looks like this: @LocalBean @Stateless public class MyBean { public void doSomething() {} } My client code (running inside the same application) looks like this: MyBean mb = (MyBean) InitialContext.doLookup(MyBean.class.getName()); According to a few sources, this should be a valid lookup method, but it throws a NameNotFoundException. What am I doing wrong? 回答1: According to what sources? I would personally use portable JNDI

Referencing a CDI Bean in a non managed CDI Bean

佐手、 提交于 2019-12-13 16:14:33
问题 Is it possible to obtain an instance of a CDI bean inside a class that is created using the new keyword? We're currently making some enhancements on an old application, and we're always getting a ContextNotActiveException everytime we do a programmatic lookup on CDI Singleton beans in our app. Code for obtaining a reference: public class ClassCreatedWithNew{ public void doSomething(){ MySingletonBean myBean = BeanManagerSupport.getInstance().getBean(MySingletonBean.class); } }

using an EJB 3.1 bean through a remote java stand-alone application

早过忘川 提交于 2019-12-13 16:06:59
问题 I have been trying to use Java EE 6 to create an Application Server based app which is to receive Job objects from a GWT Web Application and those Jobs would be pulled from a Java stand-alone application. I have been thinking that the EJB model would provide me with easy way to do remoting because my client app should be able to run on a different machine. I am using Glassfish 3.1 and Netbeans 7.0.1 as my IDE, I have also used eclipse Java EE to reproduce same problem. I have been facing the

Java EE declarative security, acquiring reference to a secured bean from application client

我是研究僧i 提交于 2019-12-13 15:19:01
问题 On 2 questions I would like to consult you. Background : I have written a test, Java EE application and added declarative security. The application is deployed on Glassfish 3.1. For unit testing I used JUnit with the embedded container for all beans with local interface. For the entry point of the appliaction, the SessionFacde bean, which has the only remote interface, I wrote a simple client which acquires reference to the SessionFace bean. Security annotations I applied for the

Can I use EJB Stateless Bean with CDI to maintain user session?

强颜欢笑 提交于 2019-12-13 15:12:00
问题 Based on this post http://www.adam-bien.com/roller/abien/entry/ejb_3_1_killed_the I use in my app @Named @Stateless bean for communication with a database (injecting EntityManager here) and display information on a jsf page. It's great facilitation since Java EE 5, but I have one question. Is it secure to use such beans for maintaining a user session (shopping cart etc)? I read a book about ejb 3.0 and I know that the same stateless bean could be used with many clients. What's the best

Null pointer error while using sessionfactory on Hibernate 4 with Spring 3.2

社会主义新天地 提交于 2019-12-13 08:47:59
问题 I'm struggling to figure out the exact problem, why the Null Pointer Error is thrown for Hibernate sessionFactory when I try to Auto wire sessionFactory from spring bean xml. Could somebody please help me out fix this. I'm new to Spring and deploying the app on Jboss server Here is the Spring-Config.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://www.springframework.org/schema/c" xmlns:context="http://www

Illegal character in path at index 25

孤者浪人 提交于 2019-12-13 07:26:33
问题 I'm getting an error: WARNING: Illegal character in path at index 25: file:/C:/Users/bkuhl/Java_Projects/CMT/build/web/WEB-INF/lib/antlr-2.7.6.jar I'm having trouble determining what the cause here might be. The stack trace is java.net.URISyntaxException: Illegal character in path at index 25: file:/C:/Users/bkuhl/Java_Projects/CMT/build/web/WEB-INF/lib/antlr-2.7.6.jar at java.net.URI$Parser.fail(URI.java:2829) at java.net.URI$Parser.checkChars(URI.java:3002) at java.net.URI$Parser

Glassfish doesn't bring up EntityManager if DAO is not Stateless

谁说我不能喝 提交于 2019-12-13 04:14:50
问题 I have an EAR application with an EJB module, that contains one persistence unit and many EJBs (as service and DAO layer). @Stateless public class BranchDAO { @PersistenceContext private EntityManager entityManager; } But DAOs as Stateless beans are not recommended. So I create this annotation using CDI: @Dependent @Stereotype @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface DAO { } After my DAO is changed to not use @Stateless : @DAO public class BranchDAO {