You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Yann BLAZART <ya...@externe.bnpparibas.com> on 2015/10/14 11:38:32 UTC

Tomee maven plugin, reload on update, datasource not reinjected

Hello everybody.

I'm currently using the tomee maven plugin to make some UI dev with vaddin.

The app is an ear, with an ejb module (where are ejb's of course) and with a war that use the ejb's.
Why ? Because the target server is a weblogic 10.3.6 (Java EE 5). So ejb must be in ejb module.

So, in web.xml I have <ejb-ref> elements, and in the war, I'm doing initial context lookup to java:comp/env/...

This working well when I launch tomee:run. But when I compile some changes in the war, the reload statrt but after, when the code use the ejb, second time I have a NullPointerExeption :

The datasource could not be injected anymore in the ejb (by using @Resource(name="xxx/xxx/xaDataSource")

In the logs, on reload I have :

INFO - Undeploying app: C:\devDATA\projects\GIT\xxx\xxx\xxx-ear\target\apache-tomee\apps\xxx-ear-1.0.4-SNAPSHOT
SEVERE - The web application [xxx] created a ThreadLocal with key of type [com.vaadin.util.CurrentInstance$1] (value [com.vaadin.util.CurrentInstance$1@1f2786e3]) and a value of type [java.util.HashMap] (value [{class com.vaadin.ui.UI=com.vaadin.util.CurrentInstance@6c5428c4, class com.vaadin.server.VaadinSession=com.vaadin.util.CurrentInstance@31814e0b, class com.vaadin.server.VaadinService=com.vaadin.util.CurrentInstance@6272b3ea}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
INFO - Closing DataSource: xxx-ear-1.0.4-SNAPSHOT/xxx/xxx/xaDataSource
INFO - Creating dedicated application classloader for xxx-ear-1.0.4-SNAPSHOT
.....
INFO - OpenWebBeans Container is starting...
INFO - OpenWebBeans Container has started, it took 60 ms.
WARNING - Failed to register in JMX: javax.naming.NameNotFoundException: Name "Resource/xxx-ear-1.0.4-SNAPSHOT/xxx/xxx/xaDataSource" not found.
WARNING - Failed to register in JMX: javax.naming.NameNotFoundException: Name "Resource/xxx-ear-1.0.4-SNAPSHOT/xxx/xxx/xaDataSource" not found.
INFO - Using readers:

The ejb are @Stateless, with @Local interface.

The config, is in the pom.xml of the ear :

<plugin>
    <groupId>org.apache.tomee.maven</groupId>
    <artifactId>tomee-maven-plugin</artifactId>
    <version>7.0.0-SNAPSHOT</version>
    <configuration>
        <inlinedTomEEXml>
            <tomee>
                <Deployments dir="apps"/>
                <Resource id="xxx/xxx/xaDataSource" type="DataSource">
                    JtaManaged = true
                    JdbcUrl = jdbc:oracle:thin:@xxx:1521/xxx
                    JdbcDriver = oracle.jdbc.driver.OracleDriver
                    UserName=xxx
                    Password=xxx
                </Resource>
            </tomee>
        </inlinedTomEEXml>
        <libs>
            <lib>oracle:ojdbc6:11g</lib>
        </libs>
        <synchronizations>
            <synch>
                <source>${project.basedir}/../xxx-web/target/classes/</source>
                <target>${project.basedir}/target/apache-tomee/apps/xxx-ear-${project.version}/xxx-web-${project.version}/WEB-INF/classes/</target>
                <extensions>
                    <extension>.class</extension>
                </extensions>
            </synch>
            <synch>
                <source>${project.basedir}/../xxx-jar/target/</source>
                <target>${project.basedir}/target/apache-tomee/apps/xxx-ear-${project.version}/</target>
                <extensions>
                    <extension>.jar</extension>
                </extensions>
            </synch>
        </synchronizations>
        <reloadOnUpdate>true</reloadOnUpdate>
    </configuration>


Regards.


This message and any attachments (the "message") is
intended solely for the intended addressees and is confidential. 
If you receive this message in error,or are not the intended recipient(s), 
please delete it and any copies from your systems and immediately notify
the sender. Any unauthorized view, use that does not comply with its purpose, 
dissemination or disclosure, either whole or partial, is prohibited. Since the internet 
cannot guarantee the integrity of this message which may not be reliable, BNP PARIBAS 
(and its subsidiaries) shall not be liable for the message if modified, changed or falsified. 
Do not print this message unless it is necessary,consider the environment.

----------------------------------------------------------------------------------------------------------------------------------

Ce message et toutes les pieces jointes (ci-apres le "message") 
sont etablis a l'intention exclusive de ses destinataires et sont confidentiels.
Si vous recevez ce message par erreur ou s'il ne vous est pas destine,
merci de le detruire ainsi que toute copie de votre systeme et d'en avertir
immediatement l'expediteur. Toute lecture non autorisee, toute utilisation de 
ce message qui n'est pas conforme a sa destination, toute diffusion ou toute 
publication, totale ou partielle, est interdite. L'Internet ne permettant pas d'assurer
l'integrite de ce message electronique susceptible d'alteration, BNP Paribas 
(et ses filiales) decline(nt) toute responsabilite au titre de ce message dans l'hypothese
ou il aurait ete modifie, deforme ou falsifie. 
N'imprimez ce message que si necessaire, pensez a l'environnement.

RE: Tomee maven plugin, reload on update, datasource not reinjected

Posted by Yann BLAZART <ya...@externe.bnpparibas.com>.
Damn, you're right, I missed that.....

Shame on me. Removed, now it works.

-----Original Message-----
From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com] 
Sent: mercredi 14 octobre 2015 11:46
To: users@tomee.apache.org
Subject: Re: Tomee maven plugin, reload on update, datasource not reinjected

Hi Yann,

Do you have a resources.xml somewhere with the same datasource? Asking cause "xxx-ear-1.0.4-SNAPSHOT/xxx/xxx/xaDataSource" should happend for application resources but not container resources.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber <http://www.tomitribe.com>

2015-10-14 11:38 GMT+02:00 Yann BLAZART <yann.blazart@externe.bnpparibas.com
>:

> Hello everybody.
>
> I'm currently using the tomee maven plugin to make some UI dev with vaddin.
>
> The app is an ear, with an ejb module (where are ejb's of course) and 
> with a war that use the ejb's.
> Why ? Because the target server is a weblogic 10.3.6 (Java EE 5). So 
> ejb must be in ejb module.
>
> So, in web.xml I have <ejb-ref> elements, and in the war, I'm doing 
> initial context lookup to java:comp/env/...
>
> This working well when I launch tomee:run. But when I compile some 
> changes in the war, the reload statrt but after, when the code use the 
> ejb, second time I have a NullPointerExeption :
>
> The datasource could not be injected anymore in the ejb (by using
> @Resource(name="xxx/xxx/xaDataSource")
>
> In the logs, on reload I have :
>
> INFO - Undeploying app:
> C:\devDATA\projects\GIT\xxx\xxx\xxx-ear\target\apache-tomee\apps\xxx-e
> ar-1.0.4-SNAPSHOT SEVERE - The web application [xxx] created a 
> ThreadLocal with key of type [com.vaadin.util.CurrentInstance$1] 
> (value
> [com.vaadin.util.CurrentInstance$1@1f2786e3]) and a value of type 
> [java.util.HashMap] (value [{class 
> com.vaadin.ui.UI=com.vaadin.util.CurrentInstance@6c5428c4, class 
> com.vaadin.server.VaadinSession=com.vaadin.util.CurrentInstance@31814e
> 0b,
> class
> com.vaadin.server.VaadinService=com.vaadin.util.CurrentInstance@6272b3
> ea}]) but failed to remove it when the web application was stopped. 
> Threads are going to be renewed over time to try and avoid a probable 
> memory leak.
> INFO - Closing DataSource: xxx-ear-1.0.4-SNAPSHOT/xxx/xxx/xaDataSource
> INFO - Creating dedicated application classloader for 
> xxx-ear-1.0.4-SNAPSHOT .....
> INFO - OpenWebBeans Container is starting...
> INFO - OpenWebBeans Container has started, it took 60 ms.
> WARNING - Failed to register in JMX: javax.naming.NameNotFoundException:
> Name "Resource/xxx-ear-1.0.4-SNAPSHOT/xxx/xxx/xaDataSource" not found.
> WARNING - Failed to register in JMX: javax.naming.NameNotFoundException:
> Name "Resource/xxx-ear-1.0.4-SNAPSHOT/xxx/xxx/xaDataSource" not found.
> INFO - Using readers:
>
> The ejb are @Stateless, with @Local interface.
>
> The config, is in the pom.xml of the ear :
>
> <plugin>
>     <groupId>org.apache.tomee.maven</groupId>
>     <artifactId>tomee-maven-plugin</artifactId>
>     <version>7.0.0-SNAPSHOT</version>
>     <configuration>
>         <inlinedTomEEXml>
>             <tomee>
>                 <Deployments dir="apps"/>
>                 <Resource id="xxx/xxx/xaDataSource" type="DataSource">
>                     JtaManaged = true
>                     JdbcUrl = jdbc:oracle:thin:@xxx:1521/xxx
>                     JdbcDriver = oracle.jdbc.driver.OracleDriver
>                     UserName=xxx
>                     Password=xxx
>                 </Resource>
>             </tomee>
>         </inlinedTomEEXml>
>         <libs>
>             <lib>oracle:ojdbc6:11g</lib>
>         </libs>
>         <synchronizations>
>             <synch>
>
> <source>${project.basedir}/../xxx-web/target/classes/</source>
>
> <target>${project.basedir}/target/apache-tomee/apps/xxx-ear-${project.version}/xxx-web-${project.version}/WEB-INF/classes/</target>
>                 <extensions>
>                     <extension>.class</extension>
>                 </extensions>
>             </synch>
>             <synch>
>                 <source>${project.basedir}/../xxx-jar/target/</source>
>
> <target>${project.basedir}/target/apache-tomee/apps/xxx-ear-${project.version}/</target>
>                 <extensions>
>                     <extension>.jar</extension>
>                 </extensions>
>             </synch>
>         </synchronizations>
>         <reloadOnUpdate>true</reloadOnUpdate>
>     </configuration>
>
>
> Regards.
>
>
> This message and any attachments (the "message") is intended solely 
> for the intended addressees and is confidential.
> If you receive this message in error,or are not the intended 
> recipient(s), please delete it and any copies from your systems and 
> immediately notify the sender. Any unauthorized view, use that does 
> not comply with its purpose, dissemination or disclosure, either whole 
> or partial, is prohibited. Since the internet cannot guarantee the 
> integrity of this message which may not be reliable, BNP PARIBAS (and 
> its subsidiaries) shall not be liable for the message if modified, 
> changed or falsified.
> Do not print this message unless it is necessary,consider the environment.
>
>
> ----------------------------------------------------------------------
> ------------------------------------------------------------
>
> Ce message et toutes les pieces jointes (ci-apres le "message") sont 
> etablis a l'intention exclusive de ses destinataires et sont 
> confidentiels.
> Si vous recevez ce message par erreur ou s'il ne vous est pas destine, 
> merci de le detruire ainsi que toute copie de votre systeme et d'en 
> avertir immediatement l'expediteur. Toute lecture non autorisee, toute 
> utilisation de ce message qui n'est pas conforme a sa destination, 
> toute diffusion ou toute publication, totale ou partielle, est 
> interdite. L'Internet ne permettant pas d'assurer l'integrite de ce 
> message electronique susceptible d'alteration, BNP Paribas (et ses 
> filiales) decline(nt) toute responsabilite au titre de ce message dans 
> l'hypothese ou il aurait ete modifie, deforme ou falsifie.
> N'imprimez ce message que si necessaire, pensez a l'environnement.
>

Re: Tomee maven plugin, reload on update, datasource not reinjected

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Yann,

Do you have a resources.xml somewhere with the same datasource? Asking
cause "xxx-ear-1.0.4-SNAPSHOT/xxx/xxx/xaDataSource" should happend for
application resources but not container resources.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-10-14 11:38 GMT+02:00 Yann BLAZART <yann.blazart@externe.bnpparibas.com
>:

> Hello everybody.
>
> I'm currently using the tomee maven plugin to make some UI dev with vaddin.
>
> The app is an ear, with an ejb module (where are ejb's of course) and with
> a war that use the ejb's.
> Why ? Because the target server is a weblogic 10.3.6 (Java EE 5). So ejb
> must be in ejb module.
>
> So, in web.xml I have <ejb-ref> elements, and in the war, I'm doing
> initial context lookup to java:comp/env/...
>
> This working well when I launch tomee:run. But when I compile some changes
> in the war, the reload statrt but after, when the code use the ejb, second
> time I have a NullPointerExeption :
>
> The datasource could not be injected anymore in the ejb (by using
> @Resource(name="xxx/xxx/xaDataSource")
>
> In the logs, on reload I have :
>
> INFO - Undeploying app:
> C:\devDATA\projects\GIT\xxx\xxx\xxx-ear\target\apache-tomee\apps\xxx-ear-1.0.4-SNAPSHOT
> SEVERE - The web application [xxx] created a ThreadLocal with key of type
> [com.vaadin.util.CurrentInstance$1] (value
> [com.vaadin.util.CurrentInstance$1@1f2786e3]) and a value of type
> [java.util.HashMap] (value [{class
> com.vaadin.ui.UI=com.vaadin.util.CurrentInstance@6c5428c4, class
> com.vaadin.server.VaadinSession=com.vaadin.util.CurrentInstance@31814e0b,
> class
> com.vaadin.server.VaadinService=com.vaadin.util.CurrentInstance@6272b3ea}])
> but failed to remove it when the web application was stopped. Threads are
> going to be renewed over time to try and avoid a probable memory leak.
> INFO - Closing DataSource: xxx-ear-1.0.4-SNAPSHOT/xxx/xxx/xaDataSource
> INFO - Creating dedicated application classloader for
> xxx-ear-1.0.4-SNAPSHOT
> .....
> INFO - OpenWebBeans Container is starting...
> INFO - OpenWebBeans Container has started, it took 60 ms.
> WARNING - Failed to register in JMX: javax.naming.NameNotFoundException:
> Name "Resource/xxx-ear-1.0.4-SNAPSHOT/xxx/xxx/xaDataSource" not found.
> WARNING - Failed to register in JMX: javax.naming.NameNotFoundException:
> Name "Resource/xxx-ear-1.0.4-SNAPSHOT/xxx/xxx/xaDataSource" not found.
> INFO - Using readers:
>
> The ejb are @Stateless, with @Local interface.
>
> The config, is in the pom.xml of the ear :
>
> <plugin>
>     <groupId>org.apache.tomee.maven</groupId>
>     <artifactId>tomee-maven-plugin</artifactId>
>     <version>7.0.0-SNAPSHOT</version>
>     <configuration>
>         <inlinedTomEEXml>
>             <tomee>
>                 <Deployments dir="apps"/>
>                 <Resource id="xxx/xxx/xaDataSource" type="DataSource">
>                     JtaManaged = true
>                     JdbcUrl = jdbc:oracle:thin:@xxx:1521/xxx
>                     JdbcDriver = oracle.jdbc.driver.OracleDriver
>                     UserName=xxx
>                     Password=xxx
>                 </Resource>
>             </tomee>
>         </inlinedTomEEXml>
>         <libs>
>             <lib>oracle:ojdbc6:11g</lib>
>         </libs>
>         <synchronizations>
>             <synch>
>
> <source>${project.basedir}/../xxx-web/target/classes/</source>
>
> <target>${project.basedir}/target/apache-tomee/apps/xxx-ear-${project.version}/xxx-web-${project.version}/WEB-INF/classes/</target>
>                 <extensions>
>                     <extension>.class</extension>
>                 </extensions>
>             </synch>
>             <synch>
>                 <source>${project.basedir}/../xxx-jar/target/</source>
>
> <target>${project.basedir}/target/apache-tomee/apps/xxx-ear-${project.version}/</target>
>                 <extensions>
>                     <extension>.jar</extension>
>                 </extensions>
>             </synch>
>         </synchronizations>
>         <reloadOnUpdate>true</reloadOnUpdate>
>     </configuration>
>
>
> Regards.
>
>
> This message and any attachments (the "message") is
> intended solely for the intended addressees and is confidential.
> If you receive this message in error,or are not the intended recipient(s),
> please delete it and any copies from your systems and immediately notify
> the sender. Any unauthorized view, use that does not comply with its
> purpose,
> dissemination or disclosure, either whole or partial, is prohibited. Since
> the internet
> cannot guarantee the integrity of this message which may not be reliable,
> BNP PARIBAS
> (and its subsidiaries) shall not be liable for the message if modified,
> changed or falsified.
> Do not print this message unless it is necessary,consider the environment.
>
>
> ----------------------------------------------------------------------------------------------------------------------------------
>
> Ce message et toutes les pieces jointes (ci-apres le "message")
> sont etablis a l'intention exclusive de ses destinataires et sont
> confidentiels.
> Si vous recevez ce message par erreur ou s'il ne vous est pas destine,
> merci de le detruire ainsi que toute copie de votre systeme et d'en avertir
> immediatement l'expediteur. Toute lecture non autorisee, toute utilisation
> de
> ce message qui n'est pas conforme a sa destination, toute diffusion ou
> toute
> publication, totale ou partielle, est interdite. L'Internet ne permettant
> pas d'assurer
> l'integrite de ce message electronique susceptible d'alteration, BNP
> Paribas
> (et ses filiales) decline(nt) toute responsabilite au titre de ce message
> dans l'hypothese
> ou il aurait ete modifie, deforme ou falsifie.
> N'imprimez ce message que si necessaire, pensez a l'environnement.
>