Message Boards

how to use jdbc jar in tomcat/lib

Scarletake Bwi, modified 3 Years ago.

how to use jdbc jar in tomcat/lib

Expert Posts: 326 Join Date: 12/20/10 Recent Posts

hi

i know if i use serivce builder and i want referenct the service api, i should modify the build.gradle

and add 

compile project(":modules:ServiceBuilderDemo:ServiceBuilderDemo-api")

but how about i want use jdbc jar in tomcat/lib? because i have many old data have to sync to new service-builder object. and i do not want add jar in each module-project. i want just reuse it and just only one version is okay for me.

is there any place i can just config and reach the goal?

thank you

thumbnail
Andrew Jardine, modified 3 Years ago.

RE: how to use jdbc jar in tomcat/lib

Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts

Hey Scarletake,

I'm not sure that I am totally following what it is you want to do, but if the goal is to try to have a library globally available through the TOMCAT_HOME/lib/ext folder then you can still do this in 7.x, but it requires a couple of extra steps. 

1. Place the library in the /lib/ext directory of course

2. In your portal-ext.properties file you need to add the property module.framework.system.packages.extra which should include the values that the portal provides and the jar you are looking to include (I believe you have to provide both and you can't just specify your jar)

3. Restart your portal

You sitll have to include a reference to the library in your build.gradle or POM files of course but once you have done this you should be able to change the inclusions to be "compile" instead of including them in the final package. 

NOTE though that sometimes the library that you want to use is "OSGI ready" in which case all you have to do is copy the jar to the LIFERAY_HOME/osgi/modules location and the container will take care of the rest for you. I use this approach with a handful of libraries including gson, stripe and a few others and it works great. 

Let us know how it goes!

Scarletake Bwi, modified 3 Years ago.

RE: RE: how to use jdbc jar in tomcat/lib

Expert Posts: 326 Join Date: 12/20/10 Recent Posts

hi andrew

thnak you very much for reply.

yes, i google it, got many posts and articls, and try many times.

i change my strategy(i do not like word "give up"). it's too complicated.

i re-write all common jars that i made for all portlet(now we call module project). as service, build via service builder, even some of those are empty entity, maybe for very first time, i have to do many thing, but i think in future, i only have to mantain service, and do not need to restart server.

again, thank you.

thumbnail
Andrew Jardine, modified 3 Years ago.

RE: how to use jdbc jar in tomcat/lib

Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts

Hi Scarletake,

If I am following what you are saying then it sounds like the better solution. The idea in the 7 series is to have things broken up anyway rather than everything all bundled together into a single module. If you are using Service Builder and the idea of "fake entities" (also common place to have a standard pattern for development), and you are on 7.2, AND you don't need to persist the entity data, then make sure you add persistence="false" to the <entity/> definitions. That will eliminate all the persistence level code from being generated. No point if generating it and having it lying around if you aren't planning to use it :)

Scarletake Bwi, modified 3 Years ago.

RE: RE: how to use jdbc jar in tomcat/lib

Expert Posts: 326 Join Date: 12/20/10 Recent Posts

Hi Andrew

thank you!

on 7.3, newest. 

i still on tring, due to i a have to generate excel file, i ain't sure the service can provide it or not. hope it can.

again, thiank you and have a nice day.