I am following this fundamentals of JEE tutorial which provides instruction to create a minimal EJB deployment.
I have gone through the steps in the tutorials but made changes to the following command line invocations
>set CLASSPATH=.;E:\wildfly-10.1.0\wildfly-10.1.0.Final\bin\client\jboss-client.jar; (Changed from the long list in the tutorial)
>jar -cvf SimpleSessionApp.ear beans*.java (Changed file extention to .ear from .ejb3)
copy SimpleSessionApp.ear E:\wildfly-10.1.0\wildfly-10.1.0.Final\standalone\deployments (Copied to the wildfly deployment directory)
I started the server and I did not get any errors. However, I did not get set of standard names the server log outputs when a bean is deployed.
I ran the client application using the following command as in tutorial
>java -D java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -D java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces -D java.naming.provider.url=localhost client.SimpleSessionClient Now is the time for all good men
I get the following error as the output
Error: Could not find or load main class java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
I know the tutorial caters for an older version of Java and JBoss. However, I modified the old references to point to the newer environment as mentioned above. So I assume versioning is not a issue here? BTW I'm just starting to learn EJB. Any insights would be great.
My Environment
Java 1.8.0.212
Wildfly 10.1.0.Final
Notepad
You should look at the reference documentation https://docs.wildfly.org/17/Developer_Guide.html#JNDI_Remote_Reference as it seems your are passing wrong configuration parameters.
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
// the property below is required ONLY if there is no ejb client configuration loaded (such as a
// jboss-ejb-client.properties in the class path) and the context will be used to lookup EJBs
env.put("jboss.naming.client.ejb.context", true);
InitialContext remoteContext = new InitialContext(env);
RemoteCalculator ejb = (RemoteCalculator) remoteContext.lookup("wildfly-http-remoting-ejb/CalculatorBean!"
+ RemoteCalculator.class.getName());
Related
I'm running my Spring Boot application with Kubernetes. Part of the architecture involves mounting secrets as file volumes under /opt/config.
$ ls -l
SECRET_1
SECRET_2
SECRET_3
Each file contains a .properties like syntax. (key=value)
I've been attemtping to make Spring Boot load these as per the documentation spring.config.import=file:/etc/config/myconfig[.yaml]
However I just can't get this to work, my full command is: java -Dspring.config.location=file:./opt/application.properties -Dspring.config.additional-location=file:./opt/config/*[.properties] -jar target/test.war --debug --server.port=8080
The ./opt/application.properties file is loaded correctly.
I have also attempted to rename all the files to include .properties:
$ ls -l
SECRET_1.properties
SECRET_2.properties
SECRET_3.properties
And load it via java -Dspring.config.location=file:./opt/application.properties -Dspring.config.import=file:./opt/config/*/ -jar target/test.war --debug --server.port=8080, however this also did not import any of the properties under ./opt/config.
I've read through the documentation dozens of times now, and this should be working, but it's not. Did I miss something obvious? Why is it not loading any of the files under ./opt/config?
I think the problem is that the locations you specify are where spring looks for application.properties, application.yml and profile variants (application-prod.properties, etc). I think you are better off loading all the files in a configured location programmatically, this might provide some ideas.
My laptop just got upgraded to windows 10 from windows 7, and a piece of code stopped working. A large application using velocity templates which used to work on windows 7 just fine now cannot find the template files.
The templates are kept at the path WebContent\WEB-INF\config\templates under the project directory. An EngineInitializer class is used to load them. The code for the class is as follows:
private static Logger logger = Logger.getLogger(EngineInitializer.class);
private static String RELATIVE_PATH_FOR_TEMPLATES = "/WEB-INF/config/templates";
if(logger.isDebugEnabled())
logger.debug("About to initialize the Velocity Engine");
Properties p = new Properties();
String absolutePath=new File(Thread.currentThread().getContextClassLoader().getResource("").getFile()).getParentFile().getParentFile().getPath();//this goes to webapps directory
//configure the velocity logger to use the default logging
p.put(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,"org.apache.velocity.runtime.log.Log4JLogChute");
p.put("runtime.log.logsystem.log4j.logger", "defaultLog");
p.put("file.resource.loader.path", absolutePath + RELATIVE_PATH_FOR_TEMPLATES);
p.put("file.resource.loader.cache", "true");
p.put("file.resource.loader.modificationCheckInterval", "-1");
p.put("parser.pool.size", "30");
Velocity.init(p);
if(logger.isInfoEnabled())
logger.info("The velocity engine is now initialized..");
The following lines in the applicationBeans.xml file initializes the engine:
<!-- initialize the velocity engine before the listener thread starts -->
<bean id="engineInitializer" class="com.file.myprogram.template.processor.EngineInitializer"
init-method="initializeEngine" />
At the beginning, the log is getting printed. Inside the individual classes, the templates are called using Velocity.getTemplate() method. This is now returning a org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'MediationZone.vm' error. Nothing other than the underlying OS has been changed. This code runs fine on an RHEL server as a web app. Code has been downloaded from subversion and run on the windows 10 laptop using eclipse v4.9.
What is going wrong here?
I had the same issue and nothing worked (file:/ prefix variants, C: or c:).
Finally I tried it with some relative path (like used in the production environment) and voilĂ , it worked.
Figured out current run dir using System.getProperty("user.dir"):
vel.getTemplate( "foo/bar/some.vm", UTF_8.name() )
I tried to deploy a Vaadin hello world application in JBOSS. The application is as simple as it can be.
My development environment is eclipse for java EE + tomcat
java.lang.RuntimeException: Error configuring property: includeWebInfInClasspath for WarClassLoaderDeployer
at org.jboss.kernel.plugins.dependency.ConfigureAction.dispatchSetProperty(ConfigureAction.java:112)
at org.jboss.kernel.plugins.dependency.ConfigureAction.setAttributes(ConfigureAction.java:85)
(...)
Caused by: java.lang.IllegalArgumentException: No such property includeWebInfInClasspath for bean org.jboss.web.tomcat.service.deployers.WarClassLoaderDeployer available [java2ClassLoadingCompliance, parentFirst, requiredInputs, filteredPackages, allInputs, deploymentRegistry, class, stage, wantComponents, componentsOnly, input, inputs, relativeOrder, output, useUnitName, outputs, topLevelOnly]
I have tried to google this error with no success.
Does anyone have any clues?
Is it a web server configuration or my *.war is missing something?
EDIT:
This error occur when I start the server after placing my *.war in the folder.
My JBOSS version is 5
I guess, you're using an old JBoss 5.
The WarClassLoaderDeployer is configured in the file server/default/deployers/jbossweb.deployer/META-INF/war-deployers-jboss-beans.xml. (The 'default' directory should be changed to whatever you passed as -c parameter) Open the file, find the WarClassLoaderDeployer bean and drop the line defining the property with name includeWebInfInClasspath.
I have an application named HelloWorld installed, yet not deployed. Its state is Installed, like such:
When I'm trying to deploy it on target server, say AdminServer, it results in creating a new application named helloworld.war which is deployed on AdminServer whereas the original HelloWorld app remains in Installed state. App helloworld.war is the one that is in state Active... Snapshot:
Here's the code I use to deploy the already installed app:
File warFilePath = new File("c:/helloworld.war"); // war file path on AdminServer machine
Target adminServerTarget = deployManager.getTarget("AdminServer");
WebLogicTargetModuleID targetModuleID = deployManager.createTargetModuleID(
"HelloWorld", ModuleType.WAR, adminServerTarget);
WebLogicTargetModuleID[] targetModuleIDs = new WebLogicTargetModuleID[1];
targetModuleIDs[0] = targetModuleID;
ProgressObject redeployProcessObject =
deployManager.redeploy(targetModuleIDs, warFilePath, null /*no deployment plan*/ );
There are two surprising facts, though.
First, when running this code on WebLogic versions 9.x to 10.3.3 it works great.
Second, when running this code from WLST prompt, with jython it also works great even on version 10.3.4 (I can attach the exact commands although they're the same as java except for syntactic adoptions)...
My question is, how do I make it work also on 10.3.4?
I should have thought that no one would answer this question... :)
Anyway, I found a solution. I should have used deploy instead of redeploy, with a DeploymentOptions of which name is the existing application name (HelloWorld):
ProgressObject redeployProcessObject = null;
try {
final DeploymentOptions options = new DeploymentOptions();
options.setName(applicationName);
redeployProcessObject = deployManager.deploy(
targetModuleIDs, warFilePath, null /*no deployment plan*/, options);
} catch (TargetException e) {
final String message =
String.format("Deployment of application %s on target %s failed: %s",
applicationName, allTargets, e.getMessage());
_log.error(message, e);
}
According to the docs, redeploy only replaces the current application files and plan with an updated version. Whereas deploy distributes the files (from the AdminServer) to the target(s) and starts the application.
Also, after digging deep in WebLogic's jython scripts and jars I found out that this is exactly what's done when invoking redeploy in the WLST.
I am having trouble setting up the Php-Java Bridge setup properly.
I will explain what I have done.
My site is in pure php
For our payment transaction process we need to set up a php-java bridge
I followed this link to setup the bridge PHP-JAVA BRIDGE INSTALATION.
Here I learned that I need to have a private jvm to install the bridge.
So 1st i installed apache-tomcat-6.0.14 in Private JVM using my c-panel. After instalation it asked me to Map a domain to private JVM. So I mapped my domain example.com (which is the only option available) to it.
Then it asked to enable a traffic redirection from Apache web server to my Java application server (there was a check box and i clicked it)
Finally it asked me to deploy the WAR File (JavaBridge.WAR was my file) and everthing seems fine
Now when i go to http://example.com/JavaBridge/ I could see the javabridge examples and it works fine.
SO FAR SO GOOD
Now my problem starts here when I try to access a java class file from php. A sample test.php is what I create and put the following code into it.
<?php
require_once("http://example.com:portnumber/JavaBridge/java/Java.inc");
$System = java("java.lang.System");
echo $System->getProperties(); //This Part echo's correctly and shows the data so it means i can access Java.inc Correctly
$path_e24class = getcwd(). '/e24PaymentPipe.class'; //This part fails both test.php and java class file e24PaymentPipe.class are in the same directory in publich_html folder
java_require($path_e24class);
$pipe = new Java("e24PaymentPipe");
$pipe->setAction("1");
?>
My site contents reside in the public_html folder and the WAR file are deployed in private jvm.
These are the error message am getting.
1) Warning: java_require() not supported anymore. Please use tomcat or jee hot deployment instead
Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new e24PaymentPipe. Cause: java.lang.ClassNotFoundException: e24PaymentPipe VM: 1.6.0_22#http://java.sun.com/" at: #-10
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) #-9
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) #-8
java.lang.Class.forName0(Native Method) #-7
java.lang.Class.forName(Class.java:247) #-6
php.java.bridge.Util.classForName(Util.java:1518) #-5
php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:445) #-4
php.java.bridge.Request.handleRequest(Request.java:458) #-3
php.java.bridge.Request.handleRequests(Request.java:500) #-2
php.java.bridge.http.ContextRunner.run(ContextRunner.java:145) #-1
php.java.bridge.ThreadPool$Delegate.run(ThreadPool.java:60) #0
http://example.com:portnumber/JavaBridge/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(3, 'java.util.Prope...', 'T', false) #1
Finally I don't know much about the java. So am stuck here not knowing what to do.
Here is a great step by step tutorial you can follow, which shows everything required! It is a little old (2007) but helped me a while ago.
There is also another option. You can install Apache Tomcat and deploy your war there. You can have even multiple tomcat instances simultaneously with your httpd running at the same time on the same machine, as long as you respect the port settings. You can even front them with Apache httpd.
you can try this:
package your code to jar, and copy it to java.ext.dirs which you can found in JavaBridge.log
copy the related class libraries to java.ext.dirs
restart the service of JavaBridge
good luck!
<?php require_once("JavaBridge/java/Java.inc");
try {
$hd = new java("hdfs.HDFS");
$hd->get("hdfs://master:9000/user/hadoop/test-in/logo_cn.png", "/home/hadoop/1.png");
} catch (JavaException $ex) { echo "An exception occured: "; echo $ex; echo "<br>\n";}
?>
You can use this php implementation on github that works with php 5.3.
See credits on the git readme for more information.
You can try this; put the JavaBridge.jar in tomcat's lib folder e.g. apache-tomcat-7.0.12/lib.
Restart tomcat server and then,
$pipe = new java("com.aciworldwide.commerce.gateway.plugins.e24PaymentPipe");
$pipe->setAction("1");
This way I created the php version of the object.
Why don't you put the e24PaymentPipe class in your Java application's classpath and skip the two lines below:
// $path_e24class = getcwd(). '/e24PaymentPipe.class';
// java_require($path_e24class);
$pipe = new java("fully.qualified.classpath.e24PaymentPipe");
You are mixing PHP side and Java side operations. in theory the java_require (which is deprecated) was designed to work on the Java side. You are specifying a PHP side path.
You can save yourself a lot of grief by using a pure PHP implementation of the e24PaymentPipe library.
Disclaimer
The link is to my github repo of the library, but I did not write it. See the readme in for original credits.