Hi Makarov,

Thanks for documenting the fix on Stackoverflow!  I upvoted your answer.

Richard

On Mon, Nov 18, 2019 at 6:01 AM Makarov Alexey <[email protected]> wrote:

> As I see, the problem in TomEE and Hibernate intercation, when Hibernate
> is not in tomee "lib", but in application "lib" directory. When testing
> process is ended, and application is undeployed, Tomee try to use class
> "org/hibernate/resource/beans/internal/BeansMessageLogger". Here same
> problem:
>
>
> https://stackoverflow.com/questions/57679191/testing-persistence-with-arquillian-and-tomee8-tests-are-passing-but-exception
>
> --
> WIth best regards,
> Makarov Alexey
>
>
> 18.11.2019, 14:48, "Makarov Alexey" <[email protected]>:
> > Hello, Richard! Thank you for reply!
> > I found workaround yesterday. Sorry for late answer.
> > I tuned Maven to assembly Hibernate libraries with denendences and copy
> it to "target/additional-libs" directory. Then, I setup "additionalLibs" in
> arquillian.xml, and specify the path to directory with hibernate libraries.
> > Here solution step by step:
> >
> > 1. Mark Hibernate and datasource driver dependencies as "provided". In
> my case:
> > ...
> > <dependency>
> >     <groupId>org.hibernate</groupId>
> >     <artifactId>hibernate-entitymanager</artifactId>
> >     <version>5.4.8.Final</version>
> >     <scope>provided</scope>
> > </dependency>
> > <dependency>
> >     <groupId>com.vladmihalcea</groupId>
> >     <artifactId>hibernate-types-52</artifactId>
> >     <version>2.7.1</version>
> >     <scope>provided</scope>
> > </dependency>
> > <dependency>
> >     <groupId>org.postgresql</groupId>
> >     <artifactId>postgresql</artifactId>
> >     <version>42.2.8</version>
> >     <scope>provided</scope>
> > </dependency>
> >
> > 2. Make assembly file src/test/resources/assembly.xml with folowing
> content:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0";
> >          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0
> http://maven.apache.org/xsd/assembly-2.0.0.xsd";>
> >
> >     <id>libs</id>
> >
> >     <formats>
> >         <format>dir</format>
> >     </formats>
> >     <includeBaseDirectory>false</includeBaseDirectory>
> >
> >     <dependencySets>
> >         <dependencySet>
> >             <includes>
> >                 <include>org.postgresql:postgresql:jar:</include>
> >                 <include>org.hibernate:hibernate-entitymanager</include>
> >                 <include>com.vladmihalcea:hibernate-types-52</include>
> >             </includes>
> >             <useTransitiveDependencies>true</useTransitiveDependencies>
> >             <useTransitiveFiltering>true</useTransitiveFiltering>
> >             <scope>provided</scope>
> >         </dependencySet>
> >     </dependencySets>
> >
> > </assembly>
> >
> > 3. In pom.xml:
> > ...
> > <plugin>
> >     <artifactId>maven-assembly-plugin</artifactId>
> >     <version>3.2.0</version>
> >     <configuration>
> >         <descriptors>
> >             <descriptor>src/test/resources/assembly.xml</descriptor>
> >         </descriptors>
> >         <attach>false</attach>
> >         <!-- libraries placed in target/additional-libs. "finalName"
> specify first part of directory name, second part is constructed in
> assembly.xml from "id" tag -->
> >         <finalName>additional</finalName>
> >         <outputDirectory>target</outputDirectory>
> >     </configuration>
> >     <executions>
> >         <execution>
> >             <id>copy-hibernate-and-postgresql-driver</id>
> >             <phase>process-test-classes</phase>
> >             <goals>
> >                 <goal>single</goal>
> >              </goals>
> >          </execution>
> >     </executions>
> > </plugin>
> > ...
> >
> > 4. Specify folowing properties in arquillian.xml:
> > ...
> > <property name="dir">target/tomee-remote</property>
> > ...
> > <property name="additionalLibs">
> >     target/additional-libs/*.jar
> > </property>
> > ...
> > <property
> name="catalina_opts">-Djavax.persistence.provider=org.hibernate.jpa.HibernatePersistenceProvider</property>
> <!-- I use TomEE plus -->
> >
> > The result is libraries copied in "lib" folder of extracted tomee
> directory. One strange behavior of Maven assembly - directory name composed
> from two pars, one from pom.xml part (step 3) and second is from "lib" tag
> on step 2. I did not find way to specify directory name in one place.
> >
> > Besides, this solution allow me to specify datasource in arquillian.xml
> and do not use resources.xml for testing purposes.
> >
> > --
> > WIth best regards,
> > Makarov Alexey
> >
> > 18.11.2019, 14:01, "Richard Monson-Haefel" <[email protected]>:
> >>  Hi,
> >>
> >>  I looked and didn't understand the problem either. Can anyone else help
> >>  with this? I see that when it occurred before (following the thread
> >>  you linked) it was not resolved or at least no follow up email was
> sent.
> >>
> >>  Richard
> >>
> >>  On Fri, Nov 15, 2019 at 9:25 PM Makarov Alexey <[email protected]>
> wrote:
> >>
> >>>   Hello!
> >>>   I have a secod problem with Arquillian test. Test-method is passed,
> but
> >>>   checked as fail couse unable to undeploy test war-file:
> >>>
> >>>   https://pastebin.com/iLZevA7Q
> >>>
> >>>   I found this thread:
> >>>
> >>>
> http://tomee-openejb.979440.n4.nabble.com/Arquillian-Tomee-7-0-3-Bigger-Test-fail-on-undeploy-td4681765.html
> >>>
> >>>   but I can't understand, what can I do to solve my problem. I will be
> glad
> >>>   of any help!
> >>>
> >>>   --
> >>>   WIth best regards,
> >>>   Makarov Alexey
> >>
> >>  --
> >>  Richard Monson-Haefel
> >>  https://twitter.com/rmonson
> >>  https://www.linkedin.com/in/monsonhaefel/
>


-- 
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/

Reply via email to