Forums de discussion

Running service inside main method.

Shibu K V, modifié il y a 10 années.

Running service inside main method.

New Member Publications: 7 Date d'inscription: 06/09/13 Publications récentes
I am developing a Liferay portlet using Eclipse IDE. I just created an entity called "USerDetails" in service.xml. Table "USerDetails" is created in the DB and I could save UserDetails entity to the DB from processAction() method.

How can I save a record to the USerDetails table by running a simple java program with a main method contains code to save data.
Its throwing "BeanLocator is null for servlet context User-Details-portlet" exception.
I tried by adding "User-Details-portlet-service.jar" to the build path, still the same error occurs.

How can I overcome this issue?
thumbnail
Tanweer Ahmed ., modifié il y a 1 année.

RE: Running service inside main method.

Expert Publications: 322 Date d'inscription: 11/03/10 Publications récentes
Hi Shibu,

Main method does not require Servlet/Portlet Container to run whereas Portlet runs inside a Portlet Container.
And your service.xml would be part of User-Details Portlet.
Hence you will not be able to run your service from the Main method.

Hope this helps,

Regards,
Tanweer
thumbnail
David H Nebinger, modifié il y a 10 années.

RE: Running service inside main method.

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
You cannot run within main. There is so much stuff that would have to be up and running to use in main() it is impractical. You have the whole spring context for Liferay and your portlet, etc.