Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test-persistence.xml jta-datasource or non-jta-datasource required #92

Open
pdstat opened this issue Jun 29, 2017 · 1 comment
Open

Comments

@pdstat
Copy link

pdstat commented Jun 29, 2017

In the "Testing Java Peristence" guide it says

Alternatively, you can skip the DataSource configuration and simply include the database connection information directly in test-persistence.xml using standard database connection properties:

However if for example I create a test-peristence.xml like so

<persistence-unit name="primary">
	<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
	<!--  <jta-data-source>jdbc/derby</jta-data-source> -->
	<properties>
		<!-- Common properties -->
		<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
		<property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:test-jpa;create=true" />
		<property name="javax.persistence.jdbc.user" value="APP" />
		<property name="javax.persistence.jdbc.password" value="APP" />

		<!-- EclipseLink specific properties -->
		<property name="eclipselink.target-database" value="Derby" />
		<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
		<property name="eclipselink.debug" value="ALL" />
		<property name="eclipselink.weaving" value="static" />
		<property name="eclipselink.logging.level" value="FINEST" />
		<property name="eclipselink.logging.level.sql" value="FINEST" />
		<property name="eclipselink.logging.level.cache" value="FINEST" />
	</properties>
</persistence-unit>

And then try to create a simple deployment for example

@Deployment
public static Archive<?> createDeployment() {
	return ShrinkWrap.create(WebArchive.class, "test.war")
			.addClass(User.class)
			.addAsResource("test-persistence.xml", "persistence.xml")
			.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}

I get the following stack trace

java.lang.NullPointerException
	at org.jboss.arquillian.persistence.core.configuration.PersistenceDescriptorParser.obtainDataSourceName(PersistenceDescriptorParser.java:61)
	at org.jboss.arquillian.persistence.core.configuration.PersistenceDescriptorParser.obtainDataSourceName(PersistenceDescriptorParser.java:66)
	at org.jboss.arquillian.persistence.core.deployment.PersistenceExtensionConfigurationTestArchiveEnricher.obtainDataSourceFromPersistenceXml(PersistenceExtensionConfigurationTestArchiveEnricher.java:98)
	at org.jboss.arquillian.persistence.core.deployment.PersistenceExtensionConfigurationTestArchiveEnricher.process(PersistenceExtensionConfigurationTestArchiveEnricher.java:72)
	at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.applyApplicationProcessors(DeploymentGenerator.java:223)
	at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.buildTestableDeployments(DeploymentGenerator.java:172)
	at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.createTestableDeployments(DeploymentGenerator.java:148)
	at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:85)
	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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:96)
	at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103)
	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:85)
	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:143)
	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
	at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
	at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:100)
	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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:96)
	at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103)
	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:85)
	at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:92)
	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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:96)
	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:92)
	at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:73)
	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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:96)
	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:92)
	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:143)
	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
	at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:87)
	at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:202)
	at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:431)
	at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:55)
	at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:219)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:167)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

If I then create a datasource in Weblogic and specify it in the jta-data-source I don't get this issue.

@neormx
Copy link

neormx commented Apr 12, 2020

I confirm the error reported by @PaulStat. Code only works by using the jta-data-source property; otherwise I got the same NPE he says.

I'm using the latest version reported on arquillian module's page: 1.0.0.Alpha7, however I can see int this site's releases page that there are newer versions but no commits since 2017. Is this project still alive @bartoszmajsak?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants