Packaging ejb3 swing client - jboss

I get the "java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFac
tory" error while running my packaged ejb3 swing client jar. Here's the stack trace.
G:\Courses\OSUMC\Installables\June 5\New>java -jar MetaDB-Client.jar
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
rg.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at net.massmatrix.metadb.ui.facade.BaseEJBFacade.getInitialContext(BaseE
JBFacade.java:26)
at net.massmatrix.metadb.ui.facade.UserManagerFacade.getUserManager(User
ManagerFacade.java:24)
at net.massmatrix.metadb.ui.facade.UserManagerFacade.isUserNameAvailable
(UserManagerFacade.java:44)
at net.massmatrix.metadb.ui.MainFrame.main(MainFrame.java:269)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFac
tory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 8 more
Exception in thread "main" java.lang.NullPointerException
at net.massmatrix.metadb.ui.facade.UserManagerFacade.isUserNameAvailable
(UserManagerFacade.java:44)
at net.massmatrix.metadb.ui.MainFrame.main(MainFrame.java:269)
Here are my packaged swing client Jar contents:-
MetaDB-Client.jar
\net\.. - contains class files(from both client and server)
META-INF
MANIFEST.MF
jndi.properties
Here's my jndi.properties:-
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost:1099
Here's my MANIFEST.MF:-
Manifest-Version: 1.0
Main-Class: net.massmatrix.metadb.ui.MainFrame
Class-Path: jbossall-client.jar
Manifest contents from my jar:-
Manifest-Version: 1.0
Created-By: 1.6.0_18 (Sun Microsystems Inc.)
Main-Class: net.massmatrix.metadb.ui.MainFrame
Command used to create the jar:-
jar cfm MetaDB-Client.jar MANIFEST.MF net\* jndi.properties
Command used to run the jar:-
java -jar MetaDB-Client.jar
I have the jbossall-client.jar in my classpath
G:\Courses\OSUMC\Installables\June 5\New>echo %CLASSPATH%
.;G:\Courses\OSUMC\WORK\Software - New\jboss-5.0.1.GA\client
What else am i missing ?
Thanks.

All you have to do is add the jbossall-client.jar library to the clients lib folder.
ClassPath in the MANIFEST cannot have * in it.
Here is the tutorial for the JAR manifest classpath.

Related

Unable to run junits in eclipse for jhipster sample app gradle

I checked out https://github.com/jhipster/jhipster-sample-app-gradle imported the project into eclipse Version: 2020-03 (4.15.0), installed gradle plugin. When I try to run the Junit test Right click -> Run as Junit I keep getting
java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: org/junit/platform/engine/EngineDiscoveryListener
at org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.getLauncherDiscoveryListener(LauncherDiscoveryRequestBuilder.java:241)
at org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.build(LauncherDiscoveryRequestBuilder.java:235)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.createUnfilteredTest(JUnit5TestLoader.java:75)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.createTest(JUnit5TestLoader.java:66)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.loadTests(JUnit5TestLoader.java:53)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:526)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: java.lang.NoClassDefFoundError: org/junit/platform/engine/EngineDiscoveryListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 9 more
Caused by: java.lang.ClassNotFoundException: org.junit.platform.engine.EngineDiscoveryListener
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 21 more
I tried searching all over but couldn't find a solution that works, Anybody had the same issue and got it resoled please provide the solution
enthusiast,
Just add
testImplementation('org.junit.platform:junit-platform-launcher:1.5.2')
to the dependencies section in build.gradle file, refresh gradle (on eclipse, on the context menu of the project > Gradle > Refresh Gradle Project). You should be able to run tests one by one.
Happy coding

java.lang.ClassNotFoundException: com.ibm.websphere.rsadapter.DB2AS400DataStoreHelper

I am trying to migrate an application from Websphere to Tomcat and facing an issue.
Class not found: com.ibm.websphere.rsadapter.DB2AS400DataStoreHelper
I have this jar com.ibm.ws.runtime-8.5.5.1 in the lib, but it doesn't have this particular DB2AS400DataStoreHelper class inside rsadapter package.
I want to find out the jar or the version number which has DB2AS400DataStoreHelper class.
4:23:42 PM: Caused by: com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException: DSRA8050W: Unable to find the DataStoreHelper class specified: com.ibm.websphere.rsadapter.DB2AS400DataStoreHelper
at com.ibm.ws.rsadapter.AdapterUtil.createDataStoreAdapterException(AdapterUtil.java:441)
at com.ibm.ws.rsadapter.DSConfigHelper.createDataStoreHelper(DSConfigHelper.java:797)
at com.ibm.ws.rsadapter.spi.WSRdbDataSource.<init>(WSRdbDataSource.java:1153)
at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.setDataSourceProperties(WSManagedConnectionFactoryImpl.java:2644)
... 72 more
Caused by: java.lang.ClassNotFoundException: com.ibm.websphere.rsadapter.DB2AS400DataStoreHelper
at java.net.URLClassLoader.findClass(Unknown Source)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:204)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:119)
at java.lang.ClassLoader.loadClass(Unknown Source)

Could not find main class : Program will exit

I was messing with the JRE setup on Eclipse. Originally the project was set to 1.6 and when set to 1.7, my program started showing a lot of errors. So when i switched back to 1.6, all the compile time errors vanished but i have a new problem now.
This was shown on the console when i tried to run the started class containing the main function. The .class files all exist. Please advice.
java.lang.UnsupportedClassVersionError: Demo : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"
Version 51.0 means the are still class files compiled with Java 7. This files wont run with a JRE 6. You have to recompile them first (Rebuild project or clean compile using ant/maven).
Check if java versions match in your Java Build path and Java Compiler in Project properties. I think you compiled with 1.6 and is trying to run with java 1.7

Javamail demo not working

I have tried running the demo msgsend from JavaMail. I have downloaded version 1.4.5 of JavaMail and unpacked it into my JDK folder. I have added mail.jar to CLASSPATH. I have compiled msgsend.java without getting any error back. However, when I then try running java msgsend I get an "Could not find the main class: msgsend" error.
I am a total noob in Java world and have spend hours browsing through the Internet trying to find an answer but to no avail in my case.
Here is what I get in the console. What am I doing wrong?
C:\Program Files\Java\jdk1.6.0_34\javamail-1.4.5\demo>echo %CLASSPATH%
C:\Program Files\Java\jdk1.6.0_34\javamail-1.4.5\mail.jar
C:\Program Files\Java\jdk1.6.0_34\javamail-1.4.5\demo>javac -cp "%classpath%" ms
gsend.java
C:\Program Files\Java\jdk1.6.0_34\javamail-1.4.5\demo>java msgsend
Exception in thread "main" java.lang.NoClassDefFoundError: msgsend
Caused by: java.lang.ClassNotFoundException: msgsend
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: msgsend. Program will exit.
C:\Program Files\Java\jdk1.6.0_34\javamail-1.4.5\demo>java -cp "%classpath%" msg
send
Exception in thread "main" java.lang.NoClassDefFoundError: msgsend
Caused by: java.lang.ClassNotFoundException: msgsend
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: msgsend. Program will exit.
C:\Program Files\Java\jdk1.6.0_34\javamail-1.4.5\demo>
Classes are case sensitive. Be sure you have the compiled MsgSend in your class path, and invoke the compiled class with the proper case.
Try java MsgSend
Edited:
This is how it will work:
Compile as you were doing:
javac.exe -cp ..\mail.jar msgsend.java
And then to run the compiled class do:
java -cp ..\mail.jar;. msgsend
In other words: you were missing the current folder in your classpath.
You didn't include the directory where msgsend.class exists, usually the current directory ("."). See the examples in README.txt included with JavaMail.

Eclipse WAS V7.0 Dev Tools wsimport error

I'm trying to generate a "Top down EJB Web Service" implementation from a WSDL with WAS V7.0 Developer Tools. (Server runtime WAS 7.0, web service runtime IBM WebSphere JAX-WS.) After selecting my EJB and EAR projects and specifying further options, I always get the following error, regardless of my options:
Errors occurred during wsimport.
java.lang.NoClassDefFoundError: com/sun/tools/internal/ws/wscompile/WsimportTool
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.ibm.ast.ws.jaxws.emitter.jdk6.command.AbstractEmitterCommand.loadClass(AbstractEmitterCommand.java:166)
at com.ibm.ast.ws.jaxws.emitter.jdk6.command.WsImportCommand.execute(WsImportCommand.java:113)
at com.ibm.ast.ws.jaxws.emitter.command.WsImportCommand.execute(WsImportCommand.java:81)
at com.ibm.ast.ws.jaxws.creation.command.WsimportNonUIThreadCommand$RunCmdInNonUIThread.run(WsimportNonUIThreadCommand.java:284)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.internal.ws.wscompile.WsimportTool
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
Going through the exact same steps in Rational Application Developer 7.5.1, I can successfully generate an EJB web service implementation with an HTTP router module for my WSDL. So I think this problem might be related to WAS Developer Tools.
Do you guys have any idea why I'm getting this error? Any help would be much appreciated.
Thank you,
Csaba
Make sure you are using the WAS 7.0 JVM when you run the wsimport. You may have several JVMs on your workstation. The JVM under <was install>/java is the one you want in your PATH ahead of all others when using the command.
It wasn't enough to configure Eclipse to use IBM's SDK for projects, I had to start Eclipse using IBM's JVM. I've edited eclipse's config file (eclipse.ini) and added IBM's JRE.
openFile
-vm
...\IBM\WebSphere7\AppServer\java\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.5
...
Reference