留言板
Error cast using Service Builder
I,m using liferay 7 with Tomcat 8, i need to insert a product on my data base using Service Builder.
I,ve been searching on internet to do the insert method in my personal portlet that is in another package, i do all the dependencies and imports, and it really works, but when I run de project and execute my method i had an error like this:
(" java.lang.ClassCastException: com.sun.proxy.$Proxy470 cannot be cast to com.serviceBuilder.service.ProductoLocalService")
My codeThis code is in my personal porlet in module DatosPersonales)
Producto prod = ProductoLocalServiceUtil.createProducto(0); ("The error apears in this line")
prod.setCodigo("Codigo");
prod.setValor("Valor");
prod.setDescripcion("Descripcion");
prod.setID(1);
prod = ProductoLocalServiceUtil.addProducto(prod);
I think is all right, but when i execute my code this error apears.
It might be an error creating my Service Builder, but i thin is all right, the error apears in my class ProductoLocalServiceUtil, doing method createProducto();
My codeThis code is in module ServiceBuilder in my package com.serviceBuilder.service)
public static com.serviceBuilder.model.Producto createProducto(int ID) {
return getService().createProducto(ID); ("This line sends my to another method")
}
Another method:
public static ProductoLocalService getService() {
return _serviceTracker.getService();
}
In the lasth method i get the error in return, i think is not working properly and i don´t know why this error apears.
If you know how to solve it please help me and the comunity.
Thanks a lot, Best Regards.
I,ve been searching on internet to do the insert method in my personal portlet that is in another package, i do all the dependencies and imports, and it really works, but when I run de project and execute my method i had an error like this:
(" java.lang.ClassCastException: com.sun.proxy.$Proxy470 cannot be cast to com.serviceBuilder.service.ProductoLocalService")
My codeThis code is in my personal porlet in module DatosPersonales)
Producto prod = ProductoLocalServiceUtil.createProducto(0); ("The error apears in this line")
prod.setCodigo("Codigo");
prod.setValor("Valor");
prod.setDescripcion("Descripcion");
prod.setID(1);
prod = ProductoLocalServiceUtil.addProducto(prod);
I think is all right, but when i execute my code this error apears.
It might be an error creating my Service Builder, but i thin is all right, the error apears in my class ProductoLocalServiceUtil, doing method createProducto();
My codeThis code is in module ServiceBuilder in my package com.serviceBuilder.service)
public static com.serviceBuilder.model.Producto createProducto(int ID) {
return getService().createProducto(ID); ("This line sends my to another method")
}
Another method:
public static ProductoLocalService getService() {
return _serviceTracker.getService();
}
In the lasth method i get the error in return, i think is not working properly and i don´t know why this error apears.
If you know how to solve it please help me and the comunity.
Thanks a lot, Best Regards.
I also met such error before but I can't recall what is exactly going on.
You can see following sample to find what is wrong with your code:
https://github.com/liferay/liferay-blade-samples/tree/master/liferay-workspace/modules
blade.servicebuilder.api
blade.servicebuilder.svc
blade.servicebuilder.web
And also , you could upload your project and we can try to reproduce it.
Regards.
You can see following sample to find what is wrong with your code:
https://github.com/liferay/liferay-blade-samples/tree/master/liferay-workspace/modules
blade.servicebuilder.api
blade.servicebuilder.svc
blade.servicebuilder.web
And also , you could upload your project and we can try to reproduce it.
Regards.
Daniel Fernandez,修改在7 年前。
RE: Error cast using Service Builder
Junior Member 帖子: 29 加入日期: 17-3-29 最近的帖子
I've already watch this link before and it really don't work properly.
My error is been located in this method:
public static ProductoLocalService getService() {
return _serviceTracker.getService();
}
In fact, this method is called by another method:
public static com.serviceBuilder.model.Producto createProducto(int ID) {
return getService().createProducto(ID);
}
When i execute my code, the error apears because Eclipse cannot cast class ProductoLocalServiceUtil to ProductoLocalService, i don't know why.
When method strarts i cast ("Producto prod = ProductoLocalServiceUtil.createProducto();") I cast producto to ProductoLocalServiceUtil.
I think ServiceBuilder is prepared to cast those classes, because we need that those clases were be able to talk to each other.
What i need to do is insert these values to liferay data base with service builder. i think i'm doing properly if i'm doing in the wrong way please let me know.
Thank for you early reply Andy Wu.
My error is been located in this method:
public static ProductoLocalService getService() {
return _serviceTracker.getService();
}
In fact, this method is called by another method:
public static com.serviceBuilder.model.Producto createProducto(int ID) {
return getService().createProducto(ID);
}
When i execute my code, the error apears because Eclipse cannot cast class ProductoLocalServiceUtil to ProductoLocalService, i don't know why.
When method strarts i cast ("Producto prod = ProductoLocalServiceUtil.createProducto();") I cast producto to ProductoLocalServiceUtil.
I think ServiceBuilder is prepared to cast those classes, because we need that those clases were be able to talk to each other.
What i need to do is insert these values to liferay data base with service builder. i think i'm doing properly if i'm doing in the wrong way please let me know.
Thank for you early reply Andy Wu.
Daniel Fernandez,修改在7 年前。
RE: Error cast using Service Builder
Junior Member 帖子: 29 加入日期: 17-3-29 最近的帖子Andy Wu:
I also met such error before but I can't recall what is exactly going on.
You can see following sample to find what is wrong with your code:
https://github.com/liferay/liferay-blade-samples/tree/master/liferay-workspace/modules
blade.servicebuilder.api
blade.servicebuilder.svc
blade.servicebuilder.web
And also , you could upload your project and we can try to reproduce it.
Regards.
I've already watch this link before and it really don't work properly.
My error is been located in this method:
public static ProductoLocalService getService() {
return _serviceTracker.getService();
}
When i execute my code, the error apears because Eclipse cannot cast class ProductoLocalServiceUtil to ProductoLocalService, i don't know why.
When method strarts i cast ("Producto prod = ProductoLocalServiceUtil.createProducto();") I cast producto to ProductoLocalServiceUtil.
I think ServiceBuilder is prepared to cast those classes, because we need that those clases were be able to talk to each other.
What i need to do is insert these values to liferay data base with service builder. i think i'm doing properly if i'm doing in the wrong way please let me know.
Thank for you early reply Andy Wu.
David H Nebinger,修改在7 年前。
RE: Error cast using Service Builder
Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
Check out my response in your original post: https://web.liferay.com/community/forums/-/message_boards/message/88812356
Come meet me at the 2017 LSNA!
Come meet me at the 2017 LSNA!