Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

java.lang.LinkageError: loader constraint violation: while consume web service which is hosted in CQ

Avatar

Level 2

Hi,

We deployed CQ 5.6.1 as a web app in Jboss 5.1.0-GA.

My requirement is to expose soap based web service within CQ, i am using Apache CXF to do this job and successfully achieved this  job in jboss 7.1.1-final.

Now i moved my code to jboss 5.1.0-GA, here my web service successfully got exposed, but when i try to consume this web service i am getting following error stack.

I did n't modify single line of code,every thing is same.Only the difference is jboss 7.1.1-final.I don't know what went wrong, do i need to configure any thing in Jboss 5.1.0-GA ?

Please suggest me

 

 

09.11.2013 20:22:44.838 *ERROR* [127.0.0.1 [1384008764656] POST /apps/hellosoapservice HTTP/1.0] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught Throwable java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.apache.cxf.jaxb.attachment.JAXBAttachmentUnmarshaller.getAttachmentAsDataHandler(Ljava/lang/String;)Ljavax/activation/DataHandler;" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) of the current class, org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller, and its superclass loader (instance of <bootloader>), have different Class objects for the type arshaller.getAttachmentAsDataHandler(Ljava/lang/String;)Ljavax/activation/DataHandler; used in the signature

  at org.apache.cxf.jaxb.JAXBDataBase.getAttachmentUnmarshaller(JAXBDataBase.java:78)

  at org.apache.cxf.jaxb.io.DataReaderImpl.createUnmarshaller(DataReaderImpl.java:123)

  at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:156)

  at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:109)

  at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)

  at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)

  at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:206)

  at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:218)

  at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:200)

  at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)

  at com.helloworld.server.util.AbstractJaxWsServer.invoke(AbstractJaxWsServer.java:66)

  at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)

 

  

 

Regards,

Sainath

1 Accepted Solution

Avatar

Correct answer by
Level 1

Hi Sai,

Please refer the following post, it talks about exposing the boot classpath in OSGI. Add the following property in sling.properties to resolver class linkage error for the javax.activation errors.

http://spring.io/blog/2009/01/19/exposing-the-boot-classpath-in-osgi/

org.osgi.framework.system.packages.extra=javax.activation;version\="1.1.1

Restart CQ instance after adding this property

Let me know if face any errors after adding this property.

Thanks

Subhan

View solution in original post

8 Replies

Avatar

Correct answer by
Level 1

Hi Sai,

Please refer the following post, it talks about exposing the boot classpath in OSGI. Add the following property in sling.properties to resolver class linkage error for the javax.activation errors.

http://spring.io/blog/2009/01/19/exposing-the-boot-classpath-in-osgi/

org.osgi.framework.system.packages.extra=javax.activation;version\="1.1.1

Restart CQ instance after adding this property

Let me know if face any errors after adding this property.

Thanks

Subhan

Avatar

Level 5

Hello Sainath,

May be below will help, Did you try to call same webservice outside CQ and see if that help ? That way you would know if it is JBoss integration error or error through CQ.

1) http://stackoverflow.com/questions/10495254/linkageerror-whilst-trying-to-invoke-cxf-soap-webservice

Yogesh

Avatar

Level 2

Thanks Subhan, It worked !!!

Regards,

Sainath

Avatar

Level 2

Hi Yogesh,

Thanks for reply.I followed the link shared by you, unfortunately it did n't work for me. i deployed same code in standalone CQ and consumed from out side of CQ,then also i am getting same issue. but same thing is working fine in Jboss 7.1.1-final, i think Jboss 7.1.1-final has some special configuration or special class loading mechanism to override this kind of issues.

 

Regards,

Sainath

Avatar

Level 10

For startup script add [1] & verify.

[1]   -XX:-UseSplitVerifier

Avatar

Level 2

Hi Sham,

Thanks for your reply. I added  -XX:-UseSplitVerifier in my start up script. but still i am facing the same problem.following is my start up script for your reference..

 

@echo off
rem -------------------------------------------------------------------------
rem JBoss Bootstrap Script for Windows
rem -------------------------------------------------------------------------

rem $Id: run.bat 88978 2009-05-16 18:18:45Z alex.loubyansky@jboss.com $

@if not "%ECHO%" == ""  echo %ECHO%
@if "%OS%" == "Windows_NT" setlocal

if "%OS%" == "Windows_NT" (
  set "DIRNAME=%~dp0%"
) else (
  set DIRNAME=.\
)

rem Read an optional configuration file.
if "x%RUN_CONF%" == "x" (   
   set "RUN_CONF=%DIRNAME%run.conf.bat"
)
if exist "%RUN_CONF%" (
   echo Calling %RUN_CONF%
   call "%RUN_CONF%" %*
) else (
   echo Config file not found %RUN_CONF%
)

pushd %DIRNAME%..
if "x%JBOSS_HOME%" == "x" (
  set "JBOSS_HOME=%CD%"
)
popd

set DIRNAME=

if "%OS%" == "Windows_NT" (
  set "PROGNAME=%~nx0%"
) else (
  set "PROGNAME=run.bat"
)

if "x%JAVA_OPTS%" == "x" (
  set "JAVA_OPTS=-Dprogram.name=%PROGNAME% -XX:-UseSplitVerifier"
) else (
  set "JAVA_OPTS=-Dprogram.name=%PROGNAME% %JAVA_OPTS% -XX:-UseSplitVerifier"
)

if "x%JAVA_HOME%" == "x" (
  set  JAVA=java
  echo JAVA_HOME is not set. Unexpected results may occur.
  echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
) else (
  set "JAVA=%JAVA_HOME%\bin\java"
  if exist "%JAVA_HOME%\lib\tools.jar" (
    set "JAVAC_JAR=%JAVA_HOME%\lib\tools.jar"
  )
)

rem Add -server to the JVM options, if supported
"%JAVA%" -server -version 2>&1 | findstr /I hotspot > nul
if not errorlevel == 1 (
  set "JAVA_OPTS=%JAVA_OPTS% -server"
)

rem Set Java platform if 64-Bit JVM used
set JAVA_PLATFORM=
"%JAVA%" -version 2>&1 | findstr /I "64-Bit ^| x86_64" > nul
if not errorlevel == 1 (
  if /I "%PROCESSOR_ARCHITECTURE%"=="IA64"  (set JAVA_PLATFORM=i64
  ) else if /I "%PROCESSOR_ARCHITECTURE%"=="AMD64" (set JAVA_PLATFORM=x64
  ) else if /I "%PROCESSOR_ARCHITECTURE%"=="x64"   (set JAVA_PLATFORM=x64
  ) else if /I "%PROCESSOR_ARCHITEW6432%"=="IA64"  (set JAVA_PLATFORM=i64
  ) else if /I "%PROCESSOR_ARCHITEW6432%"=="AMD64" (set JAVA_PLATFORM=x64
  ) else (
    echo PROCESSOR_ARCHITECTURE is not set. Unexpected results may occur.
    echo Set PROCESSOR_ARCHITECTURE according to the 64-Bit JVM used.
  )
)

if "x%JAVA_PLATFORM%" == "x" set JAVA_PLATFORM=x86

rem Add native to the PATH if present
set JBOSS_NATIVE_LOC=
if exist "%JBOSS_HOME%\bin\META-INF\lib\windows-%JAVA_PLATFORM%" (
  set "JBOSS_NATIVE_HOME=%JBOSS_HOME%\bin\META-INF\lib\windows-%JAVA_PLATFORM%"
) else if exist "%JBOSS_HOME%\bin\native" (
  set "JBOSS_NATIVE_HOME=%JBOSS_HOME%\bin\native"
)

if not "x%JBOSS_NATIVE_HOME%" == "x" (
  set "PATH=%JBOSS_NATIVE_HOME%;%PATH%;%JBOSS_HOME%\bin"
  set JAVA_OPTS=%JAVA_OPTS% "-Djava.library.path=%JBOSS_NATIVE_HOME%;%PATH%;%JBOSS_HOME%\bin"
)

rem Find run.jar, or we can't continue

if exist "%JBOSS_HOME%\bin\run.jar" (
  if "x%JAVAC_JAR%" == "x" (
    set "RUNJAR=%JAVAC_JAR%;%JBOSS_HOME%\bin\run.jar"
  ) else (
    set "RUNJAR=%JBOSS_HOME%\bin\run.jar"
  )
) else (
  echo Could not locate "%JBOSS_HOME%\bin\run.jar".
  echo Please check that you are in the bin directory when running this script.
  goto END
)

rem If JBOSS_CLASSPATH empty, don't include it, as this will
rem result in including the local directory in the classpath, which makes
rem error tracking harder.
if "x%JBOSS_CLASSPATH%" == "x" (
  set "RUN_CLASSPATH=%RUNJAR%"
) else (
  set "RUN_CLASSPATH=%JBOSS_CLASSPATH%;%RUNJAR%"
)

set JBOSS_CLASSPATH=%RUN_CLASSPATH%

rem Setup JBoss specific properties

rem Setup the java endorsed dirs
set JBOSS_ENDORSED_DIRS=%JBOSS_HOME%\lib\endorsed

echo ===============================================================================
echo.
echo   JBoss Bootstrap Environment
echo.
echo   JBOSS_HOME: %JBOSS_HOME%
echo.
echo   JAVA: %JAVA%
echo.
echo   JAVA_OPTS: %JAVA_OPTS%
echo.
echo   CLASSPATH: %JBOSS_CLASSPATH%
echo.
echo ===============================================================================
echo.

:RESTART
"%JAVA%" %JAVA_OPTS% ^
   -Djava.endorsed.dirs="%JBOSS_ENDORSED_DIRS%" ^
   -classpath "%JBOSS_CLASSPATH%" ^
   org.jboss.Main %*

if ERRORLEVEL 10 goto RESTART

:END
if "x%NOPAUSE%" == "x" pause

:END_NO_PAUSE

Avatar

Level 4

Hi Subhan,

We were able to fix the linkage error by setting this property. But we have a HTML email functionality in our bundle and now it is not working. Do we have any alternate solution for this?

Thanks,

Anusha