Hermes-JMS Unable to display message - java

I am user Hermes-JMS to try to display messages on a Java Message Queue.
When I select a message error that it is "Unable to display message" the reason is a Class Cast error.
Is there way to point Hermes to my objects (set the class path for Hermes) so it can use the toString method to display the messages that it sees on the Queue.

I found the solution. First go to your IDE and export to JAR (in RAD or eclipse this is simply right click export) and include all your projects. This should create a jar file with all your class files. Even if you are doing a war or ear file, just export to jar file so Hermes can read it.
Then in Hermes click on options -> configuration select the Providers tab expand the class path groups that already exist (important don't create a new group this was where I was making my mistake every time I tried, just use the existing one)
Right click on "Library" and select add jar file, select the jar file you create above, select ok and scan, you might have to do the add jar again for each jar you added to your project that your classes depend on.

Related

Is there a way to auto select the elements to export when exporting a jar in vscode?

I'm trying to find a way to export a jar in vscode without having to select what to include everytime and I just can't seem to find any info for it on the internet. Is there a way to do that or am I just not able to? Here's a screenshot of what i'm talking about
Could you have a look at this page?
You will see the wizard choosing the elements of the output jar. You
will see a list including output folders and the dependency artifacts
of the workspace
The runtime elements are chosen by default while the test ones are
not. You can choose the elements you need and click OK.
note: If only one element is found in your workspace, this step will
be skipped and the element will be included in the export jar
automatically. nm

How do I cross check whether an Imported a jar file is successfully added or not in Eclipse?

I am supposed to replace existiong API with Apache POI 3.16. I have downloaded poi-3.16.jar and have added it in my Eclipse libs folder. How do I check if it is successfully added or not?
Go on configure buildpath and see that jar is there or not with correct path.
right click on project
configure build path go on libraries
now check you jar folder or jar file is present or not.
or you can check by use one of class of this jar like HSSFWorkbook if it is imported means this jar is added successfully otherwise you need to add.
If you import classes from it and attempt using them, does it work or not? There's nothing more to it.
If you replaced an older version of the same lib, remove the old and rebuild the project.
But, above all, do yourself a favor and use Maven or Gradle or any other build tool with dependency management and just add the correct dependency. Manually maintaining the classpath is infernally error prone.
First, open the jar file with any program that you would use to open a zip file. Drill down through the folders until you find a class to represent that jar file.
Note the package plus class name.
Open a "Open Type" message dialog. This is usually at the shortcut, Ctrl + Shift + T, or in the menu at Navigate -> Open Type. Enter the package name plus classname in the dialog. Select the class and it should show the name of the jar file at the bottom.
If Open Type is disabled, you may need to enable it through Window -> Customize Perspective -> Command Groups Availability -> Java Navigation in the "Available command groups"

Intelli-J: cannot create class-file?

This is honestly a tiny problem but it's keeping me from proceeding with my small Java practice app.
I'm currently practicing making an API call in Java. I was trying to create a simple class file called "Film". However, when I try to create it as a class-file, Intelli-J keeps telling me that it is unable to create a class-file. I'm trying to set this file up in a folder called "models". All of these class files are going to be utilized as part of an app that performs API calls.
Is there some naming convention I haven't followed? I've been Googling but haven't really found anything.
More directly, based on what #Vishal Jumani touched on, you need to tell IntelliJ what directories are 'source' or 'test' directories.
A directory structure you can use as an example, but you can use whatever you wish.
Right click on the directory you wish to mark as 'root' --> find 'Mark Directory As' --> Select 'Sources Root'
Now you should be able to add java classes in the directory without IntelliJ interrupting you!
This would usually be because of the way your project is setup. It may not be setup correctly to indicate where your source code is.
To setup your project, in the Project Tab, click on the top most folder and select F4. This should bring up the Project Settings dialog window.
Now click on Modules in the LHS, and then select the Sources Tab on the RHS
Select your src folder and click on the Sources button, to indicate this is your source folder. Now IntelliJ is aware that this is where your code is.
Click on Apply and OK. This should close the Dialog Window.
Now right click on the src folder and then select New -> Java Class to create your Java class

How to auto configure war file in eclipse

I have a problem with my war.xml file in that it isn't picking up my class files correctly for spring.
The line that is wrong is:
<dir sourceOnDisk="C:\myApp\src\main\java" targetInArchive="/WEB-INF/classes"/>
I need:
<dir sourceOnDisk="C:\myApp\bin" targetInArchive="/WEB-INF/classes"/>
Now, I can change the file manually (from src\main\java to bin), and it works correctly for a while, but every now and again something decides my war.xml file needs to be rebuilt, and things then break again.
I added my application by dragging my project from eclipse's Project Explorer tab to my liberty profile server instance within eclipse's Servers tab.
Where is the menu option within eclipse to change this?
To automatically map your bin folder to the WEB-INF/classes folder, select your project on the Project Explorer, right click it and select Java Build Path. In this property page on the Source tab, you can add, edit or remove the source folder, and also modify the default output folder. In this case you may only need to modify the output folder, to something similar to (project-name)/bin
Regarding the *war.xml file located at (server-dir)/apps, this will be refreshed each time you modify your project in eclipse, if when doing it, you have your server started and with automatic publish enabled. Usually you don't modify this file yourself, but you can read more about it here: http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.wlp.nd.doc/ae/rwlp_loose_applications.html?cp=SSAW57_8.5.5%2F1-14-1-10
Turns out the correct place to change things is in the Deployment Assembly option when you right click on your project...

Eclipse: Create jar containing one class + dependencies

I have an eclipse project that contains several classes and packages. I want to create a runnable jar of just one class from the project. But this jar should contain all the dependencies too. Can someone please tell me how can I do this? Most posts on StackOverflow have answers for creating a jar file for the entire project, but I only need jar of one class with all dependencies bundled together.
I could finally figure out how to do it. Just right click on your class file for which you'd like to create a jar. Select Export --> Jar File. Click on next. In select resources to export, select the project name. Expand the project to find the package that contains the class you'd like to export as a jar. Select the class name. Check the box --> Export generated class files and resources. Select the export destination, and check the option --> Compress the contents of the JAR file. Click on next. Under select options for handling problems, leave both the options checked. You don't need to check the option - Save the description of this JAR. Click on next. Here, leave the default options. Under select the class of the application entry point, specify your class (Make sure your class has a main method). And finally click on finish. Once this is done, go to the path where you've saved the jar. Right click, and say open with --> Archive utility. This will create a folder of your jar file. In my case, I named the folder lib. Inside this folder, copy all the JARs that this class needs to execute.
Finally, do this from the folder where you have the folder of your jar file --
myMac$ JAVA_HOME=`/usr/libexec/java_home`
myMac$ libraries=`ls lib/*.jar | tr "\n" ":"`
myMac$ $JAVA_HOME/bin/java -cp $libraries com.test.rick.GeoData
GeoData here is the class which I was trying to export as a JAR. Hope this is useful for someone in the future.

Categories

Resources