留言板

Liferay Portal 7: Service Builder Broken

thumbnail
Fuad Efendi,修改在9 年前。

Liferay Portal 7: Service Builder Broken

Regular Member 帖子: 180 加入日期: 07-4-5 最近的帖子
Hi,

After recent refactoring and moving Service Builder outside of portal-impl.jar it is broken.
I spent many hours on a research but I cannot find the cause.

I added "System.out.println()"


	private void _createModelClp(Entity entity) throws Exception {
		if (Validator.isNull(_pluginName)) {
			return;
		}

		JavaClass javaClass = _getJavaClass(
			_outputPath + "/model/impl/" + entity.getName() + "Impl.java");

		Map<string, javamethod> methods = new HashMap&lt;&gt;();

		for (JavaMethod method : javaClass.getMethods()) {
			methods.put(method.getDeclarationSignature(false), method);
		}

		Type superClass = javaClass.getSuperClass();

		String superClassValue = superClass.getValue();
		
		System.out.println("superClassValue: "+superClassValue);

</string,>


Ant it outputs "java.lang.Object" instead of "BaseModelImpl"

Right now (2015.04.21), "Liferay Plugins" GIT repository is broken, "ant build-service" for sample-service-builder-portlet outputs this:


    [echo] Exception in thread "main" java.lang.NullPointerException
    [echo]     at com.liferay.portal.tools.service.builder.ServiceBuilder._getMethods(ServiceBuilder.java:4490)
    [echo]     at com.liferay.portal.tools.service.builder.ServiceBuilder._getMethods(ServiceBuilder.java:4484)
    [echo]     at com.liferay.portal.tools.service.builder.ServiceBuilder._createModelClp(ServiceBuilder.java:2583)
    [echo]     at com.liferay.portal.tools.service.builder.ServiceBuilder.<init>(ServiceBuilder.java:895)
    [echo]     at com.liferay.portal.tools.service.builder.ServiceBuilder.main(ServiceBuilder.java:305)</init>



It corresponds to the parent class "java.lang.Object" discovery by QDOX. There were almost no changes to this except refactoring.


Do we have JIRA story for this?

Thanks,
thumbnail
Ramalingaiah Dudidmetle,修改在9 年前。

RE: Liferay Portal 7: Service Builder Broken

Expert 帖子: 486 加入日期: 14-8-16 最近的帖子
Hi Fuad Efendi,
you have a problem in JAVA 8 not working,
java 8 remove and 7 or 6 install ,
it install java 7or 6 working fine,
i get same error service builder broken in Liferay 6.2

Thanks &Regards
Ram
thumbnail
Fuad Efendi,修改在9 年前。

RE: Liferay Portal 7: Service Builder Broken

Regular Member 帖子: 180 加入日期: 07-4-5 最近的帖子
I use Java 7 only
thumbnail
David H Nebinger,修改在9 年前。

RE: Liferay Portal 7: Service Builder Broken

Liferay Legend 帖子: 14916 加入日期: 06-9-2 最近的帖子
As well you should, neither java 6 nor java 8 are supported on the L7 milestones.
thumbnail
Fuad Efendi,修改在9 年前。

RE: Liferay Portal 7: Service Builder Broken

Regular Member 帖子: 180 加入日期: 07-4-5 最近的帖子
I am talking about current HEAD of "master" branch of both,
https://github.com/liferay/liferay-portal
https://github.com/liferay/liferay-plugins

It is updates daily; there is a bug somewhere which I am trying to fix & or, I would like to know who is going to fix it and how soon.

It is not related to Java version nor Java vendor.


Thanks,
thumbnail
Fuad Efendi,修改在9 年前。

RE: Liferay Portal 7: Service Builder Broken

Regular Member 帖子: 180 加入日期: 07-4-5 最近的帖子
Just try to clone "liferay-plugins" from GIT "master" branch, and run "ant build-service" on sample-service-builder-portlet.

Fortunately, I can use ServiceBuilder from Liferay 7 M4 SDK, but I am not sure that generated code will be forward compatible; plus I want(!!!) to know where the problem is.
thumbnail
James Falkner,修改在9 年前。

Moved to Milestone Release Feedback category

Liferay Legend 帖子: 1399 加入日期: 10-9-17 最近的帖子
Moving to Milestone feedback category. I think this breakage is temporary and will be fixed. The refactoring is still in pretty turbulent waters emoticon
thumbnail
Fuad Efendi,修改在8 年前。

RE: Liferay Portal 7: Service Builder Broken

Regular Member 帖子: 180 加入日期: 07-4-5 最近的帖子
I found that nothing wrong with ServiceBuilder; I run provided sample in isolated environment, and it works. Although it needs references to external portal-service.jar, portal-impl.jar, and util-java.jar

I found that this is a bug with build scripts in Liferay Plugins SDK recently introduced (by refactoring ServiceBuilder). Possibly, build-common-plugin.xml is outdated.

This worked for me (with additional JARs in a classpath):


	<taskdef classpathref="service.builder.classpath" resource="com/liferay/portal/tools/service/builder/ant/taskdefs.properties" />

	<target name="build-service">
		<service-builder apiDir="../tmp/api" hbmFileName="../tmp/src/META-INF/portal-hbm.xml" implDir="../tmp/src" inputFileName="service.xml" modelHintsFileName="../tmp/src/META-INF/portal-model-hints.xml" resourcesDir="../tmp/src" springFileName="../tmp/src/META-INF/portal-spring.xml" sqlDir="../tmp/sql" testDir="../tmp/test/integration" />
	</target>


Plus, there are some outdated Jars which are not needed by ServiceVuilder, but still there.

Work-in-Progress emoticon
thumbnail
Fuad Efendi,修改在8 年前。

RE: Liferay Portal 7: Service Builder Broken

Regular Member 帖子: 180 加入日期: 07-4-5 最近的帖子
I located the problem, this attribute is missing in build-common-plugin.xml:

<attribute name="service.target.entity.name" default="MyService"/>


"MyService" is dummy temporary PoC; I think whole "build-service" macrodef must be rewritten for new ServiceBuilder.
thumbnail
Fuad Efendi,修改在8 年前。

RE: Liferay Portal 7: Service Builder Broken

Regular Member 帖子: 180 加入日期: 07-4-5 最近的帖子
I was partially wrong; we have "liferay-plugins" repository with updated almost daily com.liferay.portal.tools.service.builder.jar, and we also have outdated "build-service" definition in ANT.

If you want to use newest Service Builder right now, then follow example ANT script from Service Builder source distribution, only subset of available parameters listed here:

<!--?xml version="1.0"?-->


<project>
	<path id="service.builder.classpath">
		<fileset dir="../lib" includes="*.jar" />
		<fileset dir="../../../../tools/sdk/dist" includes="com.liferay.portal.tools.service.builder-*.jar" />
	</path>

	<taskdef classpathref="service.builder.classpath" resource="com/liferay/portal/tools/service/builder/ant/taskdefs.properties" />

	<target name="build-service">
		<service-builder apiDir="../tmp/api" hbmFileName="../tmp/src/META-INF/portal-hbm.xml" implDir="../tmp/src" inputFileName="service.xml" modelHintsFileName="../tmp/src/META-INF/portal-model-hints.xml" resourcesDir="../tmp/src" springFileName="../tmp/src/META-INF/portal-spring.xml" sqlDir="../tmp/sql" testDir="../tmp/test/integration" />
	</target>
</project>
thumbnail
Fuad Efendi,修改在8 年前。

RE: Liferay Portal 7: Service Builder Broken

Regular Member 帖子: 180 加入日期: 07-4-5 最近的帖子
JIRA Issue Created:
https://issues.liferay.com/browse/LPS-55241

This issue is Windows specific; or any environment using backslash for a path. Perhaps it never happens on Linux.

Contributed solution:
https://github.com/liferay/liferay-portal/pull/712

Thank you!
thumbnail
Shinn Lok,修改在8 年前。

RE: Liferay Portal 7: Service Builder Broken

Junior Member 帖子: 89 加入日期: 11-1-14 最近的帖子
Hey Fuad,

Thanks for debugging this and sending us a fix!

I have forwarded your pull request:

https://github.com/brianchandotcom/liferay-portal/pull/26028
thumbnail
Fuad Efendi,修改在8 年前。

RE: Liferay Portal 7: Service Builder Broken

Regular Member 帖子: 180 加入日期: 07-4-5 最近的帖子
Hi Shinn,

Thank you very much for reviewing & improving the fix; the fix already applied, very fast!