Cannot generate a class for a bean

66 views
Skip to first unread message

Victor M.

unread,
Apr 14, 2015, 1:48:07 PM4/14/15
to empir...@googlegroups.com
Hello there,

I am trying to load instances some instances from the database but am running into this problem. I looked at the InstanceGenerator class and it seems to try to look for classes like ".*impl.*Impl" (in my case, "govRep.model.userManagement.impl.UserImpl"), but such class does not exist (the only one that exists is "govRep.model.userManagement.User"). Is there anything I might be overlooking here?

Cheers,
Victor M.

trace:

Message: com.clarkparsia.empire.annotation.InvalidRdfException: Cannot generate a class for a bean
java.lang.RuntimeException: com.clarkparsia.empire.annotation.InvalidRdfException: Cannot generate a class for a bean
at com.clarkparsia.empire.annotation.runtime.Proxy.value(Proxy.java:75)
at com.clarkparsia.empire.annotation.runtime.ProxyAwareList.unwrap(ProxyAwareList.java:89)
at com.clarkparsia.empire.annotation.runtime.ProxyAwareList.get(ProxyAwareList.java:77)
at java.util.AbstractList$Itr.next(AbstractList.java:358)
at java.util.AbstractCollection.toString(AbstractCollection.java:457)
at java.lang.String.valueOf(String.java:2847)
at java.lang.StringBuilder.append(StringBuilder.java:128)
at org.apache.logging.log4j.spi.AbstractLogger.exitMsg(AbstractLogger.java:386)
at org.apache.logging.log4j.spi.AbstractLogger.exit(AbstractLogger.java:377)
at org.apache.logging.log4j.spi.AbstractLogger.exit(AbstractLogger.java:364)
at govRep.dbController.DatabaseController.loadObjects(DatabaseController.java:313)
at govRep.dbController.DatabaseController.getSpecificUser(DatabaseController.java:402)
at govRep.model.userManagement.Authentication.authenticate(Authentication.java:127)
at govRep.model.userManagement.Authentication.login(Authentication.java:263)
at govRep.viewModel.MainBean.authentication(MainBean.java:474)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.el.parser.AstValue.invoke(AstValue.java:289)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:147)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:813)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at govRep.NoCacheFilter.doFilter(NoCacheFilter.java:40)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.clarkparsia.empire.annotation.InvalidRdfException: Cannot generate a class for a bean
at com.clarkparsia.empire.annotation.RdfGenerator.determineClass(RdfGenerator.java:366)
at com.clarkparsia.empire.annotation.RdfGenerator.fromRdf(RdfGenerator.java:297)
at com.clarkparsia.empire.annotation.runtime.Proxy.value(Proxy.java:72)
... 69 more
Caused by: java.lang.Exception: Previously created class cannot be loaded.
at com.clarkparsia.empire.codegen.InstanceGenerator.generateInstanceClass(InstanceGenerator.java:118)
at com.clarkparsia.empire.annotation.RdfGenerator.determineClass(RdfGenerator.java:362)
... 71 more
Caused by: java.lang.ClassNotFoundException: govRep.model.userManagement.impl.UserImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.clarkparsia.empire.util.BeanReflectUtil.loadClass(BeanReflectUtil.java:95)
at com.clarkparsia.empire.codegen.InstanceGenerator.generateInstanceClass(InstanceGenerator.java:112)
... 72 more

Michael Grove

unread,
Apr 14, 2015, 1:52:12 PM4/14/15
to empir...@googlegroups.com
In some cases, particularly when you don't provide an implementation of your bean interface, Empire will have to generate one for you.  If you have an implementation, that's what you should be loading from Empire.  If you have only an interface, it could be a bug in the instance generation.

Cheers,

Mike

--
You received this message because you are subscribed to the Google Groups "Empire" group.
To unsubscribe from this group and stop receiving emails from it, send an email to empire-rdf+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Victor M.

unread,
Apr 14, 2015, 3:36:09 PM4/14/15
to empir...@googlegroups.com
Hello there,

after fiddling with the code, it seems that the problem could be with inheritance (using one of the provided classes in the example works). The aforementioned User class has the following annotations:

@Namespaces({"sgr", "http://sgr#"})
@RdfsClass("sgr:User")
@Entity
public class User extends DatabaseMappingBasicClass
[...]


Inheriting from a superclass "DatabaseMappingBasicClass" with the following annotations.


@Namespaces({"sgr", "http://sgr#"})
@MappedSuperclass
public abstract class DatabaseMappingBasicClass implements SupportsRdfId
[...]


Is there anything missing/strange in those annotations?


Cheers,
Victor M.

Michael Grove

unread,
Apr 15, 2015, 10:04:16 AM4/15/15
to empir...@googlegroups.com
On Tue, Apr 14, 2015 at 3:36 PM, Victor M. <dark...@gmail.com> wrote:
Hello there,

after fiddling with the code, it seems that the problem could be with inheritance (using one of the provided classes in the example works). The aforementioned User class has the following annotations:

@Namespaces({"sgr", "http://sgr#"})
@RdfsClass("sgr:User")
@Entity
public class User extends DatabaseMappingBasicClass
[...]


Inheriting from a superclass "DatabaseMappingBasicClass" with the following annotations.


@Namespaces({"sgr", "http://sgr#"})
@MappedSuperclass
public abstract class DatabaseMappingBasicClass implements SupportsRdfId
[...]


Is there anything missing/strange in those annotations?

They seem fine, but without a completely, working example that demonstrates the issue you're facing, it's difficult to give any more suggestions.

Cheers,

Mike
 

--

Victor M.

unread,
May 7, 2015, 10:08:55 AM5/7/15
to empir...@googlegroups.com
Hi there,

it seems that my code sometimes deal with actual instances of a specific class and sometimes it deals with the Empire generated *Impl classes. When does the actual transformation from XImpl to X occur and is there any way to force this transformation? The code I have inherited uses a lot of conditionals that depend on class names, so I would like to avoid a workaround by editing the string directly.

Best regards,

Victor M.



On Tuesday, April 14, 2015 at 7:48:07 PM UTC+2, Victor M. wrote:

Michael Grove

unread,
May 7, 2015, 10:23:13 AM5/7/15
to empir...@googlegroups.com
On Thu, May 7, 2015 at 10:08 AM, Victor M. <dark...@gmail.com> wrote:
Hi there,

it seems that my code sometimes deal with actual instances of a specific class and sometimes it deals with the Empire generated *Impl classes. When does the actual transformation from XImpl to X occur and is there any way to force this transformation? The code I have inherited uses a lot of conditionals that depend on class names, so I would like to avoid a workaround by editing the string directly.

Empire will generate an implementation for an interface if that is what is provided when retrieving a bean.  If an instance is provided, Empire wraps that class with an implementation of EmpireGenerated to track information such as the triples used to create the object.

Cheers,

Mike
 

--

Victor M.

unread,
May 7, 2015, 11:09:25 AM5/7/15
to empir...@googlegroups.com
Hi, thanks once again for the response.

The following query is an example of a typical operation done in the code I have here:

String queryString = "SELECT DISTINCT ?result WHERE { ?result rdf:type sgr:BusinessObject. }";

// remove PREFIX declarations since createQuery breaks otherwise.
int index = queryString.indexOf("SELECT DISTINCT");
queryString = queryString.substring( index, queryString.length() );           
           
Query query = em.createQuery( queryString );
query.setHint(RdfQuery.HINT_ENTITY_CLASS, classType);

list = query.getResultList();


Is there any way to provide this interface using a string-based query?

Best regards,
Victor M.

Michael Grove

unread,
May 7, 2015, 11:13:44 AM5/7/15
to empir...@googlegroups.com
On Thu, May 7, 2015 at 11:09 AM, Victor M. <dark...@gmail.com> wrote:
Hi, thanks once again for the response.

The following query is an example of a typical operation done in the code I have here:

String queryString = "SELECT DISTINCT ?result WHERE { ?result rdf:type sgr:BusinessObject. }";

// remove PREFIX declarations since createQuery breaks otherwise.
int index = queryString.indexOf("SELECT DISTINCT");
queryString = queryString.substring( index, queryString.length() );           
           
Query query = em.createQuery( queryString );
query.setHint(RdfQuery.HINT_ENTITY_CLASS, classType);

list = query.getResultList();


Is there any way to provide this interface using a string-based query?

The query results are instantiated by whatever is annotated with @RdfsClass("sgr:BusinessObject")
Reply all
Reply to author
Forward
0 new messages