Oracle Java EE-7 tutorial - appclient doesn't execute jar - java-ee-7

I'm working through the Java EE 7 tutorial, currently in the JMS section. Java EE 7, GlassFish 4, java 7_51, build/deploy using Maven, created admin objects in GlassFish, all looks fine.
I'm trying to run the producer example, so from the command line in the tutorial-root/examples/jms/simple/producer directory I'm running: appclient -client target/producer.jar queue 3
I get no output at all, no exception, nothing, the jar is there, but isn't being executed, as the first line of code would be showing me a system.out and isn't.
I'm missing something here, but I don't see it.

Not sure what the issue was, restarted glassfish, (it had been running for about a week) now it works.

Related

Payara does not start from Intellij

The Payara with GlassFish 5.192.0 does not start using the Intellij Idea.
If I run payara\bin\asadmin start-domain is works just fine, and the server starts and runs.
These are the final lines from the console output with the --verbose property set on true.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized option: --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
Command start-domain failed.
The DAS was stopped.
The root case of the issue is logged here.
Windows launcher prepends PATH with JetBrains Runtime bin directory in order to load certain DLLs without issues. It turned out to be not the best solution and we are working to address it in a different way.
asadmin.bat uses the first java.exe from PATH. It doesn't try to detect it via JAVA_HOME.
The workaround for now is to switch IntelliJ IDEA boot JDK to JBR8 per this document or start IntelliJ IDEA using idea.bat instead of idea64.exe.
The issue is fixed in 2019.2.1 RC.

jackrabbit - There is an error in invoking javac. A full JDK (not just JRE) is required

I'm learning Jackrabbit and following the documentation to run a standalone server. When I run the command java -jar jackrabbit-standalone-2.16.2.jar and access localhost:8080 on my browser, I get a 500 error saying:
org.apache.jasper.JasperException: PWC6345: There is an error in invoking javac. A full JDK (not just JRE) is required
What am I doing wrong?
Note: I have set my jdk/bin path in my environment variables.Also, my javac command is working properly. I've jdk version 1.8.0_74 and Jackrabbit version 2.16.2
Edit: According to this answer, I tried setting my jdk to my installed jres in eclipse but that didn't solve my problem.
Running the latest jackarabit standalone jar(2.17.3) in my machine(windows 10 and java home pointing in java8 jdk) produced the same errors.
I then executed the rar with java -Djava.home="%JAVA_HOME%" -jar jackrabbit-standalone-2.17.3.jar. Although I got the same error in browser I was able to see errors in the console where I invoked the running command.
One of these error was
can't open C:\Progra~1\Java\jdk1.8.0_144\lib\tzmappings.
Searching my java installation I found that the missing files, are located under jre's installation folder.
So I eventually made the standalone jar to work with:
java -Djava.home="%JAVA_HOME%\jre" -jar jackrabbit-standalone-2.17.3.jar
The initial error is a bit misleading as it refers to javac and not to the missing files.
The whole thing seems to be a bug for me. Please give a try to my workaround and if it works for you consider filing a bug in Jackrabbit's issue tracker platform.
jackrabbit-standalone uses JSP. JSP needs compilation. Compilation needs JDK.
Before running java -jar jackrabbit-standalone-2.16.2.jar do you check your JAVA_HOME, and make sure it refers to a fully-fledged JDK? In short, the bin directory should have javac.
I found that there was another variable in the Path environment System variable preceding my %JAVA_HOME%\bin variable.
You don't have to delete the other variable, but move it down (or move %JAVA_HOME\bin up) to correct the load order.

commandline tool Glassfish appclient doesn't see deployed EJB

I'm working my way through a book about "Java EE 7 for Glassfish", with the server installed on Fedora Linux.
I have a simple stateless session bean SimpleSessionBean deployed on the server and I am trying to approach that SimpleSessionBean via SessionBeanClient and the Glassfish command line tool appclient, running a client jar. Everything from the book, so it should work. The client however can't find SimpleSessionBean. Apparently a class path issue. In the server logs nothing happened.
I can't find any pointers how Glassfish should be properly installed. Everything works within the server. I can approach installed war files from facelets running in a browser.
It is probably a matter of setting $PATH right or something or some other environment variable. Any pointers to relevant literature?
Thanks in advance for any suggestions!
UPDATE1: error message
From the bash terminal window where I run appclient:
[fedora#localhost bin]$ ./appclient -client /home/fedora/Downloads/6886EN_04_Code/ch04_src/simplesessionbeanclient/target/simplesessionbeanclient.jar
Jul 06, 2017 12:52:57 PM org.glassfish.apf.impl.DefaultErrorHandler error
SEVERE: Class [ Lnet/ensode/glassfishbook/SimpleSession; ] not found.
Error while loading [ class net.ensode.glassfishbook.SessionBeanClient ]
Exception in thread "main" java.lang.NoClassDefFoundError: net/ensode/glassfishbook/SimpleSession
at net.ensode.glassfishbook.SessionBeanClient.invokeSessionBeanMethods(SessionBeanClient.java:12)
at net.ensode.glassfishbook.SessionBeanClient.main(SessionBeanClient.java:19)
Caused by: java.lang.ClassNotFoundException: net.ensode.glassfishbook.SimpleSession
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at org.glassfish.appclient.client.acc.ACCClassLoader.findClass(ACCClassLoader.java:237)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
UPDATE2: From the Glassfish book:
We are using Maven to build our code. For this example, we used
the Maven Assembly plugin (http://maven.apache.org/plugins/maven-assembly-plugin/) to build a client JAR file
that includes all dependencies; this frees us from having to specify
all the dependent JAR files in the -classpath command-line option
of the appclient utility. To build this JAR file, simply invoke mvn
assembly:assembly from the command line.
SOLUTION: the missing link was producing a client jar with additional jar's "on board" so to speak. Proceed as follows (at least in Eclipse): select pom.xml > right-click > Run As > Maven build... > enter in Goals field: assembly:assembly> Apply/Run.
The result will be that you will find TWO jars under your target folder: xxxclient.jar and xxxclient-jar-with-dependencies.jar.
From the command line in bash execute from the folder with latter jar:
/path_to/appclient -client xxxclient-jar-with-dependencies.jar
After a very long wait (on my $200 mini Linux box) the HelloWorld-ish server EJB gets finally properly called.
Your assumption is right.
You are missing net.ensode.glassfishbook.SimpleSession in your classpath.
From an older book online:
...executed through the appclient utility. This utility can be found at
[glassfish installation directory]/glassfish/bin/. Assuming this path
is in the PATH environment variable, and assuming we placed our client
code in a JAR file called simplesessionbeanclient.jar, we would
execute the above client code by typing the following command in the
command line:
appclient -client simplesessionbeanclient.jar
It seems that you've started from
.../bin/./appclient -client
/home/fedora/Downloads/6886EN_04_Code/ch04_src/simplesessionbeanclient/target/simplesessionbeanclient.jar
You need SimpleSession.class in your CLASSPATH (or in a jar in that classpath).
Usually java checks the current directory first (which is your bin folder). If the class is not found (its not, since its in your simplesessionbeanclient folder), it searches for that class in the classpath (where you did not add the simplesessionbeanclient folder).
Try
appclient -client simplesessionbeanclient.jar
from the folder where simplesessionbeanclient.jar is located.
If you don't want to add the appclient folder to your path start with
/your/path/to/appclient -client simplesessionbeanclient.jar
(again from the folder where simplesessionbeanclient.jar is located)
Update:
If you still get a ClassNotFoundException have a look if it is missing in your jar file (jars are Zip-File, you could use your Zip-Tools):
jar tf simplesessionbeanclient.jar
if there is a SimpleSession.class
I did the following to fix my problem:
Use appclient -classpath (instead of appclient -client)
Use the regular project JARs (instead of the one generated by mvn assembly:assembly)
Deploy the EJB to Glassfish (simplesessionbean.jar)
The example code from a more recent book "Java EE 8 Application Development" by David R. Heffelfinger (the same author of "Java EE 7 for Glassfish") is almost exactly the same (the only minor difference is classes are packaged in "net.ensode.javaee8book" instead of "net.ensode.glassfishbook").
When running appclient.bat -client simplesessionbeanclient-jar-with-dependencies.jar I kept getting:
java.lang.ClassNotFoundException: <mainclass>
errors. This was because the POM was assembling a manifest with <mainClass> value of "net.ensode.glassfishbook.SessionBeanClient" (instead of "net.ensode.javaee8book.SessionBeanClient"). So I decided to avoid using the -client option for appclient.bat and switched to -classpath which allowed me to specify the main class on the command line (which is easier than updating the POM or refactoring the packages to suit the manifest).
But then when running the appclient command:
PS C:\home\programs\java_ee_sdk-8u1\glassfish5\glassfish\bin> .\appclient.bat -classpath "C:\home\code\Java-EE-8-Application-Development-Code-Samples-master\ch04_src\simplesessionbean\target\simplesessionbean.jar;C:\home\code\Java-EE-8-Application-Development-Code-Samples-master\ch04_src\simplesessionbeanclient\target\simplesessionbeanclient.jar" net.ensode.javaee8book.SessionBeanClient
I kept getting:
Root exception is javax.naming.NameNotFoundException: net.ensode.javaee8book.SimpleSession#net.ensode.javaee8book.SimpleSession not found]]
errors. This was solved by deploying the EJB (simplesessionbean.jar) to Glassfish via the Admin Console (this missing step was not mentioned in the book). Running the appclient.bat command then worked.
Screenshot of appclient.bat (takes about 15 seconds to load):
Screenshot of EJB deployment:
Alternatively
You can manually compile the client to include all the dependencies by copying SimpleSession.java and SimpleSessionBean.java from the "simplesessionbean" project to the "simplesessionbeanclient" project (remember to refactor the package statements). This will generate simplesessionbeanclient.jar with the EJBs included (Nb: you still have to deploy the EJBs to the GlassFish server). Also make sure that the <mainClass> element in the POM points to the correct package.
You can now use the -client option:

How can I run mule not using java wrapper

I'm trying to run mule-3.1.2 on 64bit IBM AIX, but the java wrapper can't be executed (Found but not executable.).
I'm sure I have set the right permission.
Besides, I also can't run mule on a ia64 machine, same problem.
So can I run the mule just as a java application not using the java wrapper?
There are different ways to start Mule without using the wrapper: besides embedding it in a java or web-application, you can also start main() on org.mule.MuleServer.
Edit: 1
A good resource suggested by #rocwing is: Configuring Mule to Run From a Script
Edit 2:
Below is a script that can start Mule standalone: logging is not correctly configured and the shutdown sequence is a little... challenged, but it should get you started.
#!/bin/sh
for f in $MULE_HOME/lib/boot/*.jar
do MULE_CLASSPATH="$MULE_CLASSPATH":$f ;
done
for f in $MULE_HOME/lib/mule/*.jar
do MULE_CLASSPATH="$MULE_CLASSPATH":$f ;
done
for g in $MULE_HOME/lib/opt/*.jar
do MULE_CLASSPATH="$MULE_CLASSPATH":$g ;
done
java -Djava.endorsed.dir=$MULE_HOME/lib/endorsed -cp "$MULE_CLASSPATH" org.mule.MuleServer -config ~/my/mule-config.xml

Weblogic forces recompile of EJBs when migrating from 9.2.1 to 9.2.3

I have a few EJBs compiled with Weblogic's EJBC complient with Weblogic 9.2.1.
Our customer uses Weblogic 9.2.3.
During server start Weblogic gives the following message:
<BEA-010087> <The EJB deployment named: YYY.jar is being recompiled within the WebLogic Server. Please consult the server logs if there are any errors. It is also possible to run weblogic.appc as a stand-alone tool to generate the required classes. The generated source files will be placed in .....>
Consequently, server start takes 1.5 hours instead of 20 min. The next server start takes exactly the same time, meaning Weblogic does not cache the products of the recompilation. Needless to say, we cannot recompile all our EJBs to 9.2.3 just for this specific customer, so we need an on-site solution.
My questions are:
1. Is there any way of telling Weblogic to leave those EJB jars as they are and avoid the re-compilation during server start?
2. Can I tell Weblogic to cache the recompiled EJBs to avoid prolonged restarts?
Our current workaround was to write a script that does this recompilation manually before the EAR's creation and deployment (by simply running java weblogic.appc <jar-name>), but we would rather avoid this solution being used in production.
I FIXED this problem by spending a great deal of time researching
and decompiling some classes.I encountered this when migrating from weblogic8 to 10
by this time you might have understood the pain in dealing with oracle weblogic tech support.
unfortunately they did not have a server configuration setting to disable this
You need to do 2 things
Step 1.You if you open the EJB jar files you can see
ejb-jar.xml=3435671213
com.mycompany.myejbs.ejb.DummyEJBService=2691629828
weblogic-ejb-jar.xml=3309609440
WLS_RELEASE_BUILD_VERSION_24=10.0.0.0
you see these hascodes for each of your ejb names.Make these hadcodes zero.
pack the jar file and deploy it on server.
com.mycompany.myejbs.ejb.DummyEJBService=0
weblogic-ejb-jar.xml=0
This is just a Marker file that weblogic.appc keeps in each ejb jar to trigger the recompilation
during server boot up.i automated this process of making these hadcodes to zero.
This hashcodes remain the same for each ejb even if you execute appc for more than once
if you add a new EJB class or delete a class those entries are added to this marker file
Note 1:
how to get this file?
if you open domains/yourdomain/servers/yourServerName/cache/EJBCompilerCache/XXXXXXXXX
you will see this file for each ejb.weblogic makes the hashcodes to zero after it recompiles
Note 2:
When you generate EJB using appc.generate them to a exploded directory using -output C:\myejb
instead of C:\myejb.jar.This way you can play around with the marker file
Step2.
Also you need a PATCH from weblogic.When you install the patch you see some message like this
"PATH CRXXXXXX installed successfully.Eliminate EJB recomilation for appc".
i dont remember the patch number but you can request weblogic for that.
You need to use both steps to fix the problem.The patch fixes only part of the problem
Goodluck!!
cheers
raj
the Marker file in EJBs is WL_GENERATED
Just to update the solution we went with - eventually we opted to recompile the EJBs once at the Customer's site instead of messing with the EJBs' internal markers (we don't want Oracle saying they cannot support problems derived from this scenario).
We created two KSH scripts - the first iterates over all the EJB jars, copies them to a temp dir and then re-compiles them in parallel by running several instances of the 2nd script which does only one thing: java -Drecompiler=yes -cp $CLASSPATH weblogic.appc $1 (With error handling of course :))
This solution reduced compilation time from 70min to 15min. After this we re-create the EAR file and redeploy it with the new EJBs. We do this once per several UAT environment creations, so we save quite a lot of time here (55min X num of envs per drop X num of drops)