A
A
Andrey Unger2014-04-25 15:45:23
Java
Andrey Unger, 2014-04-25 15:45:23

Unit tests not working

There is a large multi-module Java EE application on maven. They use junit to test beans. But all of a sudden it stopped working. Thrown with exception:
org.apache.openejb.OpenEjbContainer$InitializationException: java.lang.IllegalArgumentException
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:442)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer .java:76)
at en.simplgroupp.ejb.TestRules.setUp(TestRules.java:71)

@EJB
Bean1Local bean1;
@EJB
Bean2Local bean2;
@EJB
Bean3Local bean3;

@Before
  public void setUp() throws Exception {
    System.setProperty("javax.xml.bind.JAXBContext","com.sun.xml.internal.bind.v2.ContextFactory");
    
    final Properties p = new Properties();
        p.put(/*настройки бд*/);  
        p.put(/*настройки бд*/);   
        p.put(/*настройки бд*/);  
  
        p.setProperty(Context.INITIAL_CONTEXT_FACTORY,  
        		"org.apache.openejb.client.LocalInitialContextFactory"); 
        
        final Context context = EJBContainer.createEJBContainer(p).getContext();
        context.bind("inject", this);
        

        bean1 = (Bean1Local) context.lookup("java:global/Module1-Name!ru.package_name.Bean1Local");
        bean2 = (Bean2Local) context.lookup("java:global/Module2-Name!ru.package_name.Bean2Local");
        bean3 = (Bean3Local) context.lookup("java:global/Module3-Name!ru.package_name.Bean3Local");
  }

It is EJBContainer.createEJBContainer() that falls off - I tried to call it differently, both with and without parameters - there is no difference. There are suspicions that some of the maven dependencies broke all the tests. But here's how to find and most importantly how to fight .... has not been working for a week.
Tell me who is in the subject?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Unger, 2015-09-11
@Cobalt

After so much time, I figured out the problem. The root lies in the 8th JDK. For it, OpenEJB must be a newer version.

<dependency>
            <groupId>org.apache.openejb</groupId>
            <artifactId>openejb-core</artifactId>
            <version>4.7.2</version>
            <scope>test</scope>
        </dependency>

That's how it works

N
Nikolai, 2014-11-12
@j_wayne

OpenEJB version to the studio. We need to look into the source code and see what is there in line 442. The line numbers do not match the current version.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question