[Microcontainer] - problem with microcontainer-alpha9 while testing ejb3s. cann
by MmarcoM
hello all,
i have just upgraded jboss ejb3 to rc9 release, so ihav updated also the embeddable alpha to rc9.
i am running junit test by starting jboss microcontainer in my junit (testNG) test
i am currently using maven2... btw here' smy pom
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
| <modelVersion>4.0.0</modelVersion>
| <groupId>ejbJ2ME</groupId>
| <artifactId>ejbJ2ME</artifactId>
| <packaging>jar</packaging>
| <version>1.0-SNAPSHOT</version>
| <name>ejbJ2ME</name>
| <url>http://maven.apache.org</url>
| <dependencies>
| <dependency>
| <groupId>junit</groupId>
| <artifactId>junit</artifactId>
| <version>3.8.1</version>
| <scope>test</scope>
| </dependency>
| <dependency>
| <groupId>org.testng</groupId>
| <artifactId>testng</artifactId>
| <version>5.1</version>
| <scope>test</scope>
| <classifier>jdk15</classifier>
| </dependency>
| <dependency>
| <groupId>j2meCore</groupId>
| <artifactId>J2MECore</artifactId>
| <version>1.0-SNAPSHOT</version>
| </dependency>
| <dependency>
| <groupId>microcontainer</groupId>
| <artifactId>hibernate-all</artifactId>
| <version>rc9</version>
| <scope>system</scope>
| <systemPath>${basedir}\lib\hibernate-all-rc9.jar</systemPath>
| </dependency>
| <dependency>
| <groupId>microcontainer</groupId>
| <artifactId>jboss-ejb3-all</artifactId>
| <version>rc9</version>
| <scope>system</scope>
| <systemPath>${basedir}\lib\jboss-ejb3-all-rc9.jar</systemPath>
| </dependency>
| <dependency>
| <groupId>microcontainer</groupId>
| <artifactId>jcainflow</artifactId>
| <version>rc9</version>
| <scope>system</scope>
| <systemPath>${basedir}\lib\jcainflow-rc9.jar</systemPath>
| </dependency>
| <dependency>
| <groupId>microcontainer</groupId>
| <artifactId>thirdparty-all</artifactId>
| <version>rc9</version>
| <scope>system</scope>
| <systemPath>${basedir}\lib\thirdparty-all-rc9.jar</systemPath>
| </dependency>
| <dependency>
| <groupId>microcontainer</groupId>
| <artifactId>jms-ra</artifactId>
| <version>rc9</version>
| <scope>system</scope>
| <systemPath>${basedir}\lib\jms-ra-rc9.jar</systemPath>
| </dependency>
| <dependency>
| <groupId>microcontainer</groupId>
| <artifactId>ehcache</artifactId>
| <version>1.2</version>
| <scope>system</scope>
| <systemPath>${basedir}\lib\ehcache-1.2.jar</systemPath>
| </dependency>
|
| <dependency>
| <groupId>dbunit</groupId>
| <artifactId>dbunit</artifactId>
| <version>2.1</version>
| <scope>test</scope>
| </dependency>
| </dependencies>
| <build>
| <testSourceDirectory>src/test</testSourceDirectory>
| <testResources>
| <testResource>
| <directory>src/test/resources</directory>
| <includes>
| <include>*.*</include>
| </includes>
| </testResource>
| </testResources>
| <pluginManagement>
| <plugins>
| <plugin>
| <groupId>org.apache.maven.plugins</groupId>
| <artifactId>maven-compiler-plugin</artifactId>
| <configuration>
| <source>1.5</source>
| <target>1.5</target>
| </configuration>
| </plugin>
| <plugin>
| <groupId>org.apache.maven.plugins</groupId>
| <artifactId>maven-surefire-plugin</artifactId>
| <!--<version>2.8-SNAPSHOT</version>-->
| <configuration>
| <suiteXmlFiles>
| <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
| </suiteXmlFiles>
| </configuration>
| </plugin>
| <plugin>
| <groupId>org.apache.maven.plugins</groupId>
| <artifactId>maven-surefire-report-plugin</artifactId>
| </plugin>
| </plugins>
| </pluginManagement>
| </build>
| <pluginRepositories>
| <pluginRepository>
| <id>tapestry.javaforge</id>
| <url>http://howardlewisship.com/repository</url>
| </pluginRepository>
| </pluginRepositories>
| </project>
|
i have a base junit test which is supposed to statup EJB3 container
here's code
| package example1;
|
|
|
|
| import java.util.Hashtable;
|
| import org.jboss.ejb3.embedded.*;
| import org.testng.annotations.Configuration;
| import org.testng.annotations.ExpectedExceptions;
| import org.testng.annotations.Test;
| import junit.framework.*;
| import junit.extensions.*;
|
|
| import javax.naming.*;
|
| /**
| * Boots the JBoss Microcontainer with an EJB3 configuration.
| * <p>
| * You can also use this class to lookup managed beans from JNDI.
| *
| * @author christian.bauer(a)jboss.com
| */
| public class EJB3Container {
|
| private static InitialContext initialContext;
| private EJB3StandaloneDeployer deployer;
|
|
| @Configuration(groups = "integration.ejb3", beforeTest = true)
| public void startup() {
| try {
|
| System.err.println("---- bootstrapping EJB3 container....");
|
| // Boot the JBoss Microcontainer with EJB3 settings, loads ejb3-interceptors-aop.xml
| EJB3StandaloneBootstrap.boot(null);
| System.err.println("...... deploying embedded-jboss-beans....");
| EJB3StandaloneBootstrap.scanClasspath();
|
| // Deploy everything we got
| deployer = new EJB3StandaloneDeployer();
| deployer.setKernel(EJB3StandaloneBootstrap.getKernel());
| deployer.create();
| System.err.println("...... deployer created....");
|
| deployer.start();
| System.err.println("...... deployer started....");
|
|
| Hashtable props = new Hashtable();
| props.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
| props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
| // Create InitialContext from jndi.properties
| initialContext = new InitialContext(props);
| System.err.println("---- end of bootstrapping EJB3 container....InitialContext is:");
|
| } catch (Exception ex) {
| ex.printStackTrace();
| throw new RuntimeException(ex);
| }
| }
|
|
|
|
| @Configuration(groups = "integration.ejb3", afterTest = true)
| public void shutdown() {
| try {
| System.err.println("---- Invoking EJB3.shutdown..");
| deployer.stop();
| deployer.destroy();
| EJB3StandaloneBootstrap.shutdown();
| } catch (Exception ex) {
| throw new RuntimeException(ex);
| }
| }
|
|
|
|
|
|
|
|
| public static Object lookup(String beanName) {
| try {
|
| return initialContext.lookup(beanName);
| } catch (NamingException ex) {
| throw new RuntimeException("Couldn't lookup: " + beanName, ex);
| }
| }
|
| }
|
i have a stateless session bean, here's excerpt of class
| import com.mm.j2me.core.Agency;
| import com.mm.j2me.core.JobApplication;
| import com.mm.j2me.core.Opportunity;
| import javax.persistence.*;
| import javax.ejb.*;
| import javax.persistence.*;
| import java.util.ArrayList;
| import java.util.Collection;
| import java.util.Iterator;
| import java.util.List;
| import java.util.Vector;
|
| @Stateless
| @Local ( {FacadeIF.class})
|
| public class TestFacade implements FacadeIF {
|
| @PersistenceContext
| EntityManager em;
| ..
|
i m trying to look it up in my tests usign following code:
| TestFacade sessionFacade = (TestFacade) EJB3Container.lookup("TestFacade/local");
|
|
it results in a NUllPointerException.........
can anyone help me out in trying to find why i cannot lookup my EJB?
am i starting EJB3 container in the wrong way?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973754#3973754
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973754
19 years, 7 months
[EJB 3.0] - Problem with testing EJB3-rc9
by MmarcoM
hi all,
i am trying to test my ejb3 ejbs by starting the jboss microcontainer
i am using release rc9, and its related microcontainer..
here's my persistence.xml
| <!-- Persistence file for EJB3 application -->
| <persistence>
| <persistence-unit name="j2me">
| <jta-data-source>java:/DefaultDS</jta-data-source>
| <properties>
| <property name="hibernate.hbm2ddl.auto"
| </persistence-unit>
| </persistence>
|
i have this base test class which starts up jboss microcontainer (only relevant code
| try {
|
| System.err.println("---- bootstrapping EJB3 container....");
|
| // Boot the JBoss Microcontainer with EJB3 settings, loads ejb3-interceptors-aop.xml
| EJB3StandaloneBootstrap.boot(null);
| System.err.println("...... deploying embedded-jboss-beans....");
| EJB3StandaloneBootstrap.scanClasspath();
|
| // Deploy everything we got
| deployer.setKernel(EJB3StandaloneBootstrap.getKernel());
| deployer.create();
| System.err.println("...... deployer created....");
|
| deployer.start();
| System.err.println("...... deployer started....");
|
|
| Hashtable props = new Hashtable();
| props.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
| props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
| // Create InitialContext from jndi.properties
| initialContext = new InitialContext(props);
| System.err.println("---- end of bootstrapping EJB3 container....InitialContext is:");
|
| } catch (Exception ex) {
| ex.printStackTrace();
| throw new RuntimeException(ex);
| }
| }
|
i have following session ejb
| @Stateless(name="facade")
| @Local ( {FacadeIF.class})
|
| public class TestFacade implements FacadeIF {
|
| @PersistenceContext
| EntityManager em;
|
| public void deleteAgency(Agency agency) {
| // TODO Auto-generated method stub
| Query query = getQuery("findAgencyById");
| query.setParameter("id", agency.getId());
| Agency agencyToDelete = (Agency)query.getSingleResult();
| em.remove(agencyToDelete);
| }
|
| public void deleteJobApplication(JobApplication app) {
| Query query = getQuery("findJAById");
| query.setParameter("id", app.getId());
| JobApplication jaToDelete = (JobApplication)query.getSingleResult();
| em.remove(jaToDelete);
|
| }
| ....
|
In one of my tests i am trying to lookup the ejb
| public void testInsertAgency() throws Exception {
| System.err.println("Testing insertion of an Agency..");
| try {
|
| TestFacade sessionFacade = (TestFacade) EJB3Container.lookup("facade/local");
|
|
| } catch(Exception e) {
|
| System.err.println("an exception occurred...");
| e.printStackTrace();
| }
|
|
| }
|
but htis result sin following excepiton
| java.lang.RuntimeException: Couldn't lookup: facade/local
| at example1.EJB3Container.lookup(EJB3Container.java:101)
| at example1.AgencyTest.testInsertAgency(AgencyTest.java:33)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
| at org.testng.internal.Invoker.invokeMethod(Invoker.java:411)
| at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:785)
| at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:114)
| at org.testng.TestRunner.privateRun(TestRunner.java:693)
| at org.testng.TestRunner.run(TestRunner.java:574)
| at org.testng.SuiteRunner.privateRun(SuiteRunner.java:241)
| at org.testng.SuiteRunner.run(SuiteRunner.java:145)
| at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:901)
| at org.testng.TestNG.runSuitesLocally(TestNG.java:863)
| at org.apache.maven.surefire.testng.TestNGExecutor.executeTestNG(TestNGE
| xecutor.java:78)
| at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXml
| TestSuite.java:76)
| at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(Su
| refireBooter.java:262)
| at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.j
| ava:787)
| Caused by: javax.naming.NameNotFoundException: facade not bound
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
| at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
| at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:626)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
| at javax.naming.InitialContext.lookup(Unknown Source)
|
could anyone tell me what's the problem?
it looks like my session ejb is not being deployed..... any reasons why?
am i using the wrong jndi name to lookup the ejb?
thanks ina dvance and r egards
marco
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973752#3973752
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973752
19 years, 7 months
[Beginners Corner] - Faces FAILED load unsupported major.minor version
by hill_hobbit
Hi,
I am trying to migrate from an existing Tomcat installation to a JBoss installation. I am moving an Alfresco instance into jboss. I get the following error:
anonymous wrote : --- Incompletely deployed packages ---
| org.jboss.deployment.DeploymentInfo@dc7312d6 { url=file:/opt/jboss-4.0.4.GA/server/default/deploy/alfresco.war }
| deployer: MBeanProxyExt[jboss.web:service=WebServer]
| status: Deployment FAILED reason: org/alfresco/web/app/servlet/AlfrescoFacesServlet (Unsupported major.minor version 49.0)
| state: FAILED
| watch: file:/opt/jboss-4.0.4.GA/server/default/deploy/alfresco.war
| altDD: null
| lastDeployed: 1159056607432
| lastModified: 1159056607000
| mbeans:
Am I entering version HELL? Will I continue to get errors based on every aspect of the sprawling jboss framework? Or, is this purely an internal issue of Alfresco?
How might I resolve this error short of ditching jboss, running a parallel tomcat installation or getting rid of Alfresco?
Any help would be greatly appreciated.
Hill_Hobbit
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973747#3973747
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973747
19 years, 7 months