Enhancing OpenJPA entity in runtime in jboss - jpa

I am not able to run my spring mvc+openjpa applicaton on jboss AS 7.1.x in my windows laptop.
After deployment when i execute it, it says -
org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance "com.caobusiness.selfcare.entity.DummyTable#1698b9" to PersistenceCapable failed. Ensure that it has been enhanced.
After searching, i found that open jpa entities needs to be enhanced either during built time or run time. I am trying to enhance entity during runtime using javaagent, but it fails.
my jboss standalone.conf looks like
#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.server.default.config=standalone.xml"
JAVA_OPTS="$JAVA_OPTS -javaagent:D:\openjpa-2.2.0.jar"
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi
I do not want to go for built time enhancement as of now. I have gone through posts stackoverflow post and why enhancement is needed
Will appreciate some leads.

Related

Wildfly 24, Java 11.0.11 adding external security provider

I'm trying to use external security provider, like nCipherKM on Wildfly24.0.0 and JDK 11.0.11, however with no luck so far.
I've configured standalone.conf with:
JDK_JAVA_OPTIONS="-cp /opt/nfast/java/classes/nCipherKM.jar"
and
JAVA_OPTS="$JAVA_OPTS $JDK_JAVA_OPTIONS"
And I see wildfly started with that classpath, however, when I want to use it with the application, I'm getting the following in the server.log:
java.security.NoSuchProviderException: no such provider: nCipherKM
In the java.security I have added:
security.provider.13=nCipherKM
Any ideas what I'm missing?
Thanks
After looking into the nCipher user guide I noticed that after I ran this:
`java --module-path /opt/nfast/java/classes com.ncipher.provider.InstallationTest
Installed providers:
1: SUN
2: SunRsaSign
3: SunJSSE
4: SunJCE
Unlimited strength jurisdiction files are installed.
The nCipher provider is not correctly installed.`
See, something is not correctly set in the java.security file.
So, instead just putting security.provider.13=nCipherKM I actually put
security.provider.13=com.ncipher.provder.km.nCipherKM
The result is:
java --module-path /opt/nfast/java/classes com.ncipher.provider.InstallationTest
Installed providers:
1: SUN
2: SunRsaSign
3: SunJSSE
4: SunJCE
5: nCipherKM
Unlimited strength jurisdiction files are installed.
The nCipher provider is installed, but is not registered at
the top of the providers list in the java.security file. See
the user guide for more information about the recommended
system configuration.
nCipher JCE services:
Alg.Alias.AlgorithmParameters.DESede
...
Then in the standalone.conf I used the exact --module-path option as I did for the installationTest, like this:
JDK_JAVA_OPTIONS="--module-path /opt/nfast/java/classes" JAVA_OPTS="$JAVA_OPTS $JDK_JAVA_OPTIONS"
And restarted wildfly service.
And, application can now reach the nCipherKM and the key loads with success! :)
Hope this helps someone out there.

DeploymentDescriptorLoadException: dd_in_ear_load_EXC

I have a WebSphere enterprise app. Manual deployment in the IBM admin console works with no issue, but with the wsadmin scripts and jython,
AdminApp.update('%APP_NAME%', 'app', '[ -operation update -contents %EAR_FILE% -usedefaultbindings -defaultbinding.virtual.host default_host -nopreCompileJSPs -installed.ear.destination $(APP_INSTALL_ROOT)/%WAS_HOST%Network -distributeApp -nouseMetaDataFromBinary -nodeployejb -createMBeansForResources -noreloadEnabled -%ws% -validateinstall warn -noprocessEmbeddedConfig -filepermission .*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755 -noallowDispatchRemoteInclude -noallowServiceRemoteInclude -asyncRequestDispatchType DISABLED -nouseAutoLink -noenableClientModule -clientMode isolated -novalidateSchema -MapModulesToServers [[ %MODULE_NAME% %WAR_FILE%,WEB-INF/web.xml WebSphere:cell=%WAS_HOST%Network,cluster=%CLUSTER%+WebSphere:cell=%WAS_HOST%Network,node=%WEB_NODE%,server=%WEB_NODE% ][ PobolEJB.jar PobolEJB.jar,META-INF/ejb-jar.xml WebSphere:cell=%WAS_HOST%Network,cluster=%CLUSTER%+WebSphere:cell=%WAS_HOST%Network,node=%WEB_NODE%,server=%WEB_NODE% ]]]' )
the following errors returns and the deployment failed:
com.ibm.websphere.management.application.client.AppDeploymentException:
com.ibm.websphere.management.application.client.AppDeploymentException:
[Root exception is
org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException:
dd_in_ear_load_EXC_]
org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException:
org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException:
dd_in_ear_load_EXC_
I verified the war file, the ejb jar file, the deployment descriptor (application.xml), they are all correct. In fact the same automated deployment job in jenkins worked till recently.
I have done lots research on the web, and also tests with no luck.
Your comments will be greatly appreciated.
Webshphere 1.8.5.5.16
JDK 1.8
x86_64 x86_64 x86_64 GNU/Linux
In my case, for the same error message, it turned out to be an error with ear metadata - application.xml referred to an module/jar that did not exist.

In Eclipse: How to set default VM arguments for a new server runtime?

I quite often have to update the server runtime in Eclipse's Servers View. For this, I import the standalone JBoss installation into the Servers View via:
New -> Server -> Red Hat Jboss EAP 7.x ...
Now, this server does not have enough heap space configured, so I have to open the Launch Configuration where the default VM arguments are defined. Then I change the heap from -Xmx512m to something like -Xmx4g.
I would have suspected this configuration to be in the jboss installation somewhere, but I have switched every occurence of -Xmx512m in every file to -Xmx4g without luck.
How can I change the default value to be -Xmx4g without changing it manually every time I have to import a new server runtime?
In Jboss, JVM configurations are placed under "Jboss Directory/bin/standalone.conf" (if your are running in standalone mode) .
Inside standalone.conf , you can find the JVM startup config
#
#Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi
You need to modify "JAVA_OPTS="-Xms64m -Xmx512m " to your requirements .
Hope this suits your need . Thanks.

Keycloak 4.8.0 Error when choosing standalone-ha.xml as --server-config parameter

We have keycloak 3.2.0 working on Docker.
When we run it, we add the ARGS --server-config standalone-ha.xml
e.g
Docker run foo bar jboss/keycloak:4.5.0.Final --server-config standalone-ha.xml
Purely because we're running a few nodes to the same DB
Upgrading to 4.5, the documentation here:
https://www.keycloak.org/docs/latest/server_installation/index.html#_standalone-ha-mode
Says, also add
--server-config standalone-ha.xml
However, when i do that (From version 4.0 onwards), i get
21:12:03,574 INFO [org.jboss.modules] (main) JBoss Modules version 1.8.6.Final
java.lang.IllegalArgumentException: WFLYSRV0191: Can't use both --server-config and --initial-server-config
at org.jboss.as.server.Main.assertSingleConfig(Main.java:395)
at org.jboss.as.server.Main.determineEnvironment(Main.java:169)
at org.jboss.as.server.Main.main(Main.java:96)
at org.jboss.modules.Module.run(Module.java:352)
at org.jboss.modules.Module.run(Module.java:320)
at org.jboss.modules.Main.main(Main.java:593)
21:12:03,973 FATAL [org.jboss.as.server] (main) WFLYSRV0239: Aborting with exit code 1
Now, if i run keycloak WITHOUT --server-config, and i enter the container, PS AUX shows its running standalone-ha.xml as config.
But thats because we are migrating from a DB which has 3.2.0 previously installed.
How do i enable and constantly make sure that standalone-ha.xml gets selected by passing parameter --server-config to choose the *-ha.xml configuration?
Thanks
It is a problem in Keycloak. Using -c instead of --server-config helps.
See https://issues.jboss.org/browse/KEYCLOAK-9393 for more details.

Error running hadoop application in Eclipse on Windows

I'm trying to set up an Eclipse environment for developing and debugging hadoop. I'm following Tom White's Definitive Hadoop 3rd ed. What I would like to do is get the MaxTemperature app working locally on my Windows within Eclipse before moving it to my Hortonworks sandbox VM. The comment on page 158 about using the local job runner seems to be what I want. I don't want to set up a full hadoop implementation on Windows. I'm hoping with the right config params I can convince it to run as a java application inside Eclipse.
Windows: 7
Eclipse: Luna
Hadoop: 2.4.0
JDK: 7
When I set the Run configuration for MaxTemperatureDriver (Source code on page 157) to
inputfile outputdir foo (deliberate bogus 3rd parameter)
I get the usage message so I know I'm running my program with those params.
If I remove the bogus third param I get
Exception in thread "main" java.io.IOException: Cannot initialize Cluster. Please check your configuration for mapreduce.framework.name and the correspond server addresses.
at org.apache.hadoop.mapreduce.Cluster.initialize(Cluster.java:120)
at org.apache.hadoop.mapreduce.Cluster.<init>(Cluster.java:82)
at org.apache.hadoop.mapreduce.Cluster.<init>(Cluster.java:75)
at org.apache.hadoop.mapreduce.Job$9.run(Job.java:1255)
at org.apache.hadoop.mapreduce.Job$9.run(Job.java:1251)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1548)
at org.apache.hadoop.mapreduce.Job.connect(Job.java:1250)
at org.apache.hadoop.mapreduce.Job.submit(Job.java:1279)
at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1303)
at mark.MaxTemperatureDriver.run(MaxTemperatureDriver.java:52)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84)
at mark.MaxTemperatureDriver.main(MaxTemperatureDriver.java:56)
I've tried inserting -conf but it seems to be ignored. There is no error message if I specify a nonexistent path.
I've tried inserting -fs file:/// -jt local, but it makes no difference
I've tried inserting -D mapreduce.framework.name=local
I've tried specifying the input and output with the file: format
Note. I'm not asking about how to configure eclipse to connect to a remote Hadoop installation. I want the application to run within eclipse.
Is this possible? Any ideas?
Additional info:
I turned on debugging. I saw:
582 [main] DEBUG org.apache.hadoop.mapreduce.Cluster - Trying ClientProtocolProvider : org.apache.hadoop.mapred.YarnClientProtocolProvider
583 [main] DEBUG org.apache.hadoop.mapreduce.Cluster - Cannot pick org.apache.hadoop.mapred.YarnClientProtocolProvider as the ClientProtocolProvider - returned null protocol
I'm wondering not why YarnClientProtocolProvider failed, but why it didn't try LocalClientProtocolProvider.
New info:
It seems that this is an issue with Hadoop 2.4.0. I recreated my environment with Hadoop 1.2.1, followed the instructions in
http://gerrymcnicol.com/index.php/2014/01/02/hadoop-and-cassandra-part-4-writing-your-first-mapreduce-job/
added the Windows hack from
http://bigdatanerd.wordpress.com/2013/11/14/mapreduce-running-mapreduce-in-windows-file-system-debug-mapreduce-in-eclipse
and it all started working.
Following blog will be useful.
Running mapreduce in Windows filesystem