This discussion is archived
8 Replies Latest reply: Dec 11, 2012 4:54 AM by RenévanWijk RSS

Weblogic 12c and EmbeddedContainer

964956 Newbie
Currently Being Moderated
Hi,

I have installed new Weblogc Server 12.1.1. Now I'm trying to start the embedded container in a test case. My classpath contains the wlfullclient.jar.

But I'm getting an exception during startup:

javax.ejb.EJBException: Error instantiating embedded server
     at weblogic.ejb.embeddable.EJBContainerImpl.initializeServer(EJBContainerImpl.java:99)
     at weblogic.ejb.embeddable.EJBContainerImpl.<init>(EJBContainerImpl.java:77)
     at weblogic.ejb.embeddable.EJBContainerProvider.createEJBContainer(EJBContainerProvider.java:17)
     at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:102)
     at br.com.samaiait.poc.service.DocumentoFisicoLocalTest.setUpClass(DocumentoFisicoLocalTest.java:30)
Caused by: weblogic.server.embed.EmbeddedServerException: Error creating default domain
     at weblogic.server.embed.internal.DomainConfig.createConfig(DomainConfig.java:235)
     at weblogic.server.embed.internal.DomainConfig.getDefaultDomain(DomainConfig.java:143)
     at weblogic.server.embed.internal.DomainConfig.ensureInitialized(DomainConfig.java:66)
     at weblogic.server.embed.internal.EmbeddedServerImpl.ensureStarted(EmbeddedServerImpl.java:152)
     at weblogic.server.embed.internal.EmbeddedServerImpl.start(EmbeddedServerImpl.java:106)
     at weblogic.ejb.embeddable.EJBContainerImpl.initializeServer(EJBContainerImpl.java:96)
     ... 37 more
Caused by: java.lang.NullPointerException
     at java.io.File.<init>(File.java:251)
     at weblogic.management.utils.PDevHelper.getUpgradeLaunchLocation(PDevHelper.java:79)
     at weblogic.management.utils.PDevHelper.getPDevClassLoader(PDevHelper.java:38)
     at weblogic.management.internal.CIEDomainGenerator.validateConfigFramework(CIEDomainGenerator.java:18)
     at weblogic.server.embed.internal.FullEmbeddedServerProvider.lookupDomainGenerator(FullEmbeddedServerProvider.java:87)
     at weblogic.server.embed.internal.EmbeddedServerProvider.createDefaultDomain(EmbeddedServerProvider.java:138)
     at weblogic.server.embed.internal.DomainConfig.createConfig(DomainConfig.java:233)
     ... 42 more


public class HelloTest {
private static EJBContainer ejbContainer;
private static Context ctx;

@BeforeClass
public static void setUpClass() throws Exception {
Map properties = new HashMap();
System.setProperty("weblogic.home", "D:\\dev\\wls1211_dev\\wlserver");
     properties.put(EJBContainer.PROVIDER, "weblogic.ejb.embeddable.EJBContainerProvider");
ejbContainer = EJBContainer.createEJBContainer(properties);
ctx = ejbContainer.getContext();
}

@AfterClass
public static void tearDownClass() throws Exception {
ejbContainer.close();
}

@Test
public void hello() throws NamingException {
HelloWorld helloWorld = (HelloWorld) ctx.lookup("java:global/classes/HelloWorld");
}
}

Can anybody help me?

Thanks.
  • 1. Re: Weblogic 12c and EmbeddedContainer
    651477 Explorer
    Currently Being Moderated
    hi,
    could you please paste all of your source code including the EJB?
    and the steps to reproduce the issue.

    Thanks,
    Amy
  • 2. Re: Weblogic 12c and EmbeddedContainer
    964956 Newbie
    Currently Being Moderated
    Hi,

    My ejb:

    import javax.ejb.Stateless;

    @Stateless
    public class HelloWorld {
    public String hello(String message) {
    return "Hello " + message;
    }
    }

    only execute the HelloTest class...
  • 3. Re: Weblogic 12c and EmbeddedContainer
    user777 Newbie
    Currently Being Moderated
    Do you mind if we meet via remote desktop and skype in order to see the error executing ?
  • 4. Re: Weblogic 12c and EmbeddedContainer
    964956 Newbie
    Currently Being Moderated
    I can't give acess. I'm in network the customer. But this code works for you?
    Thanks for your help
  • 5. Re: Weblogic 12c and EmbeddedContainer
    Jeets Journeyer
    Currently Being Moderated
    Can you please provide the imports that you are using for HelloTest?
  • 6. Re: Weblogic 12c and EmbeddedContainer
    964956 Newbie
    Currently Being Moderated
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    import java.util.HashMap;
    import java.util.Map;
    import javax.ejb.embeddable.EJBContainer;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import org.junit.AfterClass;
    import org.junit.BeforeClass;
    import org.junit.Test;

    public class HelloTest {

    private static EJBContainer ejbContainer;
    private static Context ctx;

    @BeforeClass
    public static void setUpClass() throws Exception {
    Map properties = new HashMap();
    System.setProperty("weblogic.home", "D:\\dev\\wls1211_dev\\wlserver");
    properties.put(EJBContainer.PROVIDER, "weblogic.ejb.embeddable.EJBContainerProvider");
    ejbContainer = EJBContainer.createEJBContainer(properties);
    ctx = ejbContainer.getContext();
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    ejbContainer.close();
    }

    @Test
    public void hello() throws NamingException {
    HelloWorld helloWorld = (HelloWorld) ctx.lookup("java:global/mavenproject1/HelloWorld");
    System.out.println(helloWorld.hello("teste"));
    }
    }



    import javax.ejb.Stateless;

    @Stateless
    public class HelloWorld {
    public String hello(String message) {
    return "Hello " + message;
    }
    }
  • 7. Re: Weblogic 12c and EmbeddedContainer
    651477 Explorer
    Currently Being Moderated
    Hi,
    you're starting the embedded container on an existing domain, which isn't supported publicly.
    if you try
    Map properties = new HashMap();
    properties.put(EJBContainer.MODULES, "<your ejb module>");
    properties.put(EJBContainer.PROVIDER, "weblogic.ejb.embeddable.EJBContainerProvider");
    ejbContainer = EJBContainer.createEJBContainer(properties);
    it should be fine.


    Thanks,
    Amy
  • 8. Re: Weblogic 12c and EmbeddedContainer
    RenévanWijk Oracle ACE
    Currently Being Moderated
    Sort of tested this as well and encountered the same problem. The enterprise bean looks as follows:
    package model.logic;
    
    import model.entities.Person;
    import javax.ejb.Local;
    
    @Local
    public interface Company {
        public void insertPerson(Person person);
    
        public void removePerson(Integer sofinummer);
    
        public void updatePerson(Person person);
    }
    with the implementation
    package model.logic;
    
    import model.entities.Person;
    import javax.ejb.Stateless;
    
    @Stateless(name = "Company", mappedName = "Company")
    public class CompanyBean implements Company {
        public void insertPerson(Person person) {
            System.out.println("insert " + person);
        }
    
        public void removePerson(Integer sofinummer) {
            System.out.println("remove " + sofinummer);
        }
    
        public void updatePerson(Person person) {
            System.out.println("update " + person);
        }
    }
    To test the embedded EJB container the following is used
    package test;
    
    import model.logic.Company;
    
    import javax.ejb.embeddable.EJBContainer;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import java.io.File;
    import java.util.HashMap;
    import java.util.Map;
    
    public class Test {
        public static void main(String[] args) {
            Map properties = new HashMap();
            File module = new File("C:\\temp\\frameworks\\Model\\out\\artifacts\\Model\\Model.jar");
            properties.put(EJBContainer.MODULES, module);
            properties.put(EJBContainer.PROVIDER, "weblogic.ejb.embeddable.EJBContainerProvider");
    
            System.out.println("testing some stuff");
    
            EJBContainer container = EJBContainer.createEJBContainer(properties);
            Context context = container.getContext();
            try {
                Company company = (Company) context.lookup("java:module/Company");
                company.removePerson(12345);
            } catch (NamingException e) {
                e.printStackTrace();
            }
            container.close();
        }
    }
    To run the test (after compiling and packaging the different projects in jars) we use the following shell script
    set JAVA_HOME=C:\bea\jdk1.6.0_35
    
    set MEM_ARGS=-server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC
    
    set CLASSPATH=C:\temp\frameworks\Model\out\artifacts\Model\Model.jar;C:\temp\frameworks\EmbeddedEJB\lib\wlfullclient.jar;C:\temp\frameworks\EmbeddedEJB\out\artifacts\Runner\Runner.jar
    
    %JAVA_HOME%\bin\java %MEM_ARGS% test.Test
    The wlfullclient.jar (for version 12.1.1.0) is build by using the instructions presented here: http://docs.oracle.com/cd/E17904_01/web.1111/e13717/jarbuilder.htm#BABCGHFH

    When the test is run the following is observed:
    C:\temp>run.cmd
    
    C:\temp>set JAVA_HOME=C:\bea\jdk1.6.0_35
    
    C:\temp>set MEM_ARGS=-server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC
    
    C:\temp>set CLASSPATH=C:\temp\frameworks\Model\out\artifacts\Model\Model.jar;C:\temp\frameworks\EmbeddedEJB\lib\wlfullclient.jar;C:\temp\frameworks\EmbeddedEJB\out\artifacts\Runner\Runner.jar
    
    C:\temp>C:\bea\jdk1.6.0_35\bin\java -server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC test.Test
    testing some stuff
    Exception in thread "main" javax.ejb.EJBException: Error instantiating embedded server
            at weblogic.ejb.embeddable.EJBContainerImpl.initializeServer(EJBContainerImpl.java:99)
            at weblogic.ejb.embeddable.EJBContainerImpl.<init>(EJBContainerImpl.java:77)
            at weblogic.ejb.embeddable.EJBContainerProvider.createEJBContainer(EJBContainerProvider.java:17)
            at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:102)
            at test.Test.main(Test.java:21)
    Caused by: weblogic.server.embed.EmbeddedServerException: Error creating default domain
            at weblogic.server.embed.internal.DomainConfig.createConfig(DomainConfig.java:235)
            at weblogic.server.embed.internal.DomainConfig.getDefaultDomain(DomainConfig.java:143)
            at weblogic.server.embed.internal.DomainConfig.ensureInitialized(DomainConfig.java:66)
            at weblogic.server.embed.internal.EmbeddedServerImpl.ensureStarted(EmbeddedServerImpl.java:152)
            at weblogic.server.embed.internal.EmbeddedServerImpl.start(EmbeddedServerImpl.java:106)
            at weblogic.ejb.embeddable.EJBContainerImpl.initializeServer(EJBContainerImpl.java:96)
            ... 4 more
    Caused by: java.lang.NullPointerException
            at java.io.File.<init>(File.java:222)
            at weblogic.management.utils.PDevHelper.getUpgradeLaunchLocation(PDevHelper.java:79)
            at weblogic.management.utils.PDevHelper.getPDevClassLoader(PDevHelper.java:38)
            at weblogic.management.internal.CIEDomainGenerator.validateConfigFramework(CIEDomainGenerator.java:18)
            at weblogic.server.embed.internal.FullEmbeddedServerProvider.lookupDomainGenerator(FullEmbeddedServerProvider.java:87)
            at weblogic.server.embed.internal.EmbeddedServerProvider.createDefaultDomain(EmbeddedServerProvider.java:138)
            at weblogic.server.embed.internal.DomainConfig.createConfig(DomainConfig.java:233)
            ... 9 more

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points