jpa jar

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

jpa jar

Matthew Broadhead-2
seems like this must have been asked before...i have been moving some
common database code into a jar file and it works great.  but it is
included in several wars and those projects load the jar individually
each time.  i wondered if there is a way to load a jar only once into
TomEE and have it commonly accessed across all webapps?
Reply | Threaded
Open this post in threaded view
|

Re: jpa jar

Luis Rodríguez Fernández
Hello Matthew,

Probably the common classloader is the place for your jar, see [1]

Otherwise you could also packed all your apps in an .ear file and add your
.jar there. In tomee you can deploy .ear files as well [2]. For this
approach you have to declare the apps folder in conf/tomee.xml

<tomee>
  <!-- see http://tomee.apache.org/containers-and-resources.html -->

  <!-- activate next line to be able to deploy applications in apps -->
  <Deployments dir="apps" autoDeploy="true"/>
</tomee>


Hope it helps,

Luis

[1] https://tomcat.apache.org/tomcat-8.0-doc/class-loader-howto.html
[2] http://tomee.apache.org/deploying-in-tomee.html

El mié., 31 oct. 2018 a las 13:54, Matthew Broadhead
(<[hidden email]>) escribió:

> seems like this must have been asked before...i have been moving some
> common database code into a jar file and it works great.  but it is
> included in several wars and those projects load the jar individually
> each time.  i wondered if there is a way to load a jar only once into
> TomEE and have it commonly accessed across all webapps?
>


--

"Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better."

- Samuel Beckett
Reply | Threaded
Open this post in threaded view
|

Re: jpa jar

Matthew Broadhead-2
Hi Luis,

When using method [1] does the jar have to be manually dropped into a
common folder defined in the config?  That would be a pain.

What would be great if i could add some meta in the jar which means it
gets picked up by the common loader when scanned by future wars

i have lookeds into EARs but I need some time to get my head around it.
At the moment I use Tomcat virtual hosts in production although I want
to change it so that httpd is doing the proxying

On 31/10/2018 14:06, Luis Rodríguez Fernández wrote:

> Hello Matthew,
>
> Probably the common classloader is the place for your jar, see [1]
>
> Otherwise you could also packed all your apps in an .ear file and add your
> .jar there. In tomee you can deploy .ear files as well [2]. For this
> approach you have to declare the apps folder in conf/tomee.xml
>
> <tomee>
>    <!-- see http://tomee.apache.org/containers-and-resources.html -->
>
>    <!-- activate next line to be able to deploy applications in apps -->
>    <Deployments dir="apps" autoDeploy="true"/>
> </tomee>
>
>
> Hope it helps,
>
> Luis
>
> [1] https://tomcat.apache.org/tomcat-8.0-doc/class-loader-howto.html
> [2] http://tomee.apache.org/deploying-in-tomee.html
>
> El mié., 31 oct. 2018 a las 13:54, Matthew Broadhead
> (<[hidden email]>) escribió:
>
>> seems like this must have been asked before...i have been moving some
>> common database code into a jar file and it works great.  but it is
>> included in several wars and those projects load the jar individually
>> each time.  i wondered if there is a way to load a jar only once into
>> TomEE and have it commonly accessed across all webapps?
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: jpa jar

Luis Rodríguez Fernández
Hello Matthew,

mmm, yes every jar that you drop in the common classloader will be visible
to all webapps.

- "meta in the jar": mmm, yes, e.g. in our weblogic servers we have exactly
that case...
  -In the META-INF/MANIFEST.MF of the shared jar:
   Extension-Name: commonFilters
   Specification-Version: 1.0
   Implementation-Version: 1.8
- In the webapps:
  Extension-List: ssoFilters
  ssoFilters-Extension-Name: commonFilters
  ssoFilters-Specification-Version: 1.0
  ssoFilters-Implementation-Version: 1.8

... and in weblogic we deploy the jar as a library. You can have a look at
https://docs.oracle.com/javase/6/docs/technotes/guides/extensions/versioning.html

For me the simplest would be to copy your jar to $CATALINA_BASE/lib.

Hope it helps,

Luis













El mié., 31 oct. 2018 a las 14:28, Matthew Broadhead
(<[hidden email]>) escribió:

> Hi Luis,
>
> When using method [1] does the jar have to be manually dropped into a
> common folder defined in the config?  That would be a pain.
>
> What would be great if i could add some meta in the jar which means it
> gets picked up by the common loader when scanned by future wars
>
> i have lookeds into EARs but I need some time to get my head around it.
> At the moment I use Tomcat virtual hosts in production although I want
> to change it so that httpd is doing the proxying
>
> On 31/10/2018 14:06, Luis Rodríguez Fernández wrote:
> > Hello Matthew,
> >
> > Probably the common classloader is the place for your jar, see [1]
> >
> > Otherwise you could also packed all your apps in an .ear file and add
> your
> > .jar there. In tomee you can deploy .ear files as well [2]. For this
> > approach you have to declare the apps folder in conf/tomee.xml
> >
> > <tomee>
> >    <!-- see http://tomee.apache.org/containers-and-resources.html -->
> >
> >    <!-- activate next line to be able to deploy applications in apps -->
> >    <Deployments dir="apps" autoDeploy="true"/>
> > </tomee>
> >
> >
> > Hope it helps,
> >
> > Luis
> >
> > [1] https://tomcat.apache.org/tomcat-8.0-doc/class-loader-howto.html
> > [2] http://tomee.apache.org/deploying-in-tomee.html
> >
> > El mié., 31 oct. 2018 a las 13:54, Matthew Broadhead
> > (<[hidden email]>) escribió:
> >
> >> seems like this must have been asked before...i have been moving some
> >> common database code into a jar file and it works great.  but it is
> >> included in several wars and those projects load the jar individually
> >> each time.  i wondered if there is a way to load a jar only once into
> >> TomEE and have it commonly accessed across all webapps?
> >>
> >
>
>

--

"Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better."

- Samuel Beckett
Reply | Threaded
Open this post in threaded view
|

Re: jpa jar

Matthew Broadhead-2
Thank Luis,

I will try following your 2nd method.

I found this link to skinny wars for maven-ear-plugin
https://maven.apache.org/plugins/maven-ear-plugin/examples/skinny-wars.html

It seems very similar to your weblogic example with the MANIFEST.MF
configuration

It should work in my case if I change my virtual host setup

On 31/10/2018 17:44, Luis Rodríguez Fernández wrote:

> Hello Matthew,
>
> mmm, yes every jar that you drop in the common classloader will be visible
> to all webapps.
>
> - "meta in the jar": mmm, yes, e.g. in our weblogic servers we have exactly
> that case...
>    -In the META-INF/MANIFEST.MF of the shared jar:
>     Extension-Name: commonFilters
>     Specification-Version: 1.0
>     Implementation-Version: 1.8
> - In the webapps:
>    Extension-List: ssoFilters
>    ssoFilters-Extension-Name: commonFilters
>    ssoFilters-Specification-Version: 1.0
>    ssoFilters-Implementation-Version: 1.8
>
> ... and in weblogic we deploy the jar as a library. You can have a look at
> https://docs.oracle.com/javase/6/docs/technotes/guides/extensions/versioning.html
>
> For me the simplest would be to copy your jar to $CATALINA_BASE/lib.
>
> Hope it helps,
>
> Luis
>
>
>
>
>
>
>
>
>
>
>
>
>
> El mié., 31 oct. 2018 a las 14:28, Matthew Broadhead
> (<[hidden email]>) escribió:
>
>> Hi Luis,
>>
>> When using method [1] does the jar have to be manually dropped into a
>> common folder defined in the config?  That would be a pain.
>>
>> What would be great if i could add some meta in the jar which means it
>> gets picked up by the common loader when scanned by future wars
>>
>> i have lookeds into EARs but I need some time to get my head around it.
>> At the moment I use Tomcat virtual hosts in production although I want
>> to change it so that httpd is doing the proxying
>>
>> On 31/10/2018 14:06, Luis Rodríguez Fernández wrote:
>>> Hello Matthew,
>>>
>>> Probably the common classloader is the place for your jar, see [1]
>>>
>>> Otherwise you could also packed all your apps in an .ear file and add
>> your
>>> .jar there. In tomee you can deploy .ear files as well [2]. For this
>>> approach you have to declare the apps folder in conf/tomee.xml
>>>
>>> <tomee>
>>>     <!-- see http://tomee.apache.org/containers-and-resources.html -->
>>>
>>>     <!-- activate next line to be able to deploy applications in apps -->
>>>     <Deployments dir="apps" autoDeploy="true"/>
>>> </tomee>
>>>
>>>
>>> Hope it helps,
>>>
>>> Luis
>>>
>>> [1] https://tomcat.apache.org/tomcat-8.0-doc/class-loader-howto.html
>>> [2] http://tomee.apache.org/deploying-in-tomee.html
>>>
>>> El mié., 31 oct. 2018 a las 13:54, Matthew Broadhead
>>> (<[hidden email]>) escribió:
>>>
>>>> seems like this must have been asked before...i have been moving some
>>>> common database code into a jar file and it works great.  but it is
>>>> included in several wars and those projects load the jar individually
>>>> each time.  i wondered if there is a way to load a jar only once into
>>>> TomEE and have it commonly accessed across all webapps?
>>>>
>>