Showing posts with label EJB. Show all posts
Showing posts with label EJB. Show all posts

Sunday, May 12, 2024

Weblogic JNDI EJB names

 HOWTO

See also

 

GitHub

Java Naming and Directory Interface API

The naming environment provides four logical namespaces: java:comp, java:module, java:app, and java:global for objects available to components, modules, or applications or shared by all deployed applications. A Java EE component can access named system-provided and user-defined objects. The names of some system-provided objects, such as a default JDBC DataSource object, a default JMS connection factory, and a JTA UserTransaction object, are stored in the java:comp namespace. The Java EE platform allows a component to name user-defined objects, such as enterprise beans, environment entries, JDBC DataSource objects, and messaging destinations.

A Java EE component can also locate its environment naming context by using JNDI interfaces. A component can create a javax.naming.InitialContext object and look up the environment naming context in InitialContext under the name java:comp/env. A component’s naming environment is stored directly in the environment naming context or in any of its direct or indirect subcontexts.




JNDI names in deploy log

java:app/basicWebappEjb/AccountManagerImpl!dave.service.AccountManager.
java:module/AccountManagerImpl
java:module/AccountManagerImpl!dave.service.AccountManager
java:global/basicWebappEjb/AccountManagerImpl!dave.service.AccountManager 
java:app/basicWebappEjb/AccountManagerImpl
java:global/basicWebappEjb/AccountManagerImpl
<Creating application-scoped data source connection pool java:module/env/mavenArchetypeDataSource for Application basicWebappEjb, Module basicWebappEjb, URL = xxxxxx, Properties = xxxxxx.>
 


 Complete log

####<May 12, 2024, 5:09:42,007 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582007> <[severity-value: 64] [rid: 0] > <BEA-014021> <The EJB BankManagerImpl(Application: basicWebappEjb, EJBComponent: basicWebappEjb.war) has been successfully deployed. The following remote interfaces have been bound into JNDI with the specified JNDI names:>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.BankManager is bound with JNDI name java:module/BankManagerImpl.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.BankManager is bound with JNDI name java:app/basicWebappEjb/BankManagerImpl!dave.service.BankManager.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.BankManager is bound with JNDI name java:app/basicWebappEjb/BankManagerImpl.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.BankManager is bound with JNDI name java:global/basicWebappEjb/BankManagerImpl!dave.service.BankManager.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.BankManager is bound with JNDI name java:module/BankManagerImpl!dave.service.BankManager.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.BankManager is bound with JNDI name java:global/basicWebappEjb/BankManagerImpl.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014021> <The EJB AccountManagerImpl(Application: basicWebappEjb, EJBComponent: basicWebappEjb.war) has been successfully deployed. The following remote interfaces have been bound into JNDI with the specified JNDI names:>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.AccountManager is bound with JNDI name java:app/basicWebappEjb/AccountManagerImpl!dave.service.AccountManager.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.AccountManager is bound with JNDI name java:module/AccountManagerImpl.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.AccountManager is bound with JNDI name java:module/AccountManagerImpl!dave.service.AccountManager.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.AccountManager is bound with JNDI name java:global/basicWebappEjb/AccountManagerImpl!dave.service.AccountManager.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.AccountManager is bound with JNDI name java:app/basicWebappEjb/AccountManagerImpl.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-014022> <dave.service.AccountManager is bound with JNDI name java:global/basicWebappEjb/AccountManagerImpl.>
####<May 12, 2024, 5:09:42,008 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582008> <[severity-value: 64] [rid: 0] > <BEA-015075> <EJB deployment state ACTIVATED for [basicWebappEjb:basicWebappEjb, basicWebappEjb.war:basicWebappEjb:basicWebappEjb.war](BankManagerImpl, AccountManagerImpl) >
####<May 12, 2024, 5:09:42,009 PM Central European Summer Time> <Warning> <EclipseLink> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582009> <[severity-value: 16] [rid: 0] > <BEA-2005000> <2024-05-12 17:09:42.009--No partition instance associated with current SessionManager instance.>
####<May 12, 2024, 5:09:42,013 PM Central European Summer Time> <Info> <Deployer> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582013> <[severity-value: 64] [rid: 0] > <BEA-149060> <Module basicWebappEjb.war of application basicWebappEjb successfully transitioned from STATE_PREPARED to STATE_ADMIN on server AdminServer.>
####<May 12, 2024, 5:09:42,043 PM Central European Summer Time> <Info> <javax.enterprise.resource.webcontainer.jsf.config> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <weblogic> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582043> <[severity-value: 64] [rid: 0] > <jsf.config.listener.version> <Initializing Mojarra |version.string| for context '/basicWebappEjb'>
####<May 12, 2024, 5:09:42,166 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582166> <[severity-value: 64] [rid: 0] > <BEA-015075> <EJB deployment state STARTED for [basicWebappEjb:basicWebappEjb, basicWebappEjb.war:basicWebappEjb:basicWebappEjb.war](BankManagerImpl, AccountManagerImpl) >
####<May 12, 2024, 5:09:42,166 PM Central European Summer Time> <Info> <Deployer> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582166> <[severity-value: 64] [rid: 0] > <BEA-149059> <Module basicWebappEjb.war of application basicWebappEjb is transitioning from STATE_ADMIN to STATE_ACTIVE on server AdminServer.>
####<May 12, 2024, 5:09:42,166 PM Central European Summer Time> <Info> <EJB> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582166> <[severity-value: 64] [rid: 0] > <BEA-015075> <EJB deployment state ADMIN-TO-PRODUCTION for [basicWebappEjb:basicWebappEjb, basicWebappEjb.war:basicWebappEjb:basicWebappEjb.war](BankManagerImpl, AccountManagerImpl) >
####<May 12, 2024, 5:09:42,166 PM Central European Summer Time> <Info> <Deployer> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dc> <1715526582166> <[severity-value: 64] [rid: 0] > <BEA-149060> <Module basicWebappEjb.war of application basicWebappEjb successfully transitioned from STATE_ADMIN to STATE_ACTIVE on server AdminServer.>
####<May 12, 2024, 5:09:42,194 PM Central European Summer Time> <Info> <Deployer> <fedora> <AdminServer> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <15110b61-5602-4852-9ea1-778bb0a83817-000008dd> <1715526582194> <[severity-value: 64] [rid: 0] > <BEA-149074> <Successfully completed deployment task: [Deployer:149026]deploy application basicWebappEjb on AdminServer..>

Monday, January 18, 2016

Using Maven to create EJB project on Weblogic 12.2.1

First setup Maven for Oracle Weblogic plugin - http://danielveselka.blogspot.com/2016/01/using-maven-on-weblogic-1221-with-java.html 

Building Java EE Projects for WebLogic Server with Maven

http://docs.oracle.com/middleware/1221/core/MAVEN/weblogic_maven.htm#MAVEN8803

Create project from archetype
[dave@localhost weblogic]$ mvn archetype:generate -DarchetypeGroupId=com.oracle.weblogic.archetype -DarchetypeArtifactId=basic-webapp-ejb -DarchetypeVersion=12.2.1-0-0 -DgroupId=dave -DartifactId=dave-basic-webapp-ejb-project -Dversion=1.0-SNAPSHOT

Generated code
https://github.com/dveselka/weblogic

[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [com.oracle.weblogic.archetype:basic-webapp-ejb:12.2.1-0-0] found in catalog local
[INFO] Using property: groupId = dave
[INFO] Using property: artifactId = dave-basic-webapp-ejb-project
[INFO] Using property: version = 1.0-SNAPSHOT
[INFO] Using property: package = dave
Confirm properties configuration:
groupId: dave
artifactId: dave-basic-webapp-ejb-project
version: 1.0-SNAPSHOT
package: dave
 Y: : 
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: basic-webapp-ejb:12.2.1-0-0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: dave
[INFO] Parameter: artifactId, Value: dave-basic-webapp-ejb-project
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: dave
[INFO] Parameter: packageInPathFormat, Value: dave
[INFO] Parameter: package, Value: dave
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: dave
[INFO] Parameter: artifactId, Value: dave-basic-webapp-ejb-project
[INFO] project created from Archetype in dir: /home/dave/git/weblogic/dave-basic-webapp-ejb-project



[dave@localhost weblogic]$ find
.
./dave-basic-webapp-ejb-project
./dave-basic-webapp-ejb-project/pom.xml
./dave-basic-webapp-ejb-project/src
./dave-basic-webapp-ejb-project/src/main
./dave-basic-webapp-ejb-project/src/main/webapp
./dave-basic-webapp-ejb-project/src/main/webapp/css
./dave-basic-webapp-ejb-project/src/main/webapp/css/bootstrap.css
./dave-basic-webapp-ejb-project/src/main/webapp/index.xhtml
./dave-basic-webapp-ejb-project/src/main/webapp/WEB-INF
./dave-basic-webapp-ejb-project/src/main/webapp/WEB-INF/web.xml
./dave-basic-webapp-ejb-project/src/main/webapp/WEB-INF/beans.xml
./dave-basic-webapp-ejb-project/src/main/webapp/template.xhtml
./dave-basic-webapp-ejb-project/src/main/resources
./dave-basic-webapp-ejb-project/src/main/resources/META-INF
./dave-basic-webapp-ejb-project/src/main/resources/META-INF/persistence.xml
./dave-basic-webapp-ejb-project/src/main/java
./dave-basic-webapp-ejb-project/src/main/java/dave
./dave-basic-webapp-ejb-project/src/main/java/dave/entity
./dave-basic-webapp-ejb-project/src/main/java/dave/entity/Account.java
./dave-basic-webapp-ejb-project/src/main/java/dave/service
./dave-basic-webapp-ejb-project/src/main/java/dave/service/AccountManagerImpl.java
./dave-basic-webapp-ejb-project/src/main/java/dave/service/AccountManager.java
./dave-basic-webapp-ejb-project/src/main/java/dave/service/AccountBean.java
./dave-basic-webapp-ejb-project/src/main/java/dave/interceptor
./dave-basic-webapp-ejb-project/src/main/java/dave/interceptor/OnDeposit.java
./dave-basic-webapp-ejb-project/src/main/java/dave/interceptor/LogInterceptor.java
./dave-basic-webapp-ejb-project/src/main/scripts
./dave-basic-webapp-project
./dave-basic-webapp-project/pom.xml
./dave-basic-webapp-project/src
./dave-basic-webapp-project/src/main
./dave-basic-webapp-project/src/main/webapp
./dave-basic-webapp-project/src/main/webapp/css
./dave-basic-webapp-project/src/main/webapp/css/bootstrap.css
./dave-basic-webapp-project/src/main/webapp/index.xhtml
./dave-basic-webapp-project/src/main/webapp/WEB-INF
./dave-basic-webapp-project/src/main/webapp/WEB-INF/web.xml
./dave-basic-webapp-project/src/main/webapp/WEB-INF/beans.xml
./dave-basic-webapp-project/src/main/webapp/template.xhtml
./dave-basic-webapp-project/src/main/java
./dave-basic-webapp-project/src/main/java/dave
./dave-basic-webapp-project/src/main/java/dave/AccountBean.java

Code generated from Maven archetype is here https://bitbucket.org/daniel_veselka/weblogic

Start Weblogic console using http://localhost:7001/console/

Check what is the Context Root in Deployments section:  /basicWebappEjb

Connect to application using http://localhost:7001/basicWebappEjb/

Sunday, November 6, 2011

EJB 3.1 Singleton example

Simplest Possible EJB 3.1 Singleton - Injected Into Servlet 3.0, WAR Deployment
http://www.adam-bien.com/roller/abien/entry/simplest_possible_ejb_3_14

Java EE6 Tutorial : A Singleton Session Bean Example: counter
http://download.oracle.com/javaee/6/tutorial/doc/gipvi.html

A singleton session bean is instantiated once per application and exists for the lifecycle of the application. Singleton session beans are designed for circumstances in which a single enterprise bean instance is shared across and concurrently accessed by clients.

Singleton bean - implements cache

package testservice;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.PostConstruct;


/**
* Session Bean implementation class MasterDataCache
*/
@javax.ejb.Singleton
public class MasterDataCache implements MasterDataCacheLocal {

private Map cache;

@PostConstruct
public void initCache() {
System.out.println("MasterDataCache.initCache");
this.cache = new HashMap();
}

public Object get(String key) {
System.out.println("MasterDataCache.get " + key);
return this.cache.get(key);
}

public void store(String key, Object value) {
System.out.println("MasterDataCache.store " + key);
this.cache.put(key, value);
}

}




TestService Session Bean
package testservice;

import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.ejb.EJBContext;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;

import testejb.BackendBeanLocal;

/**
* Session Bean implementation class TestService
*/
@Stateless
public class TestService implements TestServiceRemote, TestServiceLocal {

@EJB
MasterDataCacheLocal masterDataCache;

@EJB
BackendBeanLocal service;

@Resource SessionContext sessionContext;

public void callService(){

System.out.println("principal=" + sessionContext.getCallerPrincipal());

if(masterDataCache.get("dave") == null){
System.out.println("TestService: masterDataCache.store" );
masterDataCache.store("dave","dave");
} else {
System.out.println("TestService: masterDataCache get" );
}

System.out.println("TestService: callService" );
service.runService();

}

}

Sunday, February 20, 2011

Access JPA2 entitites using Servlet and Session EJB

Introduction to Oracle Enterprise Pack for Eclipse 11g JPA Workbench
http://www.oracle.com/technetwork/articles/cioroianu-eclipse-jpa-084626.html

1.create Eclipse Web project testWeb


2.create Servlet calling Session EJB
package dave;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Set;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class TestJPAServlet
*/
public class TestJPAServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public TestJPAServlet() {
super();
// TODO Auto-generated constructor stub
}


@EJB
SessionJPA2EJBRemote remoteBusinessIntf;


/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

String nameParam = request.getParameter("emp");

Author author = remoteBusinessIntf.findAuthorByName(nameParam);

System.out.println("author " + author);

PrintWriter out = response.getWriter();

out.println("author" + author);

// Books
Set<Book> books = author.getBooks();

for (Book book : books) {
System.out.println("book " + book);
out.println("book" + book);
}
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}

}




3. call servlet using URL composed of testWeb project and Servlet
http://localhost:7001/testWeb/TestJPAServlet?name=dave



[EL Finest]: 2011-02-20 15:15:14.763--ServerSession(10406216)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--End deploying Persistence Unit books; session file:/home/dave/workspace/wls1033/testJPA2/build/classes/_books; state Deployed; factoryCount 1
[EL Finer]: 2011-02-20 15:15:14.763--ServerSession(10406216)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--client acquired
[EL Finer]: 2011-02-20 15:15:14.763--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--TX binding to tx mgr, status=STATUS_ACTIVE
[EL Finest]: 2011-02-20 15:15:14.764--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Execute query ReadObjectQuery(referenceClass=Author sql="SELECT ID, NAME, INSERT_TIMESTAMP FROM AUTHOR WHERE (ID = ?)")
[EL Finest]: 2011-02-20 15:15:14.764--ServerSession(10406216)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--reconnecting to external connection pool
[EL Fine]: 2011-02-20 15:15:14.765--ServerSession(10406216)--Connection(3587614)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--SELECT ID, NAME, INSERT_TIMESTAMP FROM AUTHOR WHERE (ID = ?)
bind => [1]
[EL Finer]: 2011-02-20 15:15:14.767--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--TX beforeCompletion callback, status=STATUS_ACTIVE
[EL Finer]: 2011-02-20 15:15:14.767--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--begin unit of work commit
[EL Finer]: 2011-02-20 15:15:14.768--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--TX afterCompletion callback, status=COMMITTED
[EL Finer]: 2011-02-20 15:15:14.769--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--end unit of work commit
[EL Finer]: 2011-02-20 15:15:14.769--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--release unit of work
[EL Finer]: 2011-02-20 15:15:14.769--ClientSession(26961217)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--client released
author dave.Author@1fbc274
[EL Finest]: 2011-02-20 15:15:14.77--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Execute query ReadAllQuery(name="books" referenceClass=Book )
[EL Finest]: 2011-02-20 15:15:14.77--ServerSession(10406216)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--reconnecting to external connection pool
[EL Fine]: 2011-02-20 15:15:14.771--ServerSession(10406216)--Connection(11941411)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--SELECT ID, TITLE, COUNTER, INSERT_TIMESTAMP, AUTHOR_ID FROM BOOK WHERE (AUTHOR_ID = ?)
bind => [1]
[EL Finest]: 2011-02-20 15:15:14.773--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Execute query ReadObjectQuery(name="author" referenceClass=Author )
[EL Finest]: 2011-02-20 15:15:14.774--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Register the existing object dave.Book@9c71bf
book dave.Book@9c71bf

Saturday, February 19, 2011

Enable JPA2 in Weblogic 10.3.4

WebLogic Server 10.3.4 Released - Key APIs of Java EE 6 and More
http://blogs.oracle.com/WebLogicServer/2011/01/weblogic_server_1034_released.html

Running JPA 2.0 API on WebLogic 10.3
http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#20110115:_JPA_2.0_using_EclipseLink_on_WebLogic_10.3.4.0

Enable JPA2 by adding JPA2 jar on PRE_CLASSPATH
http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#CIHDJHHI

# Set up BEA Home
BEA_HOME="/usr/app"

PRE_CLASSPATH=$BEA_HOME/modules/javax.persistence_1.0.0.0_2-0-0.jar:$BEA_HOME/modules/com.oracle.jpa2support_1.0.0.0_2-0.jar



Create JPA2 project in Eclipse Helios 3.6
Update Server Runtime to WLS 10.3.4


Create WLS 10.3.4 domain


Edit EJB project facets


Edit JPA facet


Create JPA entities from tables


Generated JPA class
package dave;

import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
import java.math.BigDecimal;


/**
* The persistent class for the BOOKS database table.
*
*/
@Entity
@Table(name="BOOKS")
public class Book implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@SequenceGenerator(name="BOOKS_ID_GENERATOR", sequenceName="ID_GEN")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BOOKS_ID_GENERATOR")
private long id;

private String author;

private BigDecimal counter;

@Column(name="INSERT_TIMESTAMP")
private Timestamp insertTimestamp;

private String title;

public Book() {
}

public long getId() {
return this.id;
}

public void setId(long id) {
this.id = id;
}

public String getAuthor() {
return this.author;
}

public void setAuthor(String author) {
this.author = author;
}

public BigDecimal getCounter() {
return this.counter;
}

public void setCounter(BigDecimal counter) {
this.counter = counter;
}

public Timestamp getInsertTimestamp() {
return this.insertTimestamp;
}

public void setInsertTimestamp(Timestamp insertTimestamp) {
this.insertTimestamp = insertTimestamp;
}

public String getTitle() {
return this.title;
}

public void setTitle(String title) {
this.title = title;
}

}


Edit persistence.xml
<persistence version="2.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_2_0.xsd">
<persistence-unit name="example" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/XE</jta-data-source>
<class>dave.Book</class>
<shared-cache-mode>NONE</shared-cache-mode><!-- shared-cache-mode must come after any class definitions (usually SE only) - the JPA schema is ordered -->
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="eclipselink.target-database" value="Oracle"/>
<property name="eclipselink.logging.level" value="FINEST"/>
<!-- new for 10.3.4.0 http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging#Server_Logging -->
<property name="eclipselink.logging.logger" value="DefaultLogger"/>
<!-- turn off DDL generation after the model is stable -->
<!-- property name="eclipselink.ddl-generation" value="drop-and-create-tables"/-->
<!-- property name="eclipselink.ddl-generation.output-mode" value="database"/-->
</properties>
</persistence-unit>
</persistence>

Thursday, December 23, 2010

Weblogic tool appc for EJB pre-compilation

<project basedir="." default="appc-ejb" name="appc-ejb">
<property environment="env"/>

<property name="wl.home" value="/app/wlserver_10.3"/>
<property name="application.dir" value="/home/dave/workspace/wls1033/testEJBGen/build/classes" />

<echo message="${wl.home}/server/lib"/>

<path id="wlappc.classpath">
<fileset dir="${wl.home}/server/lib">
<include name="*.jar"/>
</fileset>
</path>

<echo message="${toString:wlappc.classpath}"/>

<taskdef name="wlappc" classpathref="wlappc.classpath" classname="weblogic.ant.taskdefs.j2ee.Appc"/>

<target name="appc-ejb">
<wlappc source="${application.dir}"
keepgenerated="true"
verbose="true"
classpathref="wlappc.classpath"/>
</target>
</project>


Buildfile: /home/dave/workspace/wls1033/testEJBGen/build.xml
[echo] /app/wlserver_10.3/server/lib
[echo] /app/wlserver_10.3/server/lib/weblogic.jar
appc-ejb:
[wlappc] <Dec 23, 2010 9:28:28 PM CET> <Warning> <EJB> <BEA-010212> <The EJB 'TestSessionEJBGen(Jar: /home/dave/workspace/wls1033/testEJBGen/build/classes)' contains at least one method without an explicit transaction attribute setting. The default transaction attribute of Supports will be used for the following methods: remote[helloEJBGen(java.lang.String)] >
[wlappc] <Dec 23, 2010 9:28:31 PM CET> <Info> <J2EE> <BEA-160220> <Compilation completed successfully>
BUILD SUCCESSFUL


[dave@dave dave]$ pwd
/home/dave/workspace/wls1033/testEJBGen/build/classes/dave
[dave@dave dave]$ ls -lt
total 196
-rw-r--r--. 1 dave vesedan 3834 Dec 23 21:28 TestSessionEJBGen_pq6ajk_EOImpl_1033_WLStub.class
-rw-r--r--. 1 dave vesedan 1003 Dec 23 21:28 TestSessionEJBGen_pq6ajk_EOImplRTD.xml
-rw-r--r--. 1 dave vesedan 3387 Dec 23 21:28 TestSessionEJBGen_pq6ajk_EOImpl_WLSkel.class
-rw-r--r--. 1 dave vesedan 4957 Dec 23 21:28 TestSessionEJBGen_pq6ajk_HomeImpl_1033_WLStub.class
-rw-r--r--. 1 dave vesedan 4172 Dec 23 21:28 TestSessionEJBGen_pq6ajk_HomeImpl_WLSkel.class
-rw-r--r--. 1 dave vesedan 2635 Dec 23 21:28 TestSessionEJBGen_pq6ajk_ELOImpl.class
-rw-r--r--. 1 dave vesedan 4447 Dec 23 21:28 TestSessionEJBGen_pq6ajk_EOImpl.class
-rw-r--r--. 1 dave vesedan 3152 Dec 23 21:28 TestSessionEJBGen_pq6ajk_HomeImpl.class
-rw-r--r--. 1 dave vesedan 1087 Dec 23 21:28 TestSessionEJBGen_pq6ajk_HomeImplRTD.xml
-rw-r--r--. 1 dave vesedan 3763 Dec 23 21:28 TestSessionEJBGen_pq6ajk_Impl.class
-rw-r--r--. 1 dave vesedan 416 Dec 23 21:28 TestSessionEJBGen_pq6ajk_Intf.class
-rw-r--r--. 1 dave vesedan 2732 Dec 23 21:28 TestSessionEJBGen_pq6ajk_LocalHomeImpl.class
-rw-r--r--. 1 dave vesedan 2594 Dec 23 21:28 TestSessionEJBGen_pq6ajk_ELOImpl.java
-rw-r--r--. 1 dave vesedan 4006 Dec 23 21:28 TestSessionEJBGen_pq6ajk_EOImpl.java
-rw-r--r--. 1 dave vesedan 2999 Dec 23 21:28 TestSessionEJBGen_pq6ajk_HomeImpl.java
-rw-r--r--. 1 dave vesedan 4083 Dec 23 21:28 TestSessionEJBGen_pq6ajk_Impl.java
-rw-r--r--. 1 dave vesedan 626 Dec 23 21:28 TestSessionEJBGen_pq6ajk_Intf.java
-rw-r--r--. 1 dave vesedan 2540 Dec 23 21:28 TestSessionEJBGen_pq6ajk_LocalHomeImpl.java
-rw-r--r--. 1 dave vesedan 1447 Dec 23 20:53 TestSessionEJBGen.class
-rw-r--r--. 1 dave vesedan 162 Dec 23 20:53 TestSessionEJBGenLocal.class
-rw-r--r--. 1 dave vesedan 275 Dec 23 20:53 TestSessionEJBGenLocalHome.class
-rw-r--r--. 1 dave vesedan 275 Dec 23 20:53 TestSessionEJBGenRemote.class
-rw-r--r--. 1 dave vesedan 305 Dec 23 20:53 TestSessionEJBGenRemoteHome.class

Saturday, May 22, 2010

Foreign JNDI provider - call remote EJB

Create two domains - base_domain and remote_domain.


Setup Foreign JNDI provider on base_domain pointing to remote_domain.


http://download.oracle.com/docs/cd/E12840_01/wls/docs103/ConsoleHelp/taskhelp/jndi/ConfigureForeignJNDIProvider.html






Create session EJB calling remote session EJB and deploy to base_domain.
package testEAR;

import javax.ejb.Stateless;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import remoteEAR.RemoteEJBRemote;

/**
* Session Bean implementation class CallRemoteBean
*/
@Stateless
public class CallRemoteBean implements CallRemoteBeanLocal {

public CallRemoteBean() {
}


public void callRemoteBean(){


RemoteEJBRemote remoteEJB = null;
try {
remoteEJB = (RemoteEJBRemote)new InitialContext().lookup("RemoteEJB");
} catch (NamingException e) {
e.printStackTrace();
}
System.out.println("Calling remote");
String response = remoteEJB.hello();

System.out.println("Response remote=" + response);

}

}


Create session bean on remote_domain

package remoteEAR;

import javax.ejb.Stateless;

/**
* Session Bean implementation class RemoteEJB
*/
@Stateless(mappedName = "RemoteEJB")
public class RemoteEJB implements RemoteEJBRemote {

/**
* Default constructor.
*/
public RemoteEJB() {
}

public String hello(){
System.out.println("In remote");
return "Hello from remote";
}

}


All projects created in Eclipse 3.5


EJB3 reference injection problems
http://forums.oracle.com/forums/thread.jspa?messageID=4030853

http://msikora.typepad.com/michael_sikora_on_java_ee/page/2/

http://m-button.blogspot.com/2008/07/reminder-on-how-to-use-ejb3-with.html

http://biese.wordpress.com/2008/02/20/how-to-call-ejb3-from-jsp-servlet-and-stand-alone-application/

Thursday, September 3, 2009

EJB client connecting to Weblogic

Lookup service for EJB

requires wlfullclient.jar or wlthint3client.jar on classpath (must be first)

http://docs.oracle.com/cd/E17904_01/web.1111/e13717/wlthint3client.htm
http://docs.oracle.com/cd/E17904_01/web.1111/e13717/basics.htm#i1068418

    public void lookupService()  {
try {
Properties props = new Properties();
props.put(Context.PROVIDER_URL, "t3://localhost:7001");
props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
Context ctx = new InitialContext(props);
service = (TestTimer) ctx.lookup("ejb/TestTimer#testEAR.TestTimer");
} catch (NamingException e) {
e.printStackTrace();
}
}

Friday, July 31, 2009

Convert existing entity EJB to Entity Bean to EJB 3.0

Learn how to convert an EJB 2.0 entity bean to an EJB 3.0 entity bean, step by step.
http://www.oracle.com/technology/pub/articles/vohra_ejb.html?rssid=rss_otn_articles


Understanding Enterprise JavaBeans 3.0
http://edocs.bea.com/wls/docs103/ejb30/understanding.html
Because the EJB 3.0 programming model is so simple, BEA no longer supports using the EJBGen tags and code-generating tool on EJB 3.0 beans.