Can't contact EJB from remote machine - java

As title says, I can't contact my EJB from a distant machine. The client trying to contact the EJB-hosting machine works perfectly when used locally.
The remote machine is on Windows XP SP3 (32 bits) with Java JRE 7_71. It's connected to the same network as the machine running the EJB on a Glasshfish server.
The second machine (which is running the Glasshfish server) runs on Win7 x64. Are installed JDK 1.7_75, JDK 1.8_25, jre1.8.0_25 and JRE 7_71.
All firewalls are disabled. No proxies used. Just 2 machines behind a router connected to internet.
I'm programming with NetBeans 8.0.2, with a Glasshfish server 4.1.
Here's what it looks like :
http://imgur.com/zl05ACG
"ABEJB" is my EJB. In Properties > Sources, the "Source / Binary Format is JDK 7. In Properties > Libraries, I added the JDBC driver (works well) and set the Java Platform to "JDK 1.7".
Note : When I'm deploying my EJB on Glassfish, I got these infos :
Infos: Portable JNDI names for EJB AJoyfulBean: [java:global/ABEJB/AJoyfulBean!EJB.NewSessionBeanRemote, java:global/ABEJB/AJoyfulBean]
Infos: Glassfish-specific (Non-portable) JNDI names for EJB AJoyfulBean: [ABS/AJoyfulBean#EJB.NewSessionBeanRemote, ABS/AJoyfulBean]
NewSessionBean.java :
#Stateless(name = "AJoyfulBean")
public class NewSessionBean implements NewSessionBeanRemote
{
#Override
public String testConnexion()
{
String retour = "Connected to : " + System.getenv("COMPUTERNAME");
try
{
retour += " / " + InetAddress.getLocalHost();
}
catch (UnknownHostException ex)
{
retour += "unknown IP ! :(";
}
return retour;
}
}
NewSessionBeanRemote.java
#Remote
public interface NewSessionBeanRemote
{
String testConnexion();
}
sun-ejb-jar.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>AJoyfulBean</ejb-name>
<jndi-name>ABS/AJoyfulBean</jndi-name>
</ejb>
</enterprise-beans>
</sun-ejb-jar>
"A Better Stock" is my Java application on a remote machine. In Properties > Sources, the "Source / Binary Format is JDK 7. In Properties > Libraries, I added the "Java EE from GlassFish" libraries from NetBeans and the "gf-client.jar" from the Glassfish installation repertory. The Java Platform is set to "JDK 1.7".
The EJB interface is the same as my EJB (I don't get a Marchal exception anyway).
Inside a static method on my main class :
try
{
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.1.164"); // the IP of the machine hosting the glassfish server
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ctx = new InitialContext(props);
NewSessionBeanRemote myEJB = (NewSessionBeanRemote) ctx.lookup("java:global/ABEJB/AJoyfulBean!EJB.NewSessionBeanRemote"); // Tried "ABS/AJoyfulBean#EJB.NewSessionBeanRemote" too
jTextAreaInformations.setText(jTextAreaInformations.getText() + "\n" + myEJB.testConnexion());
}
catch (Exception ex)
{
jTextAreaInformations.setText(jTextAreaInformations.getText() + "\n" + ex.toString());
}
MANIFEST.MF :
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.4
Created-By: 1.8.0_25-b18 (Oracle Corporation)
Class-Path: lib/javax.annotation-api.jar lib/jaxb-api.jar lib/webservi
ces-api-osgi.jar lib/bean-validator.jar lib/javax.batch-api.jar lib/j
avax.ejb-api.jar lib/javax.el.jar lib/javax.enterprise.concurrent-api
.jar lib/javax.enterprise.concurrent.jar lib/javax.enterprise.deploy-
api.jar lib/javax.faces.jar lib/javax.inject.jar lib/javax.intercepto
r-api.jar lib/javax.jms-api.jar lib/javax.json.jar lib/javax.mail.jar
lib/javax.management.j2ee-api.jar lib/javax.persistence.jar lib/java
x.resource-api.jar lib/javax.security.auth.message-api.jar lib/javax.
security.jacc-api.jar lib/javax.servlet-api.jar lib/javax.servlet.jsp
-api.jar lib/javax.servlet.jsp.jar lib/javax.servlet.jsp.jstl-api.jar
lib/javax.servlet.jsp.jstl.jar lib/javax.transaction-api.jar lib/jav
ax.websocket-api.jar lib/javax.ws.rs-api.jar lib/javax.xml.registry-a
pi.jar lib/javax.xml.rpc-api.jar lib/jaxb-osgi.jar lib/webservices-os
gi.jar lib/weld-osgi-bundle.jar lib/jaxm-api.jar lib/gf-client.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: a.better.stock.UI.Accueil
When I'm running the .jar file of my client (with the /lib folder) on the machine hosting the glassfish server, my EJB is contacted and correctly do the tasks required (updating SQL tables).
But when I copy the .jar file and /lib folder to the distant machine and execute it, it get this exception :
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory
[Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
So basically, why am I getting this exception ? I'm giving the context. And anyway, it works on local but not on remote client. Weird.

how do you start your client? from which directory? the same as on your local directory? perhaps it could be that your class path of your client is not correct? or even incomplete?
i think it could be that some jar files from lib/ folder require other jars in the correct folder structure. you can see that for example in the appserv-rt.jar/META-INF/MANIFEST.MF. there you can find the "Class-Path: ../lib/gf-client.jar" entry. the solution could be that you run your client from within the lib/ folder or from within the bin/ directory as glass fish does..

please check if your container (glassfish) is listening on port 3700.
on windows http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/netstat.mspx?mfr=true
netstat -a -n -o
if it is running, try a telnet to the port
telnet <yourglassfishIP> 3700
If you can type anything and the telnet does not terminate immediately your port is open.
In case of open port, check if you have configured glassfish to accept remote EJB calls.

Related

WebLogic 11 WLST redeploy behavior

I am trying to setup production redeployment on WebLogic 11 using WLST.
Applications, that I am using for that are standard oracle simple applications:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/wls/12c/14-Redeployment--4465/redeploy.htm
As first, I've deployed simple.war from /tmp/deployversion1/simple.war, and it was deployed successfully.
That simple.war has MANIFEST.MF:
Manifest-Version: 1.0
Class-Path:
Created-By: Bill Bell
Weblogic-Application-Version: v1
Then, I've tried to deploy simple.war with v2 version. It has manifest:
Manifest-Version: 1.0
Class-Path:
Created-By: Bill Bell
Weblogic-Application-Version: v2
From the Oracle documentation, if manifest has a version inside of it, I may not provide versionIdentifier parameter for deploy/redeploy.
And it works for WebLogic 12.
My WLST code, thar doing the redeployment is:
redeploy(appName = 'Simple', appPath = '/tmp/deployversion2/simple.war')
After it I found, that application wasn't deployed, and in weblogic log:
<Dec 21, 2016 3:11:07 PM PST> <Error> <Deployer> <BEA-149091> <An attempt was made to deploy application 'Simple' with specified archive version 'v1'. However, the application archive as specified in the source has version 'v2'.>
But if I doing redeploy this way(versionIdentifier provided), it works fine:
redeploy(appName = 'Simple', appPath = '/tmp/deployversion2/simple.war', versionIdentifier='v2')
Also, it works if I doing deploy again, even without version:
deploy(appName = 'Simple', appPath = '/tmp/deployversion2/simple.war')
And, finally, it works if application is being deployed with weblogic.Deployer:
java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic -password ******** -redeploy -source /tmp/deployversion2/simple.war -name Simple
So, I have few questions about it.
1) How can I do production redeployment using WLST for WebLogic 11 and WebLogic 12 with one script?
2) Why WLST redeploy fails, but weblogic.Deployer -redeploy works fine, if parameters are the same?
3) What the difference between deploy and redeploy, if deploy result for WebLogic 12 is exactly the same as redeploy result?
4) Can I use for WebLogic 11 deploy() instead of redeploy() to avoid BEA-149091 error?
Thanks.

how to connect jetty server with solr instance

I'm running Jetty as a service (followed these instructions) on an Ubuntu 14 server. It's been configured to run on port 9000, and it seems to this just fine.
On the same server, I have a solr instance folder (it's located outside of jetty, as part of a website).
What I would like, is to be able to browse to hostname:9000/solr and hostname:9000/solr/admin and then see/manage the data that's in my solr instance folder, but all I ever get from the Jetty service are 404-errors.
The instance itself works perfectly if I start it manually by running 'java -Djetty.port=9000 -jar start.jar' - however, this is not what I want.
What do I need to do?
Edit: Here is the output from service jetty check
root#ubuntu14:/opt/web/mybase/webapps# service jetty check
Checking arguments to Jetty:
START_INI = /opt/web/mybase/start.ini
JETTY_HOME = /opt/jetty/jetty-distribution-9.2.7.v20150116
JETTY_BASE = /opt/web/mybase
JETTY_CONF = /opt/jetty/jetty-distribution-9.2.7.v20150116/etc/jetty.conf
JETTY_PID = /var/run/jetty.pid
JETTY_START = /opt/jetty/jetty-distribution-9.2.7.v20150116/start.jar
JETTY_LOGS = /opt/web/mybase/logs
JETTY_STATE = /opt/web/mybase/jetty.state
CLASSPATH =
JAVA = /usr/bin/java
JAVA_OPTIONS = -Dsolr.solr.home=/var/www/mywebsite/private/my-solr-4.7 -Djetty.logs=/opt/web/mybase/logs -Djetty.home=/opt/jetty/jetty-distribution-9.2.7.v20150116 -Djetty.base=/opt/web/mybase -Djava.io.tmpdir=/opt/jetty/temp
JETTY_ARGS = jetty.state=/opt/web/mybase/jetty.state jetty-logging.xml jetty-started.xml
RUN_CMD = /usr/bin/java -Dsolr.solr.home=/var/www/mywebsite/private/my-solr-4.7 -Djetty.logs=/opt/web/mybase/logs -Djetty.home=/opt/jetty/jetty-distribution-9.2.7.v20150116 -Djetty.base=/opt/web/mybase -Djava.io.tmpdir=/opt/jetty/temp -jar /opt/jetty/jetty-distribution-9.2.7.v20150116/start.jar jetty.state=/opt/web/mybase/jetty.state jetty-logging.xml jetty-started.xml
Jetty running pid=4728
First make sure you have deployed the solr.war file correctly into Jetty as described here. Basically you have 2 options -
Copy the war file into the JETTY_HOME/webapps directory
Add the war file path into $JETTY_HOME/contexts/context.xml file
This will deploy Solr into jetty.
To run Solr, set the Dsolr.solr.home system property to point to your Solr root directory e.g. java -Dsolr.solr.home= -jar start.jar

Unable to access the resource from Tomcat server in windows

On machine1, I installed apache tomcat 7 listening on port 9999 and copied a sample.html file in ../webapps/dummy folder of tomcat machine.I was able to access the resource with URL http://localhost:9999/dummy/sample.html
On machine2, Tomcat is already part of some product listening on port 8080 which i thought of utilising it for my sample test. So, I copied a sample.html file in ../webapps/dummy folder of tomcat machine. I was unable to access the resource with URL http://localhost:8080/dummy/sample.html
On machine2, I have existing servlet programming modules running in another folder ../webapps/xyz.
My question:
I am trying to understand, What are the list of things that i need to verify on machine, which let me know, why i have an issue in accessing the URL(above) on machine2? Is this something to do with http access configuration like basic.user/basic.groups file?
It has nothing to do with the port on which tomcat is running.
Did you restart Tomcat after copying file over? It might be that on machine2 it's not configured to run in a dev mode so it doesn't pick up changes at runtime.
or
(if this is linux/unix/mac computer) Tomcat on machine2 is running as tomcat:tomcat user, but file you copied can't be read by this user. Change the permissions of the file.
HTH,
Jan

Exception while Deploying ear on glassfish server of amazon cloud

we are working on java technology and we have created enterprise application in java. we also created the instances on amazon aws. we have the following hosts for our web enterpeise application on amazon
SERVER AMAZON= ec2-54-235-50-8.compute-1.amazonaws.com
MYSQL= mysqld#ec2-23-23-65-23.compute-1.amazonaws.com
we have created the JDBC connection pool on glassfish as follows
when i ping the jdbc connetction pool it is giving the following exception "Class Name is wrong or class path is not set for com.mysql.jdbc.MySqlDataSource".
Try this:
cd ./glassfish3/glassfish/domain/domainl/lib
wget http://mysql.llarian.net/Downloads/Connector-J/mysql-connector-java-5.1.18.zip
unzip mysql-connector-java-5.1.18.zip
mv ./glassfish3/glassfish/domain/domainl/lib/mysql-connector-java-5.1.18/mysql-connector-java-5.1.18-bin.jar ./glassfish3/glassfish/domain/domainl/lib
By this u will get mysql-coonector-java.jar file in lib folder.
is mysql connector should be in your glassfish domain lib dir. It seems glassfish cannot find it.
glassfish-install-dir\glassfish\domains\domain1\lib

How do I upgrade this embedded tomcat?

I want to basically upgrade my tomcat version(on RHEL).
Always worked in an environment where my war file would be dumped into */webapps, on restart of tomcat, the war file would expand and the rest is history.
Now, the system I'm working on, has completely different folder structure.
Something like this:
[root#bliss ~]# ls /usr/local/blah/blu-app/WEB-INF/
accounts faces-reports.xml logging.properties web-app_2_3.dtd
bin faces-syscfg.xml logging.properties-production web-app_2_4.xsd
buildnum.txt framework2007 perl web.xml
classes host.xsd settings work
deploy-root java.policy tags
events.xsd lib tld
[root#bliss ~]#
I can see some tomcat related jars here:
/usr/local/blah/blu-app/WEB-INF/lib/tomcat-http.jar
/usr/local/blah/blu-app/WEB-INF/lib/tomcat-util.jar
/usr/local/blah/blu-app/WEB-INF/lib/tomcat-coyote.jar
UPDATE
So I did find out that the tomcat is embedded 'cuz I found the following code starting it:
tomcat = new Embedded();
tomcat.setCatalinaHome(targetPath);
Host host = tomcat.createHost("localhost", targetPath);
Context rootCtx = tomcat.createContext("", targetPath);
((StandardContext)rootCtx).setWorkDir("WEB-INF/work");
ServletContext servletContext = rootCtx.getServletContext();
servletContext.setAttribute("version", version);
ApplRealm realm = new ApplRealm(servletContext);
tomcat.setRealm(realm);
rootCtx.setPrivileged(true);
Engine engine = tomcat.createEngine();
engine.setName("tomcat");
engine.setDefaultHost("localhost");
host.addChild(rootCtx);
engine.addChild(host);
tomcat.addEngine(engine);
LOG.debug("starting tomcat");
tomcat.start();
LOG.debug("tomcat started");
// clear out any old sessions: see bug 17882
Session[] sessions = rootCtx.getManager().findSessions();
for (int i = 0; i < sessions.length; i++)
{
sessions[i].expire();
}
ServerSocket socket = null;
socket = new ServerSocket(CmcUtils.getControlPort(), 2, InetAddress.getByName("127.0.0.1"));
socket.accept();
LOG.info("Received shutdown command. Exiting !");
tomcat.stop();
The question then is, how do I upgrade this tomcat to say Tomcat6?
Replace with the latest jars in WEB-INF/lib? Which all jars?
It depends. It could be an embedded tomcat but it could also be a heavily customised tomcat configuration.
Check the startup script to determine which class is being invoked. If its the usual catalina its not embedded its just that they changed the config to point to another folder instead of webapps.
If it is indeed embedded then to upgrade u would need to replace the tomcat jars with new ones.
In tomcat we can create virtual hosts,i.e, making tomcat recognize application's which are deployed in external folders.
A lot more information can be found here.
http://tomcat.apache.org/tomcat-5.5-doc/config/host.html
In your given scenario, try to lookup in server.xml, which is usually found in conf folder of tomcat home.

Categories

Resources