# JBoss6 UnitTest



## Gast2 (16. Mai 2011)

Hallo,

weiß jemand von euch wie man UnitTest für den JBoss konfiguriert? Ich finde keine Doku dazu, vor allem welche jars und welche Konfigurationen ich vornehmen muss damit 

```
EJBContainer.createEJBContainer()
```
 und 
	
	
	
	





```
Persistence.createEntityManagerFactory("Test").createEntityManager();
```
 funktioniert.


----------



## Gast2 (23. Mai 2011)

Keiner ne Idee?
hab schon das hier probiert:
How to Junit test EJB class | JBoss AS | JBoss Community
HOWTO test EJB3 with JUnit outside of the container (Gerald's Blog)

Bekomm aber immer beim createEJBContainer diese Meldungen

```
16:07:11,126 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/apache/tools/ant/DynamicConfigurator while loading com.sun.istack.tools.ProtectedTask; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/jaxb-xjc.jar" is not processed
16:07:11,126 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/apache/tools/ant/DynamicConfigurator while loading com.sun.istack.tools.ProtectedTask$AntElement; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/jaxb-xjc.jar" is not processed
```


----------



## mvitz (23. Mai 2011)

Für JPA sollten die folgenden bei JBoss 6 mit ausgelieferten JARs reichen:
hibernate-commons-annotations.jar
hibernate-core.jar
hibernate-entitymanager.jar
hibernate-jpa-2.0-api.jar

sowie der JDBC Treiber für die zu nutzende Datenbank.

Weiterhin brauchst du natürlich eine persistence.xml die, wenn du JPA ohne Container nutzt (in Tests durchaus üblich), auch die passenden Werte (URL, Name, Pass, Transaktion, ...) besitzen muss.


----------



## Gast2 (23. Mai 2011)

mvitz hat gesagt.:


> Für JPA sollten die folgenden bei JBoss 6 mit ausgelieferten JARs reichen:
> hibernate-commons-annotations.jar
> hibernate-core.jar
> hibernate-entitymanager.jar
> hibernate-jpa-2.0-api.jar



Die hab ich alle schon + die standalone ejb3 jar.
Aber ich steh grad aufm Schlauch wie ich die meiner Test-Runtime hinzufüge.
In Maven gebe ich einfach das die für Test gebraucht werden, aber ohne? Einfach in Web-Inf/lib?oder in den src-test?



mvitz hat gesagt.:


> Weiterhin brauchst du natürlich eine persistence.xml die, wenn du JPA ohne Container nutzt (in Tests durchaus üblich), auch die passenden Werte (URL, Name, Pass, Transaktion, ...) besitzen muss.


Ja die habe ich schon angelegt und in src-test/META-INF/ gelegt.


----------



## FArt (23. Mai 2011)

Was werden das für Tests? Nutzt du Embedded JBoss?


----------



## mvitz (23. Mai 2011)

Naja, was für eine Art Projekt ist das denn? Nur Eclipse ohne Build-System?


----------



## Gast2 (24. Mai 2011)

FArt hat gesagt.:


> Was werden das für Tests? Nutzt du Embedded JBoss?



Nee habe ich noch nicht runtergelanden. Ich hab halt die jboss-ejb3-embedded-standalone.jar, sollte doch reichen oder?

Brauch ich sowas hier?
EmbeddedAndJUnit | JBoss Community

Ich dachte das reicht vielleicht
EJB 3.1 Embeddable | EJB3 | JBoss Community




mvitz hat gesagt.:


> Naja, was für eine Art Projekt ist das denn? Nur Eclipse ohne Build-System?



Ja erstmal ganz normal ein Eclipse-Projekt.


----------



## mvitz (24. Mai 2011)

Dann sollten die ganzen JARs doch eigentlich schon im Classpath sein, da du den JBoss 6 als Server geaddet hast, oder? Ansonsten müsstest du die JARs so einbinden, dass die NICHT mit exportiert werden.


----------



## Gast2 (24. Mai 2011)

mvitz hat gesagt.:


> Dann sollten die ganzen JARs doch eigentlich schon im Classpath sein, da du den JBoss 6 als Server geaddet hast, oder? Ansonsten müsstest du die JARs so einbinden, dass die NICHT mit exportiert werden.



Ja ich hab den Server geaddet und die jars liegen auch im classpath, aber die werden beim Test anscheinend ignoriert:
Das ist meine log Ausgabe wenn ich ejbContainer create mache

```
10:22:46,079 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/jboss/test/AbstractTestDelegate while loading org.jboss.test.kernel.junit.MicrocontainerTestDelegate; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/lib/jboss-kernel.jar" is not processed
10:22:46,079 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/jboss/test/AbstractTestCaseWithSetup while loading org.jboss.test.kernel.junit.MicrocontainerTest; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/lib/jboss-kernel.jar" is not processed
10:22:47,564 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: net/sf/cglib/proxy/MethodInterceptor while loading org.apache.cxf.common.util.CglibProxyHelper$1; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-common-utilities.jar" is not processed
10:22:47,579 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/AbstractSingleBeanDefinitionParser while loading org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-common-utilities.jar" is not processed
10:22:47,595 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/AbstractSingleBeanDefinitionParser while loading org.apache.cxf.configuration.spring.SimpleBeanDefinitionParser; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-common-utilities.jar" is not processed
10:22:47,595 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/AbstractSingleBeanDefinitionParser while loading org.apache.cxf.configuration.spring.StringBeanDefinitionParser; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-common-utilities.jar" is not processed
10:22:47,595 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware while loading org.apache.cxf.configuration.spring.SpringBeanQNameMap; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-common-utilities.jar" is not processed
10:22:47,595 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware while loading org.apache.cxf.configuration.spring.SpringBeanMap; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-common-utilities.jar" is not processed
10:22:47,595 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware while loading org.apache.cxf.configuration.spring.AbstractSpringBeanMap; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-common-utilities.jar" is not processed
10:22:47,595 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/AbstractSingleBeanDefinitionParser while loading org.apache.cxf.configuration.spring.AbstractFactoryBeanDefinitionParser; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-common-utilities.jar" is not processed
10:22:47,642 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser while loading org.apache.cxf.binding.coloc.spring.ColocBeanDefinitionParser; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-rt-bindings-coloc.jar" is not processed
10:22:47,642 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/NamespaceHandlerSupport while loading org.apache.cxf.binding.coloc.spring.NamespaceHandler; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-rt-bindings-coloc.jar" is not processed
10:22:47,689 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/NamespaceHandlerSupport while loading org.apache.cxf.binding.object.spring.NamespaceHandler; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-rt-bindings-object.jar" is not processed
10:22:47,720 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/AbstractSingleBeanDefinitionParser while loading org.apache.cxf.binding.soap.spring.SoapBindingInfoConfigBeanDefinitionParser; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-rt-bindings-soap.jar" is not processed
10:22:47,720 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/NamespaceHandlerSupport while loading org.apache.cxf.binding.soap.spring.NamespaceHandler; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-rt-bindings-soap.jar" is not processed
10:22:47,720 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/springframework/beans/PropertyEditorRegistrar while loading org.apache.cxf.binding.soap.spring.SoapVersionRegistrar; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-rt-bindings-soap.jar" is not processed
10:22:47,735 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/apache/mina/filter/codec/ProtocolEncoderAdapter while loading org.apache.cxf.binding.soap.tcp.SoapTcpMessageEncoder; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-rt-bindings-soap.jar" is not processed
10:22:47,751 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/apache/mina/filter/codec/ProtocolDecoderAdapter while loading org.apache.cxf.binding.soap.tcp.SoapTcpMessageDecoder; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-rt-bindings-soap.jar" is not processed
10:22:47,751 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/apache/mina/filter/codec/ProtocolCodecFactory while loading org.apache.cxf.binding.soap.tcp.SoapTcpCodecFactory; configure an exclusion filter so "/D:/JBoss/jboss-6.0.0.Final/client/cxf-rt-bindings-soap.jar" is not processed
10:22:47,751 WARN  [ClassPathEjbJarScanner] Dev Hack Alert: Ignoring class on ClassPath which can't be loaded due to java.lang.NoClassDefFoundError: org/apache/mina/core/service/IoHandler while loading org.apache.cxf.binding.soap.tcp.SoapTcpDestination; configure an exclusion filter
```


----------



## mvitz (24. Mai 2011)

Hm, ich hatte zuletzt auch das Gefühl, dass JBoss6 in der aktuellen Eclipse Version noch nicht wirklich unterstützt wird... dann solltest du die JARs eben anders einbinden. (aber NICHT in WEB-INF/lib, sonst werden die nämlich mitdeployed)


----------



## Gast2 (24. Mai 2011)

Wenn ich das hier versuche

```
entityManager = Persistence.createEntityManagerFactory("Test")
		.createEntityManager();
```


```
javax.persistence.PersistenceException: [PersistenceUnit: Test] Unable to build EntityManagerFactory
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:911)
	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
	at com.enbw.pricepilot.test.EntityManagerTest.setUp(EntityManagerTest.java:20)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.hibernate.HibernateException: Could not find datasource
	at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:79)
	at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:143)
	at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:51)
	at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:91)
	at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833)
	at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
	... 26 more
Caused by: javax.naming.NameNotFoundException: TestDS not bound
	at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
	at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
	at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
	at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
	at javax.naming.InitialContext.lookup(InitialContext.java:392)
	at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
	... 33 more
```

Strutkur

src-test/META-INF/persistence.xml

[XML]
<persistence 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"
	version="2.0">
	<persistence-unit name="Test">
		<jta-data-source>java:/TestDS</jta-data-source>
		<properties>			
			<property name="hibernate.show_sql" value="true"/>
			<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
			<property name="hibernate.session_factory_name" value="java:hibernate/SessionFactory" />
		</properties>

	</persistence-unit>
</persistence>
[/XML]


----------



## Gast2 (24. Mai 2011)

mvitz hat gesagt.:


> Hm, ich hatte zuletzt auch das Gefühl, dass JBoss6 in der aktuellen Eclipse Version noch nicht wirklich unterstützt wird... dann solltest du die JARs eben anders einbinden. (aber NICHT in WEB-INF/lib, sonst werden die nämlich mitdeployed)



Okay versuche ich es mal so... Ja eigentlich gibt es in den neuen JBoss Tools ja den JBoss6 Server als Runtime...

Die Fehlermeldungen kommen sobald ich JBOSS_HOME setze. Vielleich hab ich da auch das falsche Verzeichniss angegeben, bis zum root ordner halt

EDIT: Wenn ich die jars explizit dem classpath hinzufüge ändert das nichts.

EDIT EDIT: Also das mit dem EntityManager hat nun geklappt. Aber das mit dem EJBContainer nicht...

Mal eine allgemeine Frage, wenn das mit dem EJBContainer klappt kann ich dann in meinen Tests DI verwenden?


----------



## Gast2 (24. Mai 2011)

Also ich hab mir jetzt mal die neusten Plugin gezogen...
Die warnungen bleiben immer noch, aber wenigstens wird jetzt der container hochgefahren(auch wenn mit 100 Mio errors ^^).

```
14:09:21,992 INFO  [StdSchedulerFactory] Quartz scheduler 'JBossQuartzScheduler' initialized from an externally opened InputStream.
14:09:21,992 INFO  [StdSchedulerFactory] Quartz scheduler version: 1.8.3
14:09:21,993 INFO  [QuartzScheduler] Scheduler JBossQuartzScheduler_$_NON_CLUSTERED started.
14:09:22,297 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
14:09:22,466 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
14:09:22,536 INFO  [xnio] XNIO Version 2.1.0.CR2
14:09:22,548 INFO  [nio] XNIO NIO Implementation Version 2.1.0.CR2
14:09:22,687 INFO  [remoting] JBoss Remoting version 3.1.0.Beta2
14:09:22,725 ERROR [AbstractKernelController] Error installing to Real: name=vfs:///D:/Programme/JBoss/jboss-6.0.0.Final/server/default/deploy/ROOT.war state=PreReal mode=Manual requiredState=Real: org.jboss.deployers.spi.DeploymentException: Error during deploy: vfs:///D:/Programme/JBoss/jboss-6.0.0.Final/server/default/deploy/ROOT.war
	at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) [jboss-deployers-core-spi.jar:2.2.0.GA]
	at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:185) [jboss-deployers-impl.jar:2.2.0.GA]
	at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [jboss-deployers-impl.jar:2.2.0.GA]
	at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) [jboss-deployers-impl.jar:2.2.0.GA]
	at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [jboss-deployers-impl.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [jboss-deployers-impl.jar:2.2.0.GA]
	at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [jboss-deployers-impl.jar:2.2.0.GA]
	at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [jboss-deployers-impl.jar:2.2.0.GA]
	at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [jboss-system.jar:6.0.0.Final]
	at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) [jboss-profileservice-core.jar:0.2.2]
	at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:151) [jboss-profileservice-core.jar:0.2.2]
	at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [jboss-profileservice-core.jar:0.2.2]
	at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.GA]
	at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]
	at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190) [jboss-profileservice-core.jar:0.2.2]
	at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87) [jboss-profileservice-core.jar:0.2.2]
	at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215) [jboss-profileservice-core.jar:0.2.2]
	at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159) [jboss-profileservice-core.jar:0.2.2]
	at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:112) [jboss-profileservice-core.jar:0.2.2]
	at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:87) [jboss-profileservice-core.jar:0.2.2]
	at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:91) [jboss-profileservice-core.jar:0.2.2]
	at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:132) [jboss-system.jar:6.0.0.Final]
	at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [jboss-system.jar:6.0.0.Final]
	at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
	at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
	at java.lang.Thread.run(Unknown Source) [:1.6.0_24]
Caused by: java.lang.NoClassDefFoundError: org/apache/catalina/Loader
	at java.lang.Class.getDeclaredConstructors0(Native Method) [:1.6.0_24]
	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) [:1.6.0_24]
	at java.lang.Class.getConstructor0(Unknown Source) [:1.6.0_24]
	at java.lang.Class.newInstance0(Unknown Source) [:1.6.0_24]
	at java.lang.Class.newInstance(Unknown Source) [:1.6.0_24]
	at org.jboss.web.tomcat.service.deployers.TomcatDeployer.getDeployment(TomcatDeployer.java:381) [:6.0.0.Final]
	at org.jboss.web.deployers.AbstractWarDeployer.deploy(AbstractWarDeployer.java:479) [jboss.jar:6.0.0.Final]
	at org.jboss.web.deployers.AbstractWarDeployer.deploy(AbstractWarDeployer.java:122) [jboss.jar:6.0.0.Final]
	at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62) [jboss-deployers-spi.jar:2.2.0.GA]
	at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55) [jboss-deployers-spi.jar:2.2.0.GA]
	at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [jboss-deployers-impl.jar:2.2.0.GA]
	... 43 more
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.Loader
	at java.net.URLClassLoader$1.run(Unknown Source) [:1.6.0_24]
	at java.security.AccessController.doPrivileged(Native Method) [:1.6.0_24]
	at java.net.URLClassLoader.findClass(Unknown Source) [:1.6.0_24]
	at java.lang.ClassLoader.loadClass(Unknown Source) [:1.6.0_24]
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) [:1.6.0_24]
	at java.lang.ClassLoader.loadClass(Unknown Source) [:1.6.0_24]
	... 54 more

14:09:22,753 INFO  [service] Removing bootstrap log handlers
14:09:22,803 ERROR [ProfileServiceBootstrap] Failed to load profile:: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

DEPLOYMENTS MISSING DEPENDENCIES:
  Deployment "AdminConsoleActivator" is missing the following dependencies:
    Dependency "WebServer" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'WebServer' **")
  Deployment "JBossWSConsoleActivator" is missing the following dependencies:
    Dependency "WebServer" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'WebServer' **")
  Deployment "JmxConsoleActivator" is missing the following dependencies:
    Dependency "WebServer" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'WebServer' **")
  Deployment "LocalTxDataSourceTemplate" is missing the following dependencies:
    Dependency "LocalTxDataSourceTemplateInfo" (should be in state "Installed", but is actually in state "**ERROR**")
  Deployment "NoTxConnectionFactoryTemplate" is missing the following dependencies:
    Dependency "NoTxConnectionFactoryTemplateInfo" (should be in state "Installed", but is actually in state "**ERROR**")
  Deployment "NoTxDataSourceTemplate" is missing the following dependencies:
    Dependency "NoTxDataSourceTemplateInfo" (should be in state "Installed", but is actually in state "**ERROR**")
  Deployment "TxConnectionFactoryTemplate" is missing the following dependencies:
    Dependency "TxConnectionFactoryTemplateInfo" (should be in state "Installed", but is actually in state "**ERROR**")
  Deployment "XADataSourceTemplate" is missing the following dependencies:
    Dependency "XADataSourceTemplateInfo" (should be in state "Installed", but is actually in state "**ERROR**")

DEPLOYMENTS IN ERROR:
  Deployment "vfs:///D:/Programme/JBoss/jboss-6.0.0.Final/server/default/deploy/mod_cluster.sar" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.apache.catalina.LifecycleListener
  Deployment "vfs:///D:/Programme/JBoss/jboss-6.0.0.Final/server/default/deploy/http-invoker.sar" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.apache.catalina.Loader
  Deployment "NoTxConnectionFactoryTemplateInfo" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.jboss.resource.deployers.management.ConnectionFactoryProperty, **ERROR**
  Deployment "vfs:///D:/Programme/JBoss/jboss-6.0.0.Final/server/default/deploy/jbossweb.sar" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.jboss.web.tomcat.service.deployers.TomcatDeployerMBean
  Deployment "XADataSourceTemplateInfo" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.jboss.resource.deployers.management.ConnectionFactoryProperty, **ERROR**
  Deployment "PostEjbJarMetadataDeployer" is in error due to the following reason(s): java.lang.NoSuchMethodError: javax.annotation.Resource.lookup()Ljava/lang/String;
  Deployment "vfs:///D:/Programme/JBoss/jboss-6.0.0.Final/server/default/deploy/ROOT.war" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.apache.catalina.Loader
  Deployment "TxConnectionFactoryTemplateInfo" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.jboss.resource.deployers.management.ConnectionFactoryProperty, **ERROR**
  Deployment "LocalTxDataSourceTemplateInfo" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.jboss.resource.deployers.management.ConnectionFactoryProperty, **ERROR**
  Deployment "WebServer" is in error due to the following reason(s): ** NOT FOUND Depends on 'WebServer' **
  Deployment "NoTxDataSourceTemplateInfo" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.jboss.resource.deployers.management.ConnectionFactoryProperty, **ERROR**
  Deployment "jboss:service=WebService" is in error due to the following reason(s): java.net.BindException: Address already in use: JVM_Bind

	at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1228) [jboss-deployers-impl.jar:2.2.0.GA]
	at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:905) [jboss-deployers-impl.jar:2.2.0.GA]
	at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.checkComplete(MainDeployerPlugin.java:87) [jboss-system.jar:6.0.0.Final]
	at org.jboss.profileservice.deployment.ProfileDeployerPluginRegistry.checkAllComplete(ProfileDeployerPluginRegistry.java:107) [jboss-profileservice-core.jar:0.2.2]
	at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:135) [jboss-system.jar:6.0.0.Final]
	at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [jboss-system.jar:6.0.0.Final]
	at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
	at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
	at java.lang.Thread.run(Unknown Source) [:1.6.0_24]
```


----------



## JimPanse (24. Mai 2011)

SirWayne hat gesagt.:


> Wenn ich das hier versuche
> 
> ```
> entityManager = Persistence.createEntityManagerFactory("Test")
> ...


----------



## Gast2 (24. Mai 2011)

JimPanse hat gesagt.:


> Das geht nur wenn in der persistence-xml:
> 
> transaction-type="RESOURCE_LOCAL"
> 
> ...



Ja darum versuche ich ja den Container zu laden...
Wie gesagt es sind ja alle Klassen im Classpath da die Server runtime(d.h. alle JBoos6 jars) im projekt eingebunden ist.
Die Client all jars gibts im JBoss6 nicht mehr die ist leer und wurde in einzelene jars aufgeteilt...
Ich arbeite grad mit JPA+Rest

EDIT:
Hier noch die Exception aus der JUnit View:

```
javax.ejb.EJBException: java.lang.reflect.InvocationTargetException
	at org.jboss.ejb3.embedded.impl.standalone.JBossStandaloneEJBContainerProvider.createEJBContainer(JBossStandaloneEJBContainerProvider.java:153)
	at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:93)
	at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:75)
	at test.MyTest.setUp(MyTest.java:27)
	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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.reflect.InvocationTargetException
	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.jboss.ejb3.embedded.impl.standalone.JBossStandaloneEJBContainerProvider.createEJBContainer(JBossStandaloneEJBContainerProvider.java:141)
	... 25 more
Caused by: javax.ejb.EJBException: org.jboss.embedded.api.DeploymentException: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

DEPLOYMENTS MISSING DEPENDENCIES:
  Deployment "AdminConsoleActivator" is missing the following dependencies:
    Dependency "WebServer" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'WebServer' **")
  Deployment "JBossWSConsoleActivator" is missing the following dependencies:
    Dependency "WebServer" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'WebServer' **")
  Deployment "JmxConsoleActivator" is missing the following dependencies:
    Dependency "WebServer" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'WebServer' **")
  Deployment "LocalTxDataSourceTemplate" is missing the following dependencies:
    Dependency "LocalTxDataSourceTemplateInfo" (should be in state "Installed", but is actually in state "**ERROR**")
  Deployment "ModClusterListener" is missing the following dependencies:
    Dependency "WebServer" (should be in state "Create", but is actually in state "** NOT FOUND Depends on 'WebServer' **")
  Deployment "NoTxConnectionFactoryTemplate" is missing the following dependencies:
    Dependency "NoTxConnectionFactoryTemplateInfo" (should be in state "Installed", but is actually in state "**ERROR**")
  Deployment "NoTxDataSourceTemplate" is missing the following dependencies:
    Dependency "NoTxDataSourceTemplateInfo" (should be in state "Installed", but is actually in state "**ERROR**")
  Deployment "TxConnectionFactoryTemplate" is missing the following dependencies:
    Dependency "TxConnectionFactoryTemplateInfo" (should be in state "Installed", but is actually in state "**ERROR**")
  Deployment "XADataSourceTemplate" is missing the following dependencies:
    Dependency "XADataSourceTemplateInfo" (should be in state "Installed", but is actually in state "**ERROR**")
  Deployment "jboss.ejb3:application=cla,module=cla,component=AngebotDAO,service=EjbEncFactory" is missing the following dependencies:
    Dependency "jboss.naming:application=cla,component=AngebotDAO,module=cla" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'jboss.naming:application=cla,component=AngebotDAO,module=cla' **")
  Deployment "jboss.j2ee:jar=classes,name=AngebotDAO,service=EJB3" is missing the following dependencies:
    Dependency "org.jboss.ejb.bean.instantiator/cla/cla/AngebotDAO" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'org.jboss.ejb.bean.instantiator/cla/cla/AngebotDAO' **")
    Dependency "jboss.ejb3:application=cla,component=AngebotDAO,module=cla,service=EjbEncFactory" (should be in state "Installed", but is actually in state "Described")
  Deployment "jboss.j2ee:jar=classes,name=AngebotDAO,service=EJB3,type=nointerface-view-jndi-binder" is missing the following dependencies:
    Dependency "jboss.j2ee:jar=classes,name=AngebotDAO,service=EJB3" (should be in state "Installed", but is actually in state "Instantiated")
  Deployment "jboss.j2ee:jar=classes,name=AngebotDAO,service=EJB3_endpoint" is missing the following dependencies:
    Dependency "jboss.j2ee:jar=classes,name=AngebotDAO,service=EJB3" (should be in state "Installed", but is actually in state "Instantiated")

DEPLOYMENTS IN ERROR:
  Deployment "jboss.ejb3:application=cla,component=AngebotDAO,module=cla,service=EjbEncFactory" is in error due to the following reason(s): Described
  Deployment "org.jboss.ejb.bean.instantiator/cla/cla/AngebotDAO" is in error due to the following reason(s): ** NOT FOUND Depends on 'org.jboss.ejb.bean.instantiator/cla/cla/AngebotDAO' **
  Deployment "vfs:///D:/Programme/JBoss/jboss-6.0.0.Final/server/default/deploy/http-invoker.sar" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.apache.tomcat.InstanceManager
  Deployment "vfs:///D:/Programme/JBoss/jboss-6.0.0.Final/server/default/deploy/jbossweb.sar" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.jboss.web.tomcat.service.deployers.TomcatDeployerMBean
  Deployment "PostEjbJarMetadataDeployer" is in error due to the following reason(s): java.lang.NoSuchMethodError: javax.annotation.Resource.lookup()Ljava/lang/String;
  Deployment "TxConnectionFactoryTemplateInfo" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.jboss.resource.deployers.management.ConnectionFactoryProperty, **ERROR**
  Deployment "WebServer" is in error due to the following reason(s): ** NOT FOUND Depends on 'We
```


----------



## JimPanse (24. Mai 2011)

SirWayne hat gesagt.:


> Ja darum versuche ich ja den Container zu laden...


???

Verstehe ich nicht? Der JBoss muss gestartet sein und mit Aufruf des Remote-Interfaces wird aus Eclipse eine Anfrage an den JBoss abgesetzt!

Bsp:

```
public class XYZTest {

private static Context;

private static XYZRemote bean;
	/**
	 * Global initialization.
	 */
	static {
		try {
			context = new InitialContext();
		} catch (NamingException e) {
			throw new ExceptionInInitializerError(e);
		}
	}

       /**
	 * @throws java.lang.Exception
	 */
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		bean = context.lookup("Bean/remote");
	
	}
...
}
```

Im classpath der Test's muss noch die jndi.properties liegen mit


```
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=jnp\://localhost\:1099
```

damit bekannt ist in welchen Prozessraum der Aufruf erfolgen soll...

Fertig. Läuft bei mir Problemlos mit JBoss 5.1... Ich weiß nur, dass mit OpenEJB - Home man nicht unbedingt den JBoss gestartet haben muss zum testen aber wäre mir persönlich zuviel Overhead 'nur' um zu testen ein zusätzliches Framework einzubinden.


----------



## Gast2 (24. Mai 2011)

JimPanse hat gesagt.:


> ???
> 
> Verstehe ich nicht? Der JBoss muss gestartet sein und mit Aufruf des Remote-Interfaces wird aus Eclipse eine Anfrage an den JBoss abgesetzt!



Ich will den JBoss nicht extra starten und eben EJBContainer (Mikrocontainer) verwenden. Soweit ich weiß sollte es so funktionieren wie ich es gemacht hab
EJB 3.1 Embeddable | EJB3 | JBoss Community

Weil sonst kann ich gleich den JBoss laufen lassen und meinen RestClient verwenden und die Services dann so testen...

Weil wenn ich den JBoss extra laufen lassen muss dann kann ich es auch so machen: Aber das war ja nicht das Ziel den ganzen JBoss hochzufahren


```
public class MyTest {

	private static final String uri = "http://localhost:8080/project";

	private MyServiceinfoService;
	
	@Before
	public void setUp(){
		RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
		final HttpClient client = new HttpClient();
		final ClientExecutor executor = new ApacheHttpClientExecutor(client);
		myService= ProxyFactory.create(MyService.class,
				uri, executor);

	}
	
	@Test
	public void testCreate() throws Exception{
		assertTrue(testwas());
		
	}
	
}
```

So kann ich halt auch keine Test-DB ansteuern von dem her gefällt es mir so NICHT!


----------



## Deadalus (24. Mai 2011)

Eine kurze Info: 

Was du hier vorhast hat nur sehr wenig mit Unit Tests zu tun. Bei einem Unit Test testest du eine abgeschlossene einheit und nicht Aufrufe irgendwelcher EJBs oder sogar echte Zugriffe auf die Datenbank.

Was du hier vor hast nennt man Integrationstest und diese sind ohne funktionierende Unit Tests unsinnig. 

Alles was du brauchst du sinnvoll zu testen ist folglich jUnit + ein Mocking Framework deiner Wahl, zum Beispiel Mockito, EasyMock, usw... 

Wenn du jetzt einen Unit Test für z.B. eine Methode eines SessionBean schreibst, das wiederum eine andere EJB aufrufst mockst du die aufzurufende EJB und lässt sie so gut wie es geht überhaupt nichts machen oder einen passenden Wert für deinen Test zurückgeben. Testen tust du dann wirklich nur das was sonst innerhalb der Methode passiert. 

Dadurch sparst du dir eine Menge Aufwand und brauchst keinerlei Container oder ähnliches zu erzeugen.


----------



## Gast2 (25. Mai 2011)

Deadalus hat gesagt.:


> Was du hier vor hast nennt man Integrationstest und diese sind ohne funktionierende Unit Tests unsinnig.



Ich will einfach ein Bean wie in dem oben genannten Link testen.


----------



## Deadalus (25. Mai 2011)

SirWayne hat gesagt.:


> Ich will einfach ein Bean wie in dem oben genannten Link testen.



Um ein Bean zu testen braucht man eben gerade keine Container zu erzeugen sondern einfach nur Junit. (+ Mockingframework wenn das Bean andere Beans referenziert).


----------



## FArt (26. Mai 2011)

Deadalus hat gesagt.:


> Um ein Bean zu testen braucht man eben gerade keine Container zu erzeugen sondern einfach nur Junit. (+ Mockingframework wenn das Bean andere Beans referenziert).



Prinzipiell hast du natürlich recht. Aber JUnit dogmatisch als reines Framework für Unittests einzustufen (weil es eben so heißt) ist nicht richtig. JUnit kann mittlerweile wesentlich mehr leisten, erhöht damit die Qualität (weil mehr Fälle einfacher und doch automatisiert abgefrühstückt werden können) und Sicherheit bei der agilen Entwicklung. Dabei kann der Aufwand für (evtl. automatisierte) Integrationstest reduziert werden.

Dennoch ist natürlich vorsicht geboten, was man denn eigentlich testen möchte. Wenn man denn denkt, man könne einen großen Businesscall über einen großen Teil der Infrastruktur laufen lassen, dann hat man damit nur gefühlt viel getestet, aber nicht wirklich viel erreicht. Wenn man sich aber wieder auf kleine Teile beschränkt, dann ist das durchaus sinnvoll sein.

Das Verhalten hängt u.U. von der Konfiguration der Berechtigungen und Transaktionen der EJBs ab.Für solche Tests kann ein Embedded JBoss durchaus sinnvoll sein, besonders in der Verwendung mit JUnit.

Das Prinzip sollte also immer sein: teste in einem möglichst kleinen Rahmen.


----------



## Gast2 (26. Mai 2011)

Da ich den Container nichts zum laufen bekomme muss ich mir erstmals keine Gedanken machen wie groß meine Units sind, die ich testen möchte


----------

