Showing posts with label JNDI. Show all posts
Showing posts with label JNDI. Show all posts

Wednesday, November 5, 2025

Weblogic 14.1.2 EJB client with JNDI lookup

 HOWTO



Git


Blog

 

 Add t3 client  

dependency>
    <groupId>com.oracle.weblogic</groupId>
    <artifactId>wlthint3client</artifactId>
    <version>14.1.2-0-0</version>
</dependency>

JNDI names

     java:global/basicWebappEjb/AccountManagerEJB!dave.service.AccountManagerRemote

Trying JNDI name: java:global/basicWebappEjb/AccountManagerEJB!dave.service.AccountManagerRemote
✓ Successfully looked up AccountManagerRemote EJB at: java:global/basicWebappEjb/AccountManagerEJB!dave.service.AccountManagerRemote
Depositing $100.5 to account: john.doe

EJB

package dave.service;

import javax.ejb.Stateless;
import javax.ejb.Remote;
import javax.ejb.Local;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.annotation.sql.DataSourceDefinition;

import dave.entity.Account;

/**
 * Option 1: Use name attribute to define the EJB name
 * The JNDI name will be: java:global/<app-name>/<ejb-name>!<interface>
 * 
 * Option 2: Use mappedName for explicit JNDI binding (WebLogic-specific)
 * mappedName = "ejb/AccountManager"
 */
@Stateless(name = "AccountManagerEJB")
@Local(AccountManager.class)
@Remote(AccountManagerRemote.class)
//Data Source defined for JPA. It assume the derby database is started up and listen to localhost:1527
@DataSourceDefinition(name = "java:module/env/mavenArchetypeDataSource", className = "org.apache.derby.jdbc.ClientXADataSource", portNumber = 1527, serverName = "localhost", databaseName = "examples", user = "examples", password = "examples", properties={"create=true", "weblogic.TestTableName=SQL SELECT 1 FROM SYS.SYSTABLES"})
public class AccountManagerImpl implements AccountManager, AccountManagerRemote {

  @PersistenceContext
  private EntityManager em;
  
  public void depositOnAccount(String name, float amount) {
    Account account = em.find(Account.class, name);
    if (account == null) {
      account = new Account();
      account.setName(name);
    }
    account.setAmount(account.getAmount() + amount);
    em.persist(account);
  }
  
  public Account findAccount(String name) {
    return em.find(Account.class, name);
  }
}

JNDI EJB client

/**
 * External Java EJB Client for AccountManager
 */
package dave.client;

import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import dave.service.AccountManagerRemote;
import dave.entity.Account;

public class AccountManagerClient {

    private static final String WEBLOGIC_JNDI_FACTORY = "weblogic.jndi.WLInitialContextFactory";
    private static final String PROVIDER_URL = "t3://localhost:7001";
    
    /**
     * JNDI lookup patterns for WebLogic:
     * 
     * Pattern 1 (Portable Global JNDI):
     * java:global/<app-name>/<module-name>/<bean-name>!<fully-qualified-interface-name>
     * Example: java:global/basicWebappEjb/AccountManagerImpl!dave.service.AccountManagerRemote
     * 
     * Pattern 2 (WebLogic-specific):
     * <ejb-name>#<fully-qualified-interface-name>
     * Example: AccountManagerImpl#dave.service.AccountManagerRemote
     * 
     * Pattern 3 (Application-scoped):
     * java:app/<module-name>/<bean-name>!<fully-qualified-interface-name>
     */
    // Multiple JNDI names to try - WebLogic registers EJBs with multiple patterns
    private static final String[] JNDI_NAMES = {
        // Using custom name="AccountManagerEJB"
        "java:global/basicWebappEjb/AccountManagerEJB!dave.service.AccountManagerRemote",
        "java:global/basicWebappEjb/AccountManagerEJB",
        // Fallback to default names
        "java:global/basicWebappEjb/AccountManagerImpl!dave.service.AccountManagerRemote",
        "java:global/basicWebappEjb/AccountManagerImpl",
        "basicWebappEjb/AccountManagerEJB!dave.service.AccountManagerRemote",
        "ejb/AccountManager#dave.service.AccountManagerRemote"
    };
    
    public static void main(String[] args) {
        AccountManagerClient client = new AccountManagerClient();
        try {
            client.testEJB();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public void testEJB() throws NamingException {
        Context context = null;
        try {
            // Get initial context
            context = getInitialContext();
            
            // Try multiple JNDI names
            AccountManagerRemote accountManager = null;
            String successfulJndiName = null;
            
            for (String jndiName : JNDI_NAMES) {
                try {
                    System.out.println("Trying JNDI name: " + jndiName);
                    accountManager = (AccountManagerRemote) context.lookup(jndiName);
                    successfulJndiName = jndiName;
                    System.out.println("✓ Successfully looked up AccountManagerRemote EJB at: " + jndiName);
                    break;
                } catch (NamingException e) {
                    System.out.println("✗ Failed: " + e.getMessage());
                }
            }
            
            if (accountManager == null) {
                throw new NamingException("Could not find EJB with any of the attempted JNDI names");
            }
            
            // Test deposit
            String accountName = "john.doe";
            float depositAmount = 100.50f;
            
            System.out.println("Depositing $" + depositAmount + " to account: " + accountName);
            accountManager.depositOnAccount(accountName, depositAmount);
            
            // Test find
            Account account = accountManager.findAccount(accountName);
            if (account != null) {
                System.out.println("Account found: " + account.getName() + 
                                   ", Balance: $" + account.getAmount());
            } else {
                System.out.println("Account not found");
            }
            
        } finally {
            if (context != null) {
                try {
                    context.close();
                } catch (NamingException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    
    /**
     * Create InitialContext for WebLogic Server
     */
    private Context getInitialContext() throws NamingException {
        Hashtable<String, String> env = new Hashtable<>();
        env.put(Context.INITIAL_CONTEXT_FACTORY, WEBLOGIC_JNDI_FACTORY);
        env.put(Context.PROVIDER_URL, PROVIDER_URL);
        
        // Add credentials - required for WebLogic security
        env.put(Context.SECURITY_PRINCIPAL, "weblogic");
        env.put(Context.SECURITY_CREDENTIALS, "weblogic123");
        
        return new InitialContext(env);
    }
}

Run client from Maven 


dave@fedora:/git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project$ mvn compile exec:java -Dexec.mainClass="./src/main/java/dave/client/AccountManagerClient.java"
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/3.1.0/exec-maven-plugin-3.1.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/3.1.0/exec-maven-plugin-3.1.0.pom (14 kB at 24 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/mojo-parent/69/mojo-parent-69.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/mojo-parent/69/mojo-parent-69.pom (35 kB at 569 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/3.1.0/exec-maven-plugin-3.1.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/3.1.0/exec-maven-plugin-3.1.0.jar (73 kB at 982 kB/s)
[INFO] 
[INFO] -----------------&lt; dave:dave-basic-webapp-ejb-project &gt;-----------------
[INFO] Building basicWebappEjb 1.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ dave-basic-webapp-ejb-project ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] 
[INFO] --- compiler:2.3.2:compile (default-compile) @ dave-basic-webapp-ejb-project ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- exec:3.1.0:java (default-cli) @ dave-basic-webapp-ejb-project ---
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-exec/1.3/commons-exec-1.3.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-exec/1.3/commons-exec-1.3.pom (11 kB at 200 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-parent/35/commons-parent-35.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-parent/35/commons-parent-35.pom (58 kB at 1.2 MB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-exec/1.3/commons-exec-1.3.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-exec/1.3/commons-exec-1.3.jar (54 kB at 990 kB/s)
Trying JNDI name: java:global/basicWebappEjb/AccountManagerEJB!dave.service.AccountManagerRemote
✓ Successfully looked up AccountManagerRemote EJB at: java:global/basicWebappEjb/AccountManagerEJB!dave.service.AccountManagerRemote
Depositing $100.5 to account: john.doe


Running with debug

directory /git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/src/main/resources
excludes []
includes []
[DEBUG] ignoreDelta true
[INFO] Copying 1 resource from src/main/resources to target/classes
[DEBUG] Copying file META-INF/persistence.xml
[DEBUG] file persistence.xml has a filtered file extension
[DEBUG] Using 'null' encoding to copy filtered resource 'persistence.xml'.
[DEBUG] copy /git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/src/main/resources/META-INF/persistence.xml to /git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/target/classes/META-INF/persistence.xml
[DEBUG] no user filter components
[INFO] 
[INFO] --- compiler:2.3.2:compile (default-compile) @ dave-basic-webapp-ejb-project ---
[DEBUG] Using mirror maven-default-http-blocker (http://0.0.0.0/) for apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository).
[DEBUG] Using mirror maven-default-http-blocker (http://0.0.0.0/) for codehaus.snapshots (http://snapshots.repository.codehaus.org).
[DEBUG] Using mirror maven-default-http-blocker (http://0.0.0.0/) for snapshots (http://snapshots.maven.codehaus.org/maven2).
[DEBUG] Using mirror maven-default-http-blocker (http://0.0.0.0/) for central (http://repo1.maven.org/maven2).
[DEBUG] Dependency collection stats {ConflictMarker.analyzeTime=227695, ConflictMarker.markTime=109858, ConflictMarker.nodeCount=101, ConflictIdSorter.graphTime=103733, ConflictIdSorter.topsortTime=20479, ConflictIdSorter.conflictIdCount=27, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=1003151, ConflictResolver.conflictItemCount=49, DfDependencyCollector.collectTime=66446805, DfDependencyCollector.transformTime=1481816}
[DEBUG] org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2
[DEBUG]    org.apache.maven:maven-plugin-api:jar:2.0.6:compile
[DEBUG]    org.apache.maven:maven-artifact:jar:2.0.6:compile
[DEBUG]    org.apache.maven:maven-core:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-settings:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-profile:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-model:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-repository-metadata:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-error-diagnostics:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-project:jar:2.0.6:compile
[DEBUG]          org.apache.maven:maven-plugin-registry:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-plugin-descriptor:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-monitor:jar:2.0.6:compile
[DEBUG]    org.apache.maven:maven-toolchain:jar:1.0:compile
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:2.0.5:compile
[DEBUG]    org.codehaus.plexus:plexus-compiler-api:jar:1.8.1:compile
[DEBUG]    org.codehaus.plexus:plexus-compiler-manager:jar:1.8.1:compile
[DEBUG]    org.codehaus.plexus:plexus-compiler-javac:jar:1.8.1:runtime
[DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-compiler-plugin:2.3.2
[DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-compiler-plugin:2.3.2
[DEBUG]   Imported:  < maven.api
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-compiler-plugin:2.3.2
[DEBUG]   Included: org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:2.0.5
[DEBUG]   Included: org.codehaus.plexus:plexus-compiler-api:jar:1.8.1
[DEBUG]   Included: org.codehaus.plexus:plexus-compiler-manager:jar:1.8.1
[DEBUG]   Included: org.codehaus.plexus:plexus-compiler-javac:jar:1.8.1
[DEBUG] Loading mojo org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-compiler-plugin:2.3.2, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@5ffd2b27]
[DEBUG] Configuring mojo execution 'org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile:default-compile' with basic configurator -->
[DEBUG]   (f) basedir = /git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project
[DEBUG]   (f) buildDirectory = /git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/target
[DEBUG]   (f) classpathElements = [/git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/target/classes, /home/dave/.m2/repository/javax/javaee-web-api/6.0/javaee-web-api-6.0.jar, /app/weblogic/weblogic-14.1.2/wlserver/server/lib/wlthint3client.jar, /app/weblogic/weblogic-14.1.2/wlserver/server/lib/weblogic.jar]
[DEBUG]   (f) compileSourceRoots = [/git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/src/main/java]
[DEBUG]   (f) compilerId = javac
[DEBUG]   (f) debug = true
[DEBUG]   (f) failOnError = true
[DEBUG]   (f) fork = false
[DEBUG]   (f) generatedSourcesDirectory = /git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/target/generated-sources/annotations
[DEBUG]   (f) optimize = false
[DEBUG]   (f) outputDirectory = /git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/target/classes
[DEBUG]   (f) outputFileName = basicWebappEjb
[DEBUG]   (f) projectArtifact = dave:dave-basic-webapp-ejb-project:war:1.0-SNAPSHOT
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@588307f7
[DEBUG]   (f) showDeprecation = false
[DEBUG]   (f) showWarnings = false
[DEBUG]   (f) source = 1.8
[DEBUG]   (f) staleMillis = 0
[DEBUG]   (f) target = 1.8
[DEBUG]   (f) verbose = false
[DEBUG] -- end configuration --
[DEBUG] Using compiler 'javac'.
[DEBUG] Source directories: [/git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/src/main/java]
[DEBUG] Classpath: [/git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/target/classes
 /home/dave/.m2/repository/javax/javaee-web-api/6.0/javaee-web-api-6.0.jar
 /app/weblogic/weblogic-14.1.2/wlserver/server/lib/wlthint3client.jar
 /app/weblogic/weblogic-14.1.2/wlserver/server/lib/weblogic.jar]
[DEBUG] Output directory: /git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/target/classes
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- exec:3.1.0:java (default-cli) @ dave-basic-webapp-ejb-project ---
[DEBUG] Dependency collection stats {ConflictMarker.analyzeTime=23194, ConflictMarker.markTime=30654, ConflictMarker.nodeCount=4, ConflictIdSorter.graphTime=5608, ConflictIdSorter.topsortTime=10155, ConflictIdSorter.conflictIdCount=4, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=144167, ConflictResolver.conflictItemCount=4, DfDependencyCollector.collectTime=11120279, DfDependencyCollector.transformTime=226745}
[DEBUG] org.codehaus.mojo:exec-maven-plugin:jar:3.1.0
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:3.4.2:compile
[DEBUG]    org.codehaus.plexus:plexus-component-annotations:jar:2.1.1:compile (optional)
[DEBUG]    org.apache.commons:commons-exec:jar:1.3:compile
[DEBUG] Created new class realm plugin>org.codehaus.mojo:exec-maven-plugin:3.1.0
[DEBUG] Importing foreign packages into class realm plugin>org.codehaus.mojo:exec-maven-plugin:3.1.0
[DEBUG]   Imported:  < maven.api
[DEBUG] Populating class realm plugin>org.codehaus.mojo:exec-maven-plugin:3.1.0
[DEBUG]   Included: org.codehaus.mojo:exec-maven-plugin:jar:3.1.0
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:3.4.2
[DEBUG]   Included: org.codehaus.plexus:plexus-component-annotations:jar:2.1.1
[DEBUG]   Included: org.apache.commons:commons-exec:jar:1.3
[DEBUG] Loading mojo org.codehaus.mojo:exec-maven-plugin:3.1.0:java from plugin realm ClassRealm[plugin>org.codehaus.mojo:exec-maven-plugin:3.1.0, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@5ffd2b27]
[DEBUG] Configuring mojo execution 'org.codehaus.mojo:exec-maven-plugin:3.1.0:java:default-cli' with basic configurator -->
[DEBUG]   (f) addOutputToClasspath = true
[DEBUG]   (f) addResourcesToClasspath = false
[DEBUG]   (f) additionalClasspathElements = [/app/weblogic/weblogic-14.1.2/wlserver/server/lib/wlthint3client.jar]
[DEBUG]   (f) arguments = []
[DEBUG]   (f) classpathScope = runtime
[DEBUG]   (f) cleanupDaemonThreads = false
[DEBUG]   (f) daemonThreadJoinTimeout = 15000
[DEBUG]   (f) includePluginDependencies = false
[DEBUG]   (f) includeProjectDependencies = true
[DEBUG]   (f) keepAlive = false
[DEBUG]   (f) killAfter = -1
[DEBUG]   (f) mainClass = dave.client.AccountManagerClient
[DEBUG]   (f) pluginDependencies = [org.codehaus.mojo:exec-maven-plugin:maven-plugin:3.1.0:, org.codehaus.plexus:plexus-utils:jar:3.4.2:compile, org.codehaus.plexus:plexus-component-annotations:jar:2.1.1:compile, org.apache.commons:commons-exec:jar:1.3:compile]
[DEBUG]   (f) preloadCommonPool = 0
[DEBUG]   (f) project = MavenProject: dave:dave-basic-webapp-ejb-project:1.0-SNAPSHOT @ /git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/pom.xml
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@588307f7
[DEBUG]   (f) skip = false
[DEBUG]   (f) stopUnresponsiveDaemonThreads = false
[DEBUG] -- end configuration --
[DEBUG] Invoking : dave.client.AccountManagerClient.main()
[DEBUG] Plugin Dependencies will be excluded.
[DEBUG] Project Dependencies will be included.
[DEBUG] Collected project artifacts []
[DEBUG] Collected project classpath [/git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/target/classes]
[DEBUG] Adding to classpath : /git/weblogic/dave-basic-project-14.1.2/dave-basic-webapp-ejb-project/target/classes
[DEBUG] Adding additional classpath element: /app/weblogic/weblogic-14.1.2/wlserver/server/lib/wlthint3client.jar to classpath
[DEBUG] joining on thread Thread[#34,dave.client.AccountManagerClient.main(),5,dave.client.AccountManagerClient]
Trying JNDI name: java:global/basicWebappEjb/AccountManagerEJB!dave.service.AccountManagerRemote
✓ Successfully looked up AccountManagerRemote EJB at: java:global/basicWebappEjb/AccountManagerEJB!dave.service.AccountManagerRemote
Depositing $100.5 to account: john.doe


Check JNDI in remote Weblogic 14.1.2 console 

 

 

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..>

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/