You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jay Bowers <ja...@multicom.co.uk> on 2014/03/28 17:03:52 UTC

Package private interface loading problem

Hello,

Thought I'd post this here in case anyone else has the same problem.

I was modifying a fairly simple tapestry app and adding a scheduled 
service with a PeriodicExecutor, the service did some database work that 
was not being committed and there was no exception in the logs!

When I investigated I found that an exception was being thrown but never 
reported, basically I had an interface that was package private and that 
was causing an exception that was never getting reported.

I've made an example project that you can see 
git@bitbucket.org:jaybowers/tapestry-class-loading-issue.git and here is 
the exception (that I had to get by stepping through the app):

[DEBUG] AppModule.SomeOtherPojo Invoking constructor public 
example.tapestry.other.SomeOtherPojoImpl() (for service 'SomeOtherPojo')
[INFO] other.SomeOtherPojoImpl Let's create a bang...
[DEBUG] AppModule.SomeOtherPojo BEGIN Analyzing 
example.tapestry.other.SomeOtherPojoImpl$1
java.lang.IllegalAccessError: class 
example.tapestry.other.SomeOtherPojoImpl$1 cannot access its 
superinterface example.tapestry.other.Bang
     at java.lang.ClassLoader.defineClass1(Native Method)
     at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
     at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
     at 
org.apache.tapestry5.internal.plastic.PlasticClassLoader.defineClassWithBytecode(PlasticClassLoader.java:52)
     at 
org.apache.tapestry5.ioc.internal.AbstractReloadableObjectCreator.doClassLoad(AbstractReloadableObjectCreator.java:268)
     at 
org.apache.tapestry5.ioc.internal.AbstractReloadableObjectCreator.loadAndTransformClass(AbstractReloadableObjectCreator.java:195)
     at 
org.apache.tapestry5.internal.plastic.PlasticClassLoader.loadClass(PlasticClassLoader.java:38)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
     at 
example.tapestry.other.SomeOtherPojoImpl.dontCallMe(SomeOtherPojoImpl.java:14)
     at $SomeOtherPojo_1197326292a3.dontCallMe(Unknown Source)
     at $SomeOtherPojo_11973262929e.dontCallMe(Unknown Source)
     at example.tapestry.services.AppModule$1.run(AppModule.java:50)
     at 
org.apache.tapestry5.ioc.internal.services.cron.PeriodicExecutorImpl$Job.invoke(PeriodicExecutorImpl.java:178)
     at 
org.apache.tapestry5.ioc.internal.services.cron.PeriodicExecutorImpl$Job.invoke(PeriodicExecutorImpl.java:48)
     at 
org.apache.tapestry5.ioc.internal.services.ParallelExecutorImpl$1.call(ParallelExecutorImpl.java:58)
     at java.util.concurrent.FutureTask.run(FutureTask.java:262)
     at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
     at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
     at java.lang.Thread.run(Thread.java:744)

I can get round this by making the interface SomeOtherPojo public but 
its not ideal.

I've also included a link on the index page of the app to create the 
exception without the scheduler.

HTH,

Jay

-- 
Multicom Products Limited is a company registered in England and Wales (Registered Number 2447353 Wales) with its registered office at 33 Victoria Street, Bristol, BS1 6AS.

This email is confidential to the addressee and may contain privileged information.  If you have reason to believe that you are not the intended recipient of this communication, please delete it from your system and contact the sender immediately. You are not permitted to use or copy this email or its attachments nor may you disclose the same to any third party.  Unauthorised use or disclosure of this email is prohibited and may be unlawful.

We reserve the right to intercept and read emails sent or received by our employees. This is to ensure compliance with our internal policies and to protect our business. If you do not wish for your communications to be subjected to such scrutiny, you should not communicate via this email system.

We endeavour to exclude viruses and other malware from our data but it is the responsibility of the recipient to scan all emails and attachments for viruses before opening them. We accept no liability for any damage caused by any virus transmitted by this email.

Email may not be completely secure or error free, can be intercepted or corrupted and may arrive late or not at all. Anyone who communicates with us by email accepts these risks.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Package private interface loading problem

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 31 Mar 2014 05:05:29 -0300, Jay Bowers <ja...@multicom.co.uk> wrote:

> Creating this instance should be (as far as I am aware) independent of
> the Tapestry IOC framework, although obviously its not because of
> classloading.

That's not correct. SomeOtherPojoImpl is instantiated successfully. What  
fails is the creation of the service proxy, as a superinterface of the  
service interface is not visible for Tapestry-IoC code nor the created  
proxy class, which should implement the service interface, which is partly  
defined by a package-private interface.

You're right about Tapestry-IoC not doing classloading transormations.  
Tapestry-core, the web framework, does classloading that, but Tapestry-IoC  
doesn't.

> Maybe this is a known limitation of the tapestry framework but I could
> not find reference to it in the documentation.

Yep, this is a known limitation.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Package private interface loading problem

Posted by Jay Bowers <ja...@multicom.co.uk>.
On 28/03/14 21:16, Thiago H de Paula Figueiredo wrote:
> On Fri, 28 Mar 2014 13:03:52 -0300, Jay Bowers <ja...@multicom.co.uk> 
> wrote:
>
>> When I investigated I found that an exception was being thrown but 
>> never reported, basically I had an interface that was package private 
>> and that was causing an exception that was never getting reported.
>
> In this case, it seems your public interface is a subinterface of a 
> package private one, so I'd guess your superinteface isn't that 
> private to begin with. Tapestry-IoC creates proxies for services 
> defined on interfaces so, so you'll run on problems when the service 
> interface has a superinterface the proxy, which isn't created in the 
> same package as the service interface, is created.

Here is the interface that was causing the problem:

/* package private - makes things go bang */ interface Bang
{
     void whatEver();
}

And here is where the Bang interface is being used (in the same package 
that its declared) that causes the previous exception:

public class SomeOtherPojoImpl implements SomeOtherPojo
{
     private static Logger logger = Logger.getLogger( 
SomeOtherPojoImpl.class );
     public void dontCallMe()
     {
         logger.info( "Let's create a bang..." );
*Bang bang = new Bang()*
         {
             public void whatEver()
             {
                 // TODO Auto-generated method stub
             }
         };
         logger.info( "You will never see me!" );
     }
}

Creating this instance should be (as far as I am aware) independent of 
the Tapestry IOC framework, although obviously its not because of 
classloading.

Maybe this is a known limitation of the tapestry framework but I could 
not find reference to it in the documentation.

Jay


-- 
Multicom Products Limited is a company registered in England and Wales (Registered Number 2447353 Wales) with its registered office at 33 Victoria Street, Bristol, BS1 6AS.

This email is confidential to the addressee and may contain privileged information.  If you have reason to believe that you are not the intended recipient of this communication, please delete it from your system and contact the sender immediately. You are not permitted to use or copy this email or its attachments nor may you disclose the same to any third party.  Unauthorised use or disclosure of this email is prohibited and may be unlawful.

We reserve the right to intercept and read emails sent or received by our employees. This is to ensure compliance with our internal policies and to protect our business. If you do not wish for your communications to be subjected to such scrutiny, you should not communicate via this email system.

We endeavour to exclude viruses and other malware from our data but it is the responsibility of the recipient to scan all emails and attachments for viruses before opening them. We accept no liability for any damage caused by any virus transmitted by this email.

Email may not be completely secure or error free, can be intercepted or corrupted and may arrive late or not at all. Anyone who communicates with us by email accepts these risks.

Re: Package private interface loading problem

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 28 Mar 2014 13:03:52 -0300, Jay Bowers <ja...@multicom.co.uk> wrote:

> Hello,

Hi!

> When I investigated I found that an exception was being thrown but never  
> reported, basically I had an interface that was package private and that  
> was causing an exception that was never getting reported.

In this case, it seems your public interface is a subinterface of a  
package private one, so I'd guess your superinteface isn't that private to  
begin with. Tapestry-IoC creates proxies for services defined on  
interfaces so, so you'll run on problems when the service interface has a  
superinterface the proxy, which isn't created in the same package as the  
service interface, is created.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org