You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by benerridge <be...@cyberoblivion.com> on 2014/11/11 21:46:45 UTC

Ear Classloading issue

I have an issue where I have 2 wars inside an EAR; both jars have a copy of a
utility jar.
when I do an em.find hibernate returns an instance of a class from the wrong
war's lib folder jar.

So 
In WarA
em.find(classA, id) returns instance of classA from
WarB/WEB-INF/lib/utility.jar
I then immediately get class cast exception: cannot cast classA to classA.

Is this normal?
if so is there a way to resolve this without significantly modifying the ear
packaging?





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Ear-Classloading-issue-tp4672836.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Ear Classloading issue

Posted by benerridge <be...@cyberoblivion.com>.
Yeah that seems to fix the issue. Strange that it works in other containers
though. No matter, simple enough fix. Thanks!



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Ear-Classloading-issue-tp4672836p4672894.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Ear Classloading issue

Posted by Romain Manni-Bucau <rm...@gmail.com>.
think it comes from the fact persistence.xml is shared, can you try
moving it in webapps?


Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau


2014-11-17 19:26 GMT+01:00 benerridge <be...@cyberoblivion.com>:
> I made another GitHub project that demonstrates this behaviour.
>
> https://github.com/cyberoblivion/ear-sso-test.git
>
> Install:
> Tomee Plume should be used as the base app server. Hibernate libs will need
> to be copied into the plume/lib folder.
> All necessary hibernate libs are included in the /lib folder as well as a
> tomee.xml to configure necessary resources.
>
>
> When deployed go to
> localhost:8080/webappA
>
> click on "Set Cookie" button and links will appear to navigate you to
> two other applications. If all goes well you will see the welcome pages of
> the other two apps when you click the links.
> Otherwise the links will direct you back to the current page.
>
> When deployed as separate wars the application works as expected. When
> deployed with ear packaging you will get error:
> Cannot cast com.ciminc.domain.SingleSignOn as com.ciminc.domain.SingleSignOn
>
> Let me know if you have any issues with this and thanks for your help.
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Ear-Classloading-issue-tp4672836p4672892.html
> Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Ear Classloading issue

Posted by benerridge <be...@cyberoblivion.com>.
I made another GitHub project that demonstrates this behaviour.

https://github.com/cyberoblivion/ear-sso-test.git

Install:
Tomee Plume should be used as the base app server. Hibernate libs will need
to be copied into the plume/lib folder.
All necessary hibernate libs are included in the /lib folder as well as a
tomee.xml to configure necessary resources. 


When deployed go to
localhost:8080/webappA

click on "Set Cookie" button and links will appear to navigate you to 
two other applications. If all goes well you will see the welcome pages of
the other two apps when you click the links.
Otherwise the links will direct you back to the current page.

When deployed as separate wars the application works as expected. When
deployed with ear packaging you will get error: 
Cannot cast com.ciminc.domain.SingleSignOn as com.ciminc.domain.SingleSignOn

Let me know if you have any issues with this and thanks for your help.





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Ear-Classloading-issue-tp4672836p4672892.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Ear Classloading issue

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

2014-11-11 21:46 GMT+01:00 benerridge <be...@cyberoblivion.com>:
> I have an issue where I have 2 wars inside an EAR; both jars have a copy of a
> utility jar.
> when I do an em.find hibernate returns an instance of a class from the wrong
> war's lib folder jar.
>
> So
> In WarA
> em.find(classA, id) returns instance of classA from
> WarB/WEB-INF/lib/utility.jar
> I then immediately get class cast exception: cannot cast classA to classA.
>
> Is this normal?

No

> if so is there a way to resolve this without significantly modifying the ear
> packaging?
>
>

Can you share an app showing it? Also maybe check em is the on you
expect (debugging you should be able to see properties of the
persistence unit so adding foo=a and foo=b you should be able to
identify them).

>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Ear-Classloading-issue-tp4672836.html
> Sent from the TomEE Users mailing list archive at Nabble.com.