ClassLoader issue on WAS 7.0.0.0 - DocumentBuilderFactoryImpl - java

I am working with a Web application written in cocoon framework (Java) and running on WAS 7.0.0.0.
When running on WAS 6.X.X.X everything works fine.
However, on WAS 7 during runtime I am receiving the following error:
java.lang.ClassCastException org.apache.xerces.jaxp.DocumentBuilderFactoryImpl incompatible with javax.xml.parsers.DocumentBuilderFactory
at javax.xml.parsers.DocumentBuilderFactory.newInstance
We suspect that this is a ClassLoader issue.
I have tried many steps to overcome this issue:
I have tried to add in the WAS Administration Console a new Custom properties:
Application servers -> Server Name -> Process definition -> Java Virtual Machine -> Custom properties
Name = javax.xml.parsers.DocumentBuilderFactory
Value = org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
But this did not resolve the problem!
I tried to change the WAS class loader order in the WAS Admin Console between parent first and parent last - both options did not resolve the issue.
Please let me know if you need additional information.

Because was7 must have these jars inbuilt. You need to remove these jars from your ear/war and then deploy. Multiple copies of the same jars are conflicting.
Regards,

Related

JMeter not recognizing classpath in user.properties

I am using JMeter version 5.0 r and I am following [this tutorial]
(https://docs.wso2.com/display/EI630/Point-to-Point+Messaging#865c10b8d4d64ac688d6a0799cfb6012),
jndiqueues.properties
# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.QueueConnectionFactory = amqp://admin:admin#clientID/carbon?brokerlist='tcp://localhost:5675'
# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.FirstQueue = myfirstqueue
when I am running this JMS publisher I am getting error as:
Response message: javax.naming.NamingException: javax.naming.NoInitialContextException: Cannot instantiate class: org.wso2.andes.jndi.PropertiesFileInitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.wso2.andes.jndi.PropertiesFileInitialContextFactory ]
This jar is already there in lib folder still I added want to add it in classpath because it was giving this error. So I edited user.properties file, like mentioned in an answer here:
user.classpath=../classes;../lib;../app1/jar1.jar;../app2/jar2.jar;../lib/andes-client-4.0.0.jar
But still I am getting same error. What am I doing wrong?
If you copied andes-client-4.0.0.jar to "lib" folder of your JMeter installation there is no need to set up user.classpath property, JMeter will automatically pick it up.
Remember that you need to restart JMeter for any property change application and when you add .jars under JMeter Classpath, otherwise the changes will not be picked up.
More information:
JMeter Properties Reference
Apache JMeter Properties Customization Guide
You can also add the libraries to JMeter Classpath at Test Plan level like:
in that case JMeter restart will not be required
try the same you did but using absolute class paths instead of relative ones
What it worked for me was to use:
<propertiesJMeter>
<search_paths>${project.basedir}/some_path</search_paths>
<user.classpath>${project.basedir}/some_path</user.classpath>
</propertiesJMeter>
Hope it helps

Spring websocket example - error - Are you running in a Servlet container that supports J SR-356?

I am trying to run the Spring 4 example given # https://spring.io/guides/gs/messaging-stomp-websocket. When I try to connect to socket, it throws me following exception. As per the example you need tomcat 7.0.50 and I checked the executable jar which has right version of tomcat. Any pointer would be helpful.
java.lang.IllegalArgumentException: No 'javax.websocket.server.ServerContainer' ServletContext attribute. Are you running in a Servlet container that supports JSR-356?
Check that you have tomcat7-websocket.jar and websocket-api.jar bundled in your executable jar - perhaps you're just getting vanilla tomcat without the extra websocket bits.
I got the same error message in another use case: I deactivated auto configuration and added WebSocketConfig manually to the configuration. Then I got the abovementioned error message.
Fixing the problem was easy: just adding WebSocketAutoConfiguration to the configuration.
I know that this is an ancient thread but I ran into this error and resolved it in modern times by adding implementation("org.springframework.boot:spring-boot-starter-tomcat") explicitly to my project.

NoClassDefFoundError while deploying an application on WAS

I am trying to deploy an application on WAS 6.1 Server.
However, I am getting the below error:
java.lang.NoClassDefFoundError: org.apache.log4j.Logger
at myPackage.myClass.<clinit>(myClass.java:40)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:194)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1328)
at com.ibm.ejs.container.EJSContainer.loadBeanMetaData(EJSContainer.java:1756)
at com.ibm.ejs.container.HomeOfHomes.loadBeanMetaData(HomeOfHomes.java:1073)
at com.ibm.ejs.container.HomeRecord.getHomeAndInitialize(HomeRecord.java:454)
at com.ibm.ejs.container.EJSContainer.getHomeWrapperCommon(EJSContainer.java:1322)
at com.ibm.ejs.container.EJSContainer.getHomeInstance(EJSContainer.java:1231)
at com.ibm.ejs.container.EJSContainer.startBean(EJSContainer.java:1217)
at com.ibm.ws.runtime.component.EJBContainerImpl.startBean(EJBContainerImpl.java:3385)
at com.ibm.ws.runtime.component.EJBContainerImpl.startModule(EJBContainerImpl.java:2589)
at com.ibm.ws.runtime.component.EJBContainerImpl.start(EJBContainerImpl.java:3719)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1304)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1165)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:587)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:832)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:950)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2131)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:342)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at com.ibm.ws.classloader.CompoundClassLoader.findClass(CompoundClassLoader.java:579)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:414)
at java.lang.ClassLoader.loadClass(ClassLoader.java:597)
... 22 more
In
Admin Console -> Servers -> Application Servers -> myServerName -> Java and Process Management -> Process Definition -> Java Virtual Machine -> ClassPath
I have an entry as below:
${MY_JARS}\log4j-1.2.15.jar
Where in 'Custom Properties' MY_JARS key contains value as the path to the log4j jar
I did server clean and restart, republish, redeploy the application umpteen number of times. But this error is not going.
What am I doing wrong ?
To use ${MY_JARS} that way, you need to define it in Environment > WebSphere Variables, not in Custom Properties.
However I'd caution you about adding log4j in that manner. I seem to recall log4j might not work correctly if a single jar is shared across multiple apps. I think we attempted using log4j as a Shared Library (probably the more recommended way of doing what you're trying to do, BTW), but ended up needing to deploy to each application's WEB-INF/lib instead.
As dbreaux already pointed out you have to create environment variables with the correct scope. A custom property is available at runtime, but not for the server configuration level.
Within the WAS you can check what libraries are loaded. IIRC you have to click on the Application, afterwards on the Web Module and than you should be able to check the classloaders. If you open up the classloaders, you will see what libraries are loaded.
Please make sure log4j.jar is on the CLASSPATH of your application.For example; under WEB-INF\lib

DWR invoke error in Javascript

I am using Spring 3.05 and DWR 3.0rc1 in my application for making AJAX calls. In local environment, i.e. Eclipse & Tomcat Server, it's working fine but in Clustered Environment I am getting the following errors while invoking DWR and a script error is coming saying DWR is not defined, but I am able to see myApplication/dwr/index.html properly.
Error Log:
Skipping 'script' due to NoClassDefFoundError on org.directwebremoting.create.ScriptedCreator. Cause: org/apache/bsf/BSFException
Skipping 'pageflow' due to ClassNotFoundException on org.directwebremoting.beehive.PageFlowCreator. Cause: Beehive/Weblogic jar file not available.
adding creator type: none = class org.directwebremoting.create.NullCreator
adding creator type: new = class org.directwebremoting.create.NewCreator
Please help me out
Looks to me that jars are not included in the classpath. Can you please check whether it is included?

Classloader problem with EJB

I'm working on a project which includes persistence library (JPA 1.2), EJB 3 and Web presentation layer (JSF). I develop application using Eclipse and application is published on Websphere Application Server Community Edition (Geronimo 2.1.4) through eclipse plugin (but the same thing happens if I publish manually). When publishing to server I get the following error:
java.lang.NoClassDefFoundError: Could not fully load class: manager.administration.vehicles.VehicleTypeAdminBean
due to:manager/vehicles/VehicleType
in classLoader:
org.apache.geronimo.kernel.classloader.TemporaryClassLoader#18878c7
at org.apache.xbean.finder.ClassFinder.(ClassFinder.java:177)
at org.apache.xbean.finder.ClassFinder.(ClassFinder.java:146)...
In web.xml I have reference to EJB:
<ejb-local-ref>
<ejb-ref-name>ejb/VehicleTypeAdmin</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>manager.administration.vehicles.VehicleTypeAdmin</local>
<ejb-link>VehicleTypeAdminBean</ejb-link>
</ejb-local-ref>
EJB project has a reference to persistence project, and Web project has references to both projects. I don't get any compilation errors, so I suppose classes and references are correct.
I don't know if it is app server problem, but I ran previously application on the same server using same configuration parameters.
Does anybody have a clue what might be the problem?
Looks almost like it couldn't find the class manager.vehicles.VehicleType when it was attempting to create/load the class manager.administration.vehicles.VehicleTypeAdminBean.
I've encountered similar problems before. When the class loader attempts to load the class it looks at the import statements (and other class usage declarations) and then attempts to load those classes and so on until it reaches the bottom of the chain (ie java.lang.Object). If it cannot find one class along the chain (in your case it looks like it cannot load VehicleType) then it will state that it cannot load the class at the top of the chain (in your case VehicleTypeAdminBean).
Is the VehicleType class in a different jar? If you have a web module and and EJB module do you have the jar containing the VehicleType class in the appropriate place(s). Sometimes with web projects you have to put the jars in the WebContent/WEB-INF/lib folder or it won't find them.
Are both of these projects deployed separately (ie. two ears? or one ear and one war?) or are they together (ie, one ear with jars and a war inside?). I'm assuming the second given you declared your EJB local?
The jars that you are dependent on also have to be declared in your MANIFEST.MF files in the projects that use it.
I'm kind of running on guesses since I do not know your project structure. Showing that would help quite a bit. But I'd still check on where VehicleType is located with regards to your EJB class. You might find it isn't where you think it is come packaging or runtime.
Thanks #Chris for WebContent/WEB-INF/lib idea ! it works for me by following these steps :
1- Export my EJBs to a JAR (MyEJBs.jar)
2- I created another jar with your_installation_path/IBM/SDP/runtimes/your_version/binCreateEJBStrub.bat via CMD.exe, by executing this command :
createEJBStubs.bat <my_path>/MyEJBs.jar -newfile –quiet
3- A new jar will be automatically created in the same directory as MyEJBs.jar named MyEJBs_withStubs.jar
4- Put your new jar in WebContent/WEB-INF/lib
5- Call your EJBs by :
MyEJBRemote eJBRemote;
InitialContext ic = new InitialContext();
obj = ic.lookup("your_ejb_name_jndi");
eJBRemote = (MyEJBRemote ) PortableRemoteObject.narrow(obj,
MyEJBRemote.class);
eJBRemote = (MyEJBRemote ) obj;
Now you can call your EJBs from another EAR

Categories

Resources