3

I have a .war application module, that can be successfully deployed without any exotic changes and server tuning. However, i was unable to deploy this app to GF 3.1.2: server throws following exception:

java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.NoSuchFieldError: theInstance

What i am doing wrong? Has anyone suggest me something? Is there any additional settings that i should perform to deploy .war module successfully?

Thanks a lot in advance.

UPD

More precise log entry:

javax.xml.bind.JAXBException: Provider com.sun.xml.bind.ContextFactory_1_0_1 could not be instantiated: javax.xml.bind.JAXBException - with linked exception: [java.lang.NoSuchFieldError: theInstance]
- with linked exception: [javax.xml.bind.JAXBException - with linked exception: [java.lang.NoSuchFieldError: theInstance]]

johnny-b-goode
  • 3,792
  • 12
  • 45
  • 68
  • Perhaps you are creating a library conflict. Which libraries are you deploying as part of your war? – Gimby Dec 19 '12 at 10:37
  • If you talking about project's dependencies, there are a lot of them: JDBC stuff, logging api, JAXB, PDF, JSF, AXIS, COMMONS and other stuff. Do you think that it may be some kind of conflict between project's and server's provided dependencies? How to check this out? – johnny-b-goode Dec 19 '12 at 10:43
  • 1
    Are you packaging a different version of JAXB then what glassfish use ? – Aviram Segal Dec 24 '12 at 12:11

4 Answers4

3

Sounds like a class loader issue.

You need your WEB-INF/lib JAXB jars used ahead of the GlassFish JAXB jars. Or change your app to use the versions GlassFish 3.1.2 is bundled with.

Servlet spec says that web applications should use the local class loader before delegating to the parent. I think GlassFish delegates to the the parent class loader for web applications by default. Use <class-loader delegate="false"/> in web.xml or glassfish-web.xml.

Note there may be other ways to modify the class loader in GlassFish if this does not work.

This type of issue is common during deployment to many application servers. I've used GlassFish daily for the last 5+ years and see this every so often. Recently saw a similar issue when deploying to JBoss on CloudBees, and modified a deployment descriptor accordingly.

Googling "glassfish prefer web-inf/lib jars".

Response To psed comment below EJB interfaces must reside in the class path hierarchy shared by the Web module and EJB module. If you have an EJB interface jar in WEB-INF/lib and another copy of the EJB interface jar on the EJB module classpath, you would get a ClassCastException when injecting/locating the EJB in your web application. I assume WebServices have the same issue. Sharing the EJB interface jar though an EAR should resolve this issue though. Note there may be other issues I am unaware of

Community
  • 1
  • 1
Matthew Petty
  • 652
  • 5
  • 7
  • BTW, i have found, that setting delegate="false" to classloader option may be dangerous for a multimodule application but i dont realize why. I have already tested my app in chain with client .net app and everything works fine (including web services). Could you please explain more precisely, because i have found following record on Oracle GlassFish Docs page: -"It's safe to set this to false only for a web module that does not interact with any other modules." Thanks. – johnny-b-goode Dec 31 '12 at 09:10
  • However, i must found the way to deploy my extremely old web app to glassfish without affecting other apps that may be also deployed to GlassFish (unable to use Override Standarts Mechanism even for domain). – johnny-b-goode Dec 31 '12 at 09:12
1

You should not bundle JAXB jars with your application - Glassfish already has them, and it seems this is causing a conflict (incidentally, I've been digging through JAXB code recently, and theInstance is part of a static class defined by MarshallerImpl)

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
0

You should place your all jar files to your runtime server lib...

Kanagaraj M
  • 956
  • 8
  • 18
0

This instruction is for GlassFish 3.1.2 The issue is runtime classes from JAXB 2.2.5 are not backward compilable with JAXB 1 code. This issue was fixed with JAXB 2.2.6, however, it's not in latest GlassFish release. So, either you wait until the next GlassFish upgrade or you do it manually.

Here is how i did, I removed the 2 bundle files from GlassFish module

C:\glassfish3\glassfish\modules\jaxb-osgi.jar
C:\glassfish3\glassfish\modules\endorsed\jaxb-api-osgi.jar

Clear the osgi-cache by deleting all the subfolder in

C:\glassfish3\glassfish\domains\domain1\osgi-cache

Download JAXB 2.2.6 from ORACLE JAXB

Extract the zip file to a temp location [C:\Java\jaxb-ri-2.2.6\jaxb-ri-2.2.6\osgi]

copy C:\Java\jaxb-ri-2.2.6\jaxb-ri-2.2.6\osgi\jaxb-osgi.jar to C:\glassfish3\glassfish\modules\

copy C:\Java\jaxb-ri-2.2.6\jaxb-ri-2.2.6\osgi\jaxb-api-osgi.jar to C:\glassfish3\glassfish\modules\endorsed\

restart your server ... i hope this will help. Good Luck

xlecoustillier
  • 16,183
  • 14
  • 60
  • 85