-->
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.  [ 5 posts ] 
Author Message
 Post subject: .CGLIBLazyInitializer can not access a public member
PostPosted: Tue Jan 09, 2007 8:18 am 
Newbie

Joined: Thu Sep 09, 2004 1:05 pm
Posts: 4
Hi,


I am trying to migrate from hibernate 3.1.3 to 3.2.1 ga.

I changed all the return types of COUNT to Long (as specified in the migration document) but the other modifications does not seems to concern me.

However, when I run my unit tests, I get this error which I cannot understand (was working fine with 2.1.7c and after 3.1.3, this is an old piece of code that has not changed for years).


I have put as much information as I can, hope it helps you pin point the problem.

Thanks,
Daniel


Hibernate version: 3.2.1.ga

Mapping documents:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class table="cenacodem" name="com.rf1.data.sage.NarrativeCode" schema="scheme">
<composite-id class="com.rf1.data.sage.NarrativeCodeId" name="id">
<key-property type="com.rf1.data.types.TrimmedString" column="kind" length="3" name="kind"/>
<key-property type="com.rf1.data.types.TrimmedString" column="code" length="10" name="code"/>
</composite-id>
<discriminator type="string" force="true" column="kind" length="3" not-null="true" insert="false"/>
<property name="description" not-null="true" length="60" type="com.rf1.data.types.TrimmedString" column="description"/>
<subclass name="com.rf1.data.sage.Event" discriminator-value="019"/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

NarrativeCodeId id = Event.newId();
id.setCode(parameters.getCode());

Event event = (Event) session.load(Event.class, id, LockMode.NONE);
event.setDescription(description);

//I get the same error if I try to access getDescription() although eclipse seems to be able to retrieve it correctly in the debugger view!?!?!?!

Full stack trace of any exception that occurs:

java.lang.IllegalAccessException-->Class org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer can not access a member of class com.rf1.data.sage.NarrativeCode with modifiers "public"
] [net.sf.cglib.proxy.UndeclaredThrowableException: java.lang.IllegalAccessException-->Class org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer can not access a member of class com.rf1.data.sage.NarrativeCode
with modifiers "public"
at com.rf1.data.sage.Event$$EnhancerByCGLIB$$37bbbb49.setDescription(<generated>)
at com.rf1.ws.sage.event.SageEventSoapBindingImpl.addOrUpdateEvent(SageEventSoapBindingImpl.java:169)
at com.rf1.ws.sage.event.OperationAddOrUpdateEventTest.testAddOrUpdateEvent01(OperationAddOrUpdateEventTest.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
Caused by: java.lang.IllegalAccessException: Class org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer can not access a member of class com.rf1.data.sage.NarrativeCode with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
at java.lang.reflect.Method.invoke(Method.java:317)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:147)
... 18 more


Name and version of the database you are using: PostgreSQL 8.0.4

The generated SQL (show_sql=true):

Hibernate: select event0_.kind as kind4_0_, event0_.code as code4_0_, event0_.description as descript3_4_0_ from scheme.cenacodem event0_ where event0_.kind=? and event0_.code=? and event0_.kind='019'

Debug level Hibernate log excerpt:

2750 [main] DEBUG - instantiated session factory
2750 [main] DEBUG - Checking 0 named HQL queries
2750 [main] DEBUG - Checking 0 named SQL queries
2953 [main] DEBUG - opened session at timestamp: 11683446140
2969 [main] DEBUG - begin
2969 [main] DEBUG - opening JDBC connection
2969 [main] DEBUG - total checked-out connections: 0
2969 [main] DEBUG - using pooled JDBC connection, pool size: 0
2969 [main] DEBUG - current autocommit status: false
2969 [main] DEBUG - after transaction begin
3016 [main] DEBUG - unable to locate HQL query plan in cache; generating (Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?))
3094 [main] DEBUG - parse() - HQL: Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?)
3125 [main] DEBUG - --- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| +-[FROM] 'from'
| | \-[RANGE] 'RANGE'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[DOT] '.'
| | | | | | +-[IDENT] 'com'
| | | | | | \-[IDENT] 'rf1'
| | | | | \-[IDENT] 'data'
| | | | \-[IDENT] 'sage'
| | | \-[IDENT] 'Event'
| | \-[ALIAS] 'b'
| \-[SELECT] 'Select'
| \-[COUNT] 'count'
| \-[DOT] '.'
| +-[IDENT] 'b'
| \-[IDENT] 'description'
\-[WHERE] 'where'
\-[EQ] '='
+-[DOT] '.'
| +-[DOT] '.'
| | +-[IDENT] 'b'
| | \-[IDENT] 'id'
| \-[IDENT] 'code'
\-[PARAM] '?'

3125 [main] DEBUG - throwQueryException() : no errors
3187 [main] DEBUG - select << begin [level=1, statement=select]
3203 [main] DEBUG - FromClause{level=1} : com.rf1.data.sage.Event (b) -> event0_
3203 [main] DEBUG - Resolved : b -> (event0_.kind, event0_.code)
3203 [main] DEBUG - handling property dereference [com.rf1.data.sage.Event (b) -> description (class)]
3203 [main] DEBUG - getDataType() : description -> org.hibernate.type.CustomType@2a2cc
3203 [main] DEBUG - Resolved : b.description -> event0_.description
3219 [main] DEBUG - Resolved : b -> (event0_.kind, event0_.code)
3219 [main] DEBUG - handling property dereference [com.rf1.data.sage.Event (b) -> id (class)]
3219 [main] DEBUG - getDataType() : id -> org.hibernate.type.ComponentType@6c2896
3219 [main] DEBUG - Unresolved property path is now 'id.code'
3219 [main] DEBUG - Resolved : b.id -> event0_.code
3219 [main] DEBUG - getDataType() : id.code -> org.hibernate.type.CustomType@dccfab
3219 [main] DEBUG - Resolved : b.id.code -> event0_.code
3219 [main] DEBUG - select : finishing up [level=1, statement=select]
3219 [main] DEBUG - processQuery() : ( SELECT ( {select clause} ( count ( event0_.description (event0_.kind, event0_.code) description ) ) ) ( FromClause{level=1} scheme.cenacodem event0_ ) ( where ( = ( event0_.code ( event0_.code (event0_.kind, event0_.code) id ) code ) ? ) ) )
3234 [main] DEBUG - Using FROM fragment [scheme.cenacodem event0_]
3234 [main] DEBUG - Using WHERE fragment [event0_.kind='019']
3234 [main] DEBUG - select >> end [level=1, statement=select]
3234 [main] DEBUG - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (scheme.cenacodem)
+-[SELECT_CLAUSE] SelectClause: '{select clause}'
| +-[COUNT] CountNode: 'count'
| | \-[DOT] DotNode: 'event0_.description' {propertyName=description,dereferenceType=4,propertyPath=description,path=b.description,tableAlias=event0_,className=com.rf1.data.sage.Event,classAlias=b}
| | +-[ALIAS_REF] IdentNode: '(event0_.kind, event0_.code)' {alias=b, className=com.rf1.data.sage.Event, tableAlias=event0_}
| | \-[IDENT] IdentNode: 'description' {originalText=description}
| \-[SELECT_COLUMNS] SqlNode: ' as col_0_0_'
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[b], fromElementByTableAlias=[event0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'scheme.cenacodem event0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=b,role=null,tableName=scheme.cenacodem,tableAlias=event0_,origin=null,colums={,className=com.rf1.data.sage.Event}}
\-[WHERE] SqlNode: 'where'
+-[FILTERS] SqlNode: '{filter conditions}'
| \-[SQL_TOKEN] SqlFragment: 'event0_.kind='019''
\-[EQ] BinaryLogicOperatorNode: '='
+-[DOT] DotNode: 'event0_.code' {propertyName=code,dereferenceType=4,propertyPath=id.code,path=b.id.code,tableAlias=event0_,className=com.rf1.data.sage.Event,classAlias=b}
| +-[DOT] DotNode: 'event0_.code' {propertyName=code,dereferenceType=2,propertyPath=id.code,path=b.id,tableAlias=event0_,className=com.rf1.data.sage.Event,classAlias=b}
| | +-[ALIAS_REF] IdentNode: '(event0_.kind, event0_.code)' {alias=b, className=com.rf1.data.sage.Event, tableAlias=event0_}
| | \-[IDENT] IdentNode: 'id' {originalText=id}
| \-[IDENT] IdentNode: 'code' {originalText=code}
\-[PARAM] ParameterNode: '?' {ordinal=0, expectedType=org.hibernate.type.CustomType@dccfab}

3234 [main] DEBUG - throwQueryException() : no errors
3250 [main] DEBUG - HQL: Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?)
3250 [main] DEBUG - SQL: select count(event0_.description) as col_0_0_ from scheme.cenacodem event0_ where event0_.kind='019' and event0_.code=?
3250 [main] DEBUG - throwQueryException() : no errors
3266 [main] DEBUG - HQL param location recognition took 0 mills (Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?))
3281 [main] DEBUG - located HQL query plan in cache (Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?))
3281 [main] DEBUG - find: Select count(b.description) from com.rf1.data.sage.Event as b where (b.id.code = ?)
3281 [main] DEBUG - parameters: [27/11/2003]
3281 [main] DEBUG - named parameters: {}
3281 [main] DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
3281 [main] DEBUG - select count(event0_.description) as col_0_0_ from scheme.cenacodem event0_ where event0_.kind='019' and event0_.code=?
3281 [main] DEBUG - preparing statement
3297 [main] DEBUG - binding '27/11/2003' to parameter: 1
3328 [main] DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
3328 [main] DEBUG - processing result set
3328 [main] DEBUG - result set row: 0
3328 [main] DEBUG - result row:
3328 [main] DEBUG - returning '1' as column: col_0_0_
3328 [main] DEBUG - done processing result set (1 rows)
3328 [main] DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
3328 [main] DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
3328 [main] DEBUG - closing statement
3328 [main] DEBUG - initializing non-lazy collections
3344 [main] DEBUG - loading entity: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3344 [main] DEBUG - creating new proxy for entity
3359 [main] DEBUG - initializing proxy: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - attempting to resolve: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - object not resolved in any cache: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - Fetching entity: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - loading entity: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
3359 [main] DEBUG - select event0_.kind as kind4_0_, event0_.code as code4_0_, event0_.description as descript3_4_0_ from scheme.cenacodem event0_ where event0_.kind=? and event0_.code=? and event0_.kind='019'
3359 [main] DEBUG - preparing statement
3359 [main] DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
3359 [main] DEBUG - processing result set
3359 [main] DEBUG - result set row: 0
3359 [main] DEBUG - result row: EntityKey[com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - Initializing object from ResultSet: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3359 [main] DEBUG - Hydrating entity: [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3375 [main] DEBUG - done processing result set (1 rows)
3375 [main] DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
3375 [main] DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
3375 [main] DEBUG - closing statement
3375 [main] DEBUG - total objects hydrated: 1
3375 [main] DEBUG - resolving associations for [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3375 [main] DEBUG - done materializing entity [com.rf1.data.sage.Event#component[kind,code]{code=27/11/2003, kind=019}]
3375 [main] DEBUG - initializing non-lazy collections
3375 [main] DEBUG - done entity load
3453 [main] DEBUG - rollback
3453 [main] DEBUG - rolled back JDBC Connection
3453 [main] DEBUG - after transaction completion
3453 [main] DEBUG - aggressively releasing JDBC connection
3453 [main] DEBUG - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
3453 [main] DEBUG - returning connection to pool, pool size: 1
3453 [main] DEBUG - after transaction completion
3453 [main] DEBUG - disconnecting session
3453 [main] DEBUG - connection already null in cleanup : no action
3453 [main] DEBUG - closing session
3453 [main] DEBUG - connection already null in cleanup : no action


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 1:32 pm 
Regular
Regular

Joined: Wed Dec 07, 2005 4:19 pm
Posts: 53
Are you sure there are not some other code changes, either in the class itself, it's superclasses and/or the com.rf1.data.types.TrimmedString?

Is the class itself (still) 'public'?

I would try writing some code using introspection, in a hope I could get it to fail in a small test, something like
Code:
            Class cls = obj.getClass();
             Field[] flds = cls.getDeclaredFields();
             for (Field f : flds) {
                 if (!(Modifier.isStatic(f.getModifiers()) || f.getType().isPrimitive())) {
                     try {
                         // Supress Java language access controls (private, protected)
                         if (!Modifier.isPublic(f.getModifiers()) ||
                             !Modifier.isPublic(cls.getModifiers())) {
                             log.error("Inaccessible memeber " + f);
                             // you could call: f.setAccessible(true);
                         }
                         // Note that declared type may be lesser than actual, i.e.
                         // member is declared as Set, but it is a PersistentSet
                         Object member = f.get(obj);
                         // ...

                      } catch (IllegalAccessException t) {
                         log.error("Failed to access " + cls.getName() + "." + f.getName());
                     }
                 }
             }

Of course, you can try the same for methods...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 1:54 pm 
Newbie

Joined: Thu Sep 09, 2004 1:05 pm
Posts: 4
Hi,

Using CVS I can assure you the code logic has not changed for a long time. Of course small things around do change over time.

However, everything works fine in the moment with hibernate 3.1.3 (and we have cruise control running all tests on each modifications).

Here is exactly what I did:

Change the hibernate lib to 3.2.1 ga (was 3.1.3)
Change the ehcache lib to 1.2.3 (was 1.1)
Change the antlr to 2.7.6 (was 2.7.6rc1)

Everywhere I was doing a select count..., I cast the return type in a Long (was Integer)
I don't use SUM of AVG so I didn't have to change any.

Nothing else.

Now when I run my unit tests I get the error I reported and cannot understand the problem.

Maybe there is something else I need to modify to migrate?

Thanks,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 2:45 pm 
Newbie

Joined: Thu Sep 09, 2004 1:05 pm
Posts: 4
ok I found the problem!

My class NarrativeCode was set with default modifier (package), as I did not want to use it directly but instead force the use of subclasses. When I put it public it works fine.

Something changed in hibernate as it has always been like that. However I do not mind changing it to public so problem solved for me!


Top
 Profile  
 
 Post subject: Problem has some dire consequences.
PostPosted: Fri Feb 29, 2008 9:55 am 
Newbie

Joined: Mon Oct 23, 2006 4:14 am
Posts: 2
I apologize for bringing this theme up more than a year later.
Recently our project also migrated from Hibernate 3.1 (3.1.3) to Hibernate 3.2 (3.2.5ga).

We fell upon the following case:
Code:
public abstract class A {
  public abstract void someMethod();
}

/*package protected*/ abstract class B extends A {
  public void someMethod() {
    // Do stuff.
  }
}

public class C_Entity extends B {
  // Entity stuff. Method someMethod not overridden!
}

If we try to access method someMethod() on a newly loaded C_Entity we get the same UndeclaredThrowable->IllegalAccessException.

This works CORRECTLY in Hibernate 3.1.3.
I have prepared a test-case, but I can not attach it here.


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

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.