Integrated ant - taskdef classloader issue - java

On Weblogic 10.3 my enterprise application includes a webservice that runs ant scripts inside. My problem is that I cannot get my custom tasks running due to java.lang.ClassNotFoundExceptions.
(All this works well on Tomcat 5.5)
My task implementation can be found in 4 different locations:
something.ear/APP-INF/lib/antaddon.jar!/foo/bar/MyTask.class
something.ear/Webservice.war/WEB-INF/lib/antaddon.jar!/foo/bar/MyTask.class
something.ear/Webservice.war/WEB-INF/classes/foo/bar/MyTask.class
server/lib/antaddon.jar!/foo/bar/MyTask.class
I see that the Weblogic 10.3 integrated Ant 1.6.5 module might cause problems
as I have an Ant 1.8.0 bundled, so I added
<prefer-application-packages>
<package-name>antlr.*</package-name>
<package-name>org.apache.ant.*</package-name>
<package-name>org.apache.zip.*</package-name>
</prefer-application-packages>
to my weblogic-application.xml to overcome this. (This solved some NoSuchMethodErrors..)
However my Task is still not found:
java.lang.ClassNotFoundException: foo.bar.MyTask.class
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:457)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:91)
can you help me how to solve this?

The problem was that my prefer-application-packages directive was wrong, ant classes are not in org.apache.ant.* but in org.apache.tools.ant.*. After repairing this my custom class gets loaded and works well from APP-INF/lib/antaddon.jar

Related

Weblogic 9.2: java.lang.NoSuchMethodError: javax.jws.WebMethod.exclude()Z

I'm getting this error when I'm trying to consume one Web Service:
java.lang.NoSuchMethodError: javax.jws.WebMethod.exclude()Z
at org.apache.cxf.jaxws.support.JaxWsServiceConfiguration.isOperation(JaxWsServiceConfiguration.java:155)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.isValidMethod(ReflectionServiceFactoryBean.java:1853)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperations(ReflectionServiceFactoryBean.java:623)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeWSDLOperations(JaxWsServiceFactoryBean.java:289)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:392)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:499)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:152)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:464)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:331)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:318)
at javax.xml.ws.Service.getPort(Service.java:40)
at prova.wsclient.hello.HelloWorldImplService.getHelloWorldImplPort(HelloWorldImplService.java:78)
at prova.helloWorldProxy(Tasca.java:1380)
at prova.run(Tasca.java:126)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
In my project I've got CXF and JSR181 jars and seems to appear this method.
At the weblogic.xml appears:
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
Also, at the weblogic-application.xml:
<prefer-application-packages>
<package-name>javax.jws.*</package-name>
</prefer-application-packages>
My version of Weblogic Server is 9.2. What I'm doing wrong? I would appreciate any help.
Thanks!
I have faced this kind of issues with Weblogic 9.2 and resolved by prepending the jars to the server jvm classpath (you can do it through the weblogic console). It is not the right solution, but it has worked at times.

Spring+quartz giving java.lang.NoClassDefFoundError: weblogic/logging/LogEntryFormatter

Im following http://www.mkyong.com/spring/spring-quartz-scheduler-example/ to develop a job for my spring app... Im getting the following exception when im trying to run it.
Can anyone tell whats the resolution for this?
Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/logging/LogEntryFormatter >
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:891)
at java.lang.ClassLoader.loadClass(ClassLoader.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at weblogic.logging.commons.LogImpl.<init>(LogImpl.java:14)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:21)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:18)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:145)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:70)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:45)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:59)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:84)
at com.jobs.RunMeJob.main(RunMeJob.java:10)
Seems like you are using the weblogic common logging mechanism in your app...and missing some jars/classes in your WL classpath. Can you post your classpath?
Also, you might want to try SLF4J for logging (http://www.slf4j.org) which I find so much easier to use (as well as versatile, allowing you to use any underlying logging mechanism, such as popular log4j for example)
If you deployed quartz to your Weblogic domain's lib directory you need to ensure that all of quartz dependencies are also deployed to the same directory.
I solved a similar problem by deploying jcl-over-slf4j and slf4j-api.

<HTTP> <BEA-101163> <Could not load user defined listener:

I have modified an EAR for Weblogic 10 ( BEA 10 )which is already running on BEA 8..
I am getting the following error while deploying the EAR..
[HTTP:101163]Could not load user defined listener: com.xxx.xxxx.jmx.LifecycleListener java.lang.NoClassDefFoundError: com/tibco/sdk/MException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357) at java.lang.Class.getConstructor0(Class.java:2671) at java.lang.Class.newInstance0(Class.java:321) at java.lang.Class.newInstance(Class.java:303) at weblogic.servlet.internal.WebComponentContributor.getNewInstance(WebComponentContributor.java:187) at weblogic.servlet.internal.WebComponentContributor.createListenerInstance
Have you faced this error ?Please help me...
From the Exception it seems that some library is missing from your ear file. Make sure that com.xxx.xxxx.jmx.LifecycleListener is a valid package and included correctly in your ear.
If you are developing and building the ear with JDeveloper make sure you add this lib in your application resources. If you do this manualy make sure that this lib exists in your WEB-INF/lib folder

JaxWS ClassCastException on JBoss

I'm using JBoss 5.1.0.GA (for JDK6), and jaxws 2.2.6.
When I invoke the webservice, I get the following exception:
java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider:
Provider org.jboss.ws.core.jaxws.spi.ProviderImpl could not be
instantiated: java.lang.ClassCastException at
org.jboss.resource.work.WorkWrapper.completed(WorkWrapper.java:283)
at
org.jboss.util.threadpool.BasicTaskWrapper.taskCompleted(BasicTaskWrapper.java:367)
at
org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:268)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by:
java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider:
Provider org.jboss.ws.core.jaxws.spi.ProviderImpl could not be
instantiated: java.lang.ClassCastException at
java.util.ServiceLoader.fail(ServiceLoader.java:207) at
java.util.ServiceLoader.access$100(ServiceLoader.java:164) at
java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:353) at
java.util.ServiceLoader$1.next(ServiceLoader.java:421) at
javax.xml.ws.spi.Provider.getProviderUsingServiceLoader(Provider.java:180)
at javax.xml.ws.spi.Provider.provider(Provider.java:140) at
javax.xml.ws.Service.(Service.java:92)
[...]
... 3 more Caused by: java.lang.ClassCastException at
java.lang.Class.cast(Class.java:2990) at
java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:345)
... 14 more
I also tried to update jbossws to version 3.4.0 from 3.1.2.GA, nothing changed.
I've read a lot of suggestions related to checking jars in lib/endorsed of JBoss, so this is the content:
activation.jar
jaxb-api.jar
jaxws-api.jar
jbossws-native-factories.jar
resolver.jar
serializer.jar stax-api.jar
xalan.jar
xercesImpl.jar
I've also added the switch -verbose:class to the JVM:
[Loaded org.jboss.ws.core.jaxws.spi.ProviderImpl from jar:file:/Users/carlo/jboss-5.1.0.GA/common/lib/jbossws-native-core.jar!/]
and that class extends javax.xml.ws.spi.Provider (http://bit.ly/LK9bNE)
Can someone help me what's going on here?
EDIT 1
Ok, so I see that the ClassCastException is raised from: ServiceLoader.java line 345
S p = service.cast(Class.forName(cn, true, loader).newInstance());
when service.cast is called, this is javax.xml.ws.spi.Provider and the arg to cast is org.jboss.ws.core.jaxws.spi.ProviderImpl.
I still fail to understand the problem though.
Finally, I've managed to solve my problem: I put jaxws-rt.jar in $JBOSS_HOME/lib/endorsed.
EDIT
I had the same problem on JBoss 5.1 EAP, and to solve it, the steps are a little different:
in $JBOSS_HOME/lib/endorsed I removed the old jaxb-api.jar, then copied
jaxb-api.jar
jaxb-impl.jar
jaxws-api.jar
jaxws-rt.jar
from the latest jaxws-ri package, and eventually it worked.
I faced the same issue. I am running JBoss 5.1 EAP along with JDK 1.6_22.
I did things slightly different. I combined the solution by Carlo plus this solution.
I created an endorsed folder under $JBOSS_HOME/server//lib/endorsed. I then copied over streambuffer.jar, stax-ex.jar, policy.jar, jaxws-rt.jar, jaxws-api.jar, jaxb-impl.jar, jaxb-api.jar and gmbal-api-only.jar.
I left the $JBOSS_HOME/lib/endorsed alone.
Doing this, I was able to get it to work it all to work
I had the same problem on JBoss 5.1 EAP
Instead of putting jar files into JBOSS application server it is more robust when you alter class loading logic by isolating WAR with Overriding Server Classes (http://www.jboss.org/community/wiki/classloadingconfiguration) In my case I have 3 environments. With this solution I can move war file from one JBOSS instance to another and it will still work.
I resolved this problem by:
Adding this to jboss-web.xml:
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>
com.example:archive=unique-archive-name
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
...
and by adding requierd jars into war (jaxb-api.jar, jaxb-impl.jar, jaxws-api.jar, jaxws-rt.jar)

ClassCastException with OpenJPA in Jboss 6.0

Jboss 6 comes with JPA 2.0 (hibernate-jpa-2.0-api.jar) and Hibernate 3.6.6 as the implementation.
I have a web application that has OpenJPA 2.0 library (openjpa-all-2.1.0.jar). I have set the classloader isolation in the jboss-web.xml as shown below
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>
some.example:loader=some-webapp.war
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
When I deploy the application I get this error
ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=some.war#some state=Create: java.lang.ClassCastException: org.apache.openjpa.persistence.PersistenceProviderImpl cannot be cast to javax.persistence.spi.PersistenceProvider
This is strange since, org.apache.openjpa.persistence.PersistenceProviderImpl already implements javax.persistence.spi.PersistenceProvider
I did a -version:class to check where the javax.persistence.spi.PersistenceProvider is being loaded from and it appears that it's being loaded from the web application first and then from jboss6\common\lib
[Loaded javax.persistence.spi.PersistenceProviderResolverHolder$1 from vfs:/home/sathwik/apps/jboss-6.1.0.Final/server/default/deploy/some-webapp.war/WEB-INF/lib/openjpa-all-2.1.0.jar/]
[Loaded javax.persistence.spi.PersistenceProvider from vfs:/home/sathwik/apps/jboss-6.1.0.Final/common/lib/hibernate-jpa-2.0-api.jar/]
From the Manifest.mf file i was able to gather the JDK version used to compile
hibernate-jpa-2.0-api.jar is compiled with Build-Jdk: 1.5.0_19,
openjpa-all-2.1.0 is compiled with Build-Jdk: 1.6.0_22
Can anyone help me out in understanding why this exception?
According to the OpenJPA Dependencies page, the openjpa-all JAR file
[...] includes the OpenJPA core code plus all of the runtime dependencies for Java SE environments
You're not running in a JavaSE envrionment, you're in a full-blown JavaEE environment, which already has many of the ancillary API classes contained within the openjpa-all JAR. As a result, you're getting conflicts caused by loading classes of the same name, but from different classloaders.
You should replace openjpa-all with more specific JAR files (i.e. openjpa-2.1.0.jar and whatever others are necessary to make it work - see the above page).

Categories

Resources