-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: JPA binding classes are not found when added at runtime
PostPosted: Wed Jan 05, 2011 10:17 am 
Newbie

Joined: Wed Jan 05, 2011 9:59 am
Posts: 1
Hi,

I have my jpa binding classes in a jar file, which acts as a plugin for my application. I add this jar at runtime using a custom URL class loader. But I am getting exception that my tables are not mapped, when i try to use them.

Here is the exception :-

java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: data_source_tab is not mapped [select d from data_source_tab d where d.url = ?1]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:601)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:96)
... 6 more
Caused by: org.hibernate.hql.ast.QuerySyntaxException: data_source_tab is not mapped [select d from data_source_tab d where d.url = ?1]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:181)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:94)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:316)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3228)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3112)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:720)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:571)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:288)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:231)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)

If i directly add the jar in my build path, then it is working fine and it is creating the required tables. But the problem is, I get the hold on jar file at runtime.
Please help me with this.

Here is my classloader class :-

Code:
public class CustomURLClassLoader extends URLClassLoader
{
    private static CustomURLClassLoader URLCLASSLOADER = null;

    public CustomURLClassLoader(ClassLoader parent)
    {
        super(new URL[0], parent);
        this.addAllJarsToClassPath();
    }

    /**
     * This method adds all the jars in the specified dirs and sub dirs
     * recursively to the classpath. NOTE : Even though we use the term
     * 'classpath' technically URLs are added to a list of URLs to search for
     * classes and resources.
     *
     * @param dirContainingJars
     *            The directory containing jars
     * @throws Exception
     */
    public void addJarsToClassPath(File dirContainingJars) throws Exception
    {
        super.addURL("URL of jar file");
    }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.