Quantcast
Channel: Java mon amour
Viewing all 1124 articles
Browse latest View live

WebLogic Administrator Questions

$
0
0
How can you see if your OS is running a 64 or 32 bit OS

Can you explain me the basic Linux directory structure (/var/log/, /etc, /opt. /dev, /users)

How can you see how much disk space is left

Can you see what processes are running

Name some scheduling techniques

What is VM ware, have you ever worked with it, name some vendors

how do you check the hostname of a machine

Can you explain me something about Domain Names, how can you override domain names

Name some infrastructure monitoring software (Nagios/ Big Brother/ HP Open View)

Would you mind to explain me what a Proxy service is?

Would you mind to explain me what Business service is?

What are JMX Beans, what to they do …how can we use it

Name some Monitoring Best Practices for Middleware environments

Name some Monitoring Products for Middleware environments

How is your knowledge of Oracle Enterprise Manager and or Grid Control

What is the difference between tablespace/ schema

What is the difference between active and passive FTP

What is the difference between SFTP and FTPS

Name some Configuration Management Systems, (Puppet / CFEngine) have you ever worked with it

Do an analysis of a problem in a 4 tier system…from frontend to backend…where do you start/ escalate

What can you tell about SMNP, (trap destination/ trap translator)
How would you create and monitor a JMS queue with scripts? (hint: WLST, eventually Java)

Can you start and stop a WebLogic server from WLST, and how? (hint: nmConnect, nmStart, Node Manager)

Which options do you have to target a JMS queue? (hint: cluster, individual WLS server, individual JMS server, subdeployments)

Why would you use a Distributed Queue? (hint: high availability, load balancing)

How do you ensure that operations can continue without disruption even if a WLS instance goes down
(hint: cluster, whole server migration, service migration, load balancing with failover)

How to you check for Stuck Threads in WLS (hint: thread dump)

How do you update a Deployment (deployment plan)

Which are some common JCA Adapter and how do you set them up (hint: FTPAdapter, FileAdapter)

How to verify which Patches are applied to WLS, and how to apply a new Patch ?

How do you change the log properties? Which are the main logs you have for weblogic and osb?

Which metrics would you monitor in WLS for a JDBC Data Source?

What does a 'lock' mean when you startup weblogic? How to solve it?

In linux what command tells you the dependencies of a .so file

How can you see what processes are holding which ports (hint netstat -antpu)

Can you explain something about certificates (SSL technology , hint : public private key)

Can you explain me something about ORM (Object Relational Mapping)

Name some storage technologies (RAID - vs Striped), what are the advantages disadvantages

What can you tell about ORACLE RAC technology

How do you configure a UnitofOrder in Weblogic?A persistent store? A remotequeue?

Is it possible a Managed server continue providing services in spite of shutting down the admin server? How to?

SOA Architect Questions

$
0
0
How would you monitor a WebLogic instance (hint: console, Nagios/ Oracle Enterprise Manager and or Grid Control/ HP Open View)

Need for SOA Governance?

Have you read some EAI books, and which EAI patterns do you remember?

Do you know which are the main internal variable in OSB?( Hint: body, inbound, outbound)

If a process is long running, with human interaction, how would you manage it? (hint asynchronous)

Explain me how you would handle errors in OSB (hint: eror handler stage level, proxy level, …)

How do you monitor performance and response time and Errors using the OSB console? (hint SLA -Alert, logging and reporting actions)

What is a fault in OSB? How is represented? (hint: $fault details, ….)

Which problem do you face when deploying an integration solution to a new environment, and how do you solve this (customization plans/files)

When is it necessary to apply compensation? (hint error handling, non transactional)

Which features are available in BPEL which are not in a general purpose programming language like Java?

How would you test an integration solution?

What is JNDI?

You have a CSV or EDI file, how do you tranform it in XML?

What is Oracle RAC? How do you configure WebLogic to take advantage of RAC (hint: Multidatasource)

Which options do you have to enforce data integrity in a DB (constraints, triggers, range check, not null, foreign keys)

What is a WSDL?

How can we reuse services?

How would you configure WebLogic domains without using manual operations (hint: WLST, domain templates)

Difference between a Proxy service and Business Service?

What are JMX Beans, what to they do …how can we use it

How would you create and monitor a JMS queue with scripts? (hint: WLST, eventually Java)

Can you start and stop a WebLogic server from WLST, and how? (hint: nmConnect, nmStart, Node Manager)

Which options do you have to target a JMS queue? (hint: cluster, individual WLS server, individual JMS server, subdeployments)

How do you ensure that operations can continue without disruption even if a WLS instance goes down
(hint: cluster, whole server migration, service migration, load balancing with failover)

How do you change the log properties? Which are the main logs you have for weblogic and osb?

Which metrics would you monitor in WLS for a JDBC Data Source?

How would you implement the following integration interface?
. Our source system is sending the requests via FTP (it writes into ftp) and the target destination is a database. (hint database and ftp adapters).
. we want the implementation not to manage the connection details to the ftp or the database (JCA)
. We want messages to be persisted (persistent stores, jms queues)
. control error (error handler strategies)
. monitor the execution (tracking actions logging messages) end to end (messages id)
. in case something is failing we want ensure the database integrity so if we update the database and before ending the process something fails we want the database to be back to the original status( XA)
. The source message has a different format than the target (hint: xquery, xslt)
. we want to ensure that messages are processed in order (sequences, unit of order)
. We need to ensure that the message we send and we receive is valid according to the input and output schemas (hint validate actions)
. While mapping the values some of them , for example currency or country codes are represented in a different format in each system. For example EURO and EUR, POUND and PND, ... (Hint: domain value mapping)
. We want the service to be reused and accessible from multiple systems (service registry and service repository)
. Finally we would like to have the schemas in a repository (metadata repository) "
Please explain how to create a queue in FIFO mode in Weblogic? (Hint :one consumer)

What is a Canonical Data model? (hint common data, reusability)

Would you mind to explain the difference between async and synch behaviour?

Can you explain me something about ORM (Object Relational Mapping)

How do you ensure that a request is persisted and executed even in case of system crash (hint: persistence, transactions)

What is a transactional resource? What is a XA interface?

How do you configure a UnitofOrder in Weblogic? A persistent store? A remotequeue?

Is it possible a Managed server continue providing services in spite of shutting down the admin server? How to?

OSB Cluster

$
0
0
Create a new Domain, using the "OSB Production" template
Create it in "Production" mode
Create MS osb_server1 and osb_server2 and put them into a cluster.

You will notice that this deployment:

"ALSB Cluster Singleton Marker Application" is targeted to osb_server1

wlsbJMSServer_auto_1 and 2 are targeted to osb_server1 and 2

WseeJmsServer_auto_1 and 2 are targeted to osb_server1 and 2

wli.reporting.purge.queue is deployed to wlsbJMSServer_auto_1

all the reporting, email file ftp sftp transport JMS queues are created as Distributed Destinations and targeted to the cluster
(wlsb.internal.transport.task.queue.ftp_auto_1, wlsb.internal.transport.task.queue.sftp_auto_1, wlsb.internal.transport.task.queue.email_auto_1, wlsb.internal.transport.task.queue.file_auto_1, QueueIn_auto_1, wli.reporting.jmsprovider.queue_auto_1, wli.reporting.jmsprovider_error.queue_auto_1)


DefaultCallbackQueue-WseeJmsServer_auto_1/2 and DefaultQueue-WseeJmsServer_auto_1/2 are deployed to either server



see here


for File, FTP, email:
"the poller on only one managed server will poll for a given proxy service"

WebLogic cluster in Unicast mode

$
0
0
http://weblogic-wonders.com/weblogic/2010/12/17/comparison-between-cluster-multicast-messaging-and-unicast-messaging-mode/


"For the member servers in the cluster, group leaders are chosen and only those group leaders communicate with the servers among the group and these leaders notify each other about the availability of all the other servers.
For example : Suppose there are 6 servers in the cluster. 2 groups are made and there are 2 group leaders. Other 2 servers of the group will notify their leader that they are alive and the group leader will send this information to the leader of other group."


Basically there can be multiple leaders. On the "monitoring" tab of the cluster you see:

"Local Group Leader"
"Total Groups"
"Discovered Group Leaders"
"Groups"


Unicast prefers a "private" network channel
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/config_wls/network.html
This in order to separate JNDI traffic from cluster traffic.

Here is says explicitly that you must set the listen address on the CLUSTER-BROADCAST channel.
The book Professional Oracle WebLogic Server says that WebLogic supports TCP/IP-based unicast or UDP-based multicast.
This book explains VERY well the Cluster Topologies and Unicast mode, at Chapter 12: Administering and Deploying Applications.


Why Groups are formed and change over time?
Here is what WebLogic documentation says http://download.oracle.com/docs/cd/E11035_01/wls100/cluster/features.html:

"Cluster members communicate to the group leader when they need to send a broadcast message which is usually the heartbeat message. When the cluster members detect the failure of a group leader, the next oldest member becomes the group leader."


"If the group leaders
become overloaded, this can lead to cluster members dropping out and rejoining the cluster frequently."

"we have found that if your connection between the data centers has a tendency to lose packets or the latency is over a few hundred milliseconds, this can
cause problems with WebLogic Server’s clustering mechanisms. Prefer architectures that do not require using WebLogic Server clusters that span data centers."




What is Unicast?

http://publib.boulder.ibm.com/infocenter/wllm/v2r0/index.jsp?topic=/com.ibm.wllm.doc/wllmover_multiuni.html
There is Unicast UDP and Unicast TCP.

This article explains the Groups formed when in Unicast

This article shows some Network communication topologies http://en.wikipedia.org/wiki/Unicast

Digging in JNDI

$
0
0
JNDI is a bit of a mystery for me...whenever I get an exception like:

javax.naming.NameNotFoundException: While trying to look up comp/env/jms/CF1 in /app/webapp/rocAdmin/1482669104.; remaining name "comp/env/jms/CF1" at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1180) at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:143) at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:253) at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:426) at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45) at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130) at javax.naming.InitialContext.lookup(InitialContext.java:411) ...

I scratch my head ... So I wrote some code to dump the content of the InitialContext (it runs in a EJB timer to avoid having to create a client:

package com.pierre;

import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.ejb.Timer;
import javax.naming.Binding;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;

@Stateless
public class PVTimer {

/**
* Default constructor.
*/
public PVTimer() {
// TODO Auto-generated constructor stub
}

@SuppressWarnings("unused")
@Schedule(second = "*/10", minute = "*", hour = "*", dayOfWeek = "*", dayOfMonth = "*", month = "*", year = "*", info = "MyTimer")
private void scheduledTimeout(final Timer t) {
System.out.println("@Schedule called at: " + new java.util.Date());
try {
System.out.println();
InitialContext ic = new InitialContext();
NamingEnumeration names = ic.listBindings("");
printNames(names, "all");
NamingEnumeration jms = ic.listBindings("jms");
printNames(jms, "jms");
System.out.println();
} catch (Throwable t1) {
t1.printStackTrace();
}

}

private void printNames(NamingEnumeration names, String title)
throws NamingException {
int count = 1;
while (names.hasMore()) {
Binding next = names.next();
System.out.println(title + "" + count + " ToString=" + next.toString() + " Name=" + next.getName() + " Classname=" + next.getClassName() + " getObject=" + next.getObject());
count++;
}
}
}


and this is the result:


all 1 ToString=weblogic: weblogic.jndi.internal.WLEventContextImpl:EventContext (weblogic) Name=weblogic Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (weblogic)
all 2 ToString=__WL_GlobalJavaApp: weblogic.jndi.internal.WLEventContextImpl:EventContext (__WL_GlobalJavaApp) Name=__WL_GlobalJavaApp Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (__WL_GlobalJavaApp)
all 3 ToString=PVEarPVEjbProject_jarPVStateless_PVStatelessRemote: com.pierre.PVStateless_fcmphc_PVStatelessRemoteImpl:com.pierre.PVStateless_fcmphc_PVStatelessRemoteImpl@e964ee Name=PVEarPVEjbProject_jarPVStateless_PVStatelessRemote Classname=com.pierre.PVStateless_fcmphc_PVStatelessRemoteImpl getObject=com.pierre.PVStateless_fcmphc_PVStatelessRemoteImpl@e964ee
all 4 ToString=ejb: weblogic.jndi.internal.WLEventContextImpl:EventContext (ejb) Name=ejb Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (ejb)
all 5 ToString=jms: weblogic.jndi.internal.WLEventContextImpl:EventContext (jms) Name=jms Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (jms)
all 6 ToString=PVEarPVEjbProject_jarPVStateless_Home: weblogic.ejb.container.internal.StatelessEJBHomeImpl:weblogic.ejb.container.internal.StatelessEJBHomeImpl@f229af Name=PVEarPVEjbProject_jarPVStateless_Home Classname=weblogic.ejb.container.internal.StatelessEJBHomeImpl getObject=weblogic.ejb.container.internal.StatelessEJBHomeImpl@f229af
all 7 ToString=javax: weblogic.jndi.internal.WLEventContextImpl:EventContext (javax) Name=javax Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (javax)
all 8 ToString=java:global: weblogic.jndi.internal.WLEventContextImpl:EventContext (java:global) Name=java:global Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (java:global)
all 9 ToString=mejbmejb_jarMejb_EO: weblogic.management.j2ee.mejb.Mejb_dj5nps_EOImpl:ClusterableRemoteRef(4485985896511196818S:169.254.152.121:pvdomain:AdminServer [4485985896511196818S:169.254.152.121:pvdomain:AdminServer/294])/294 Name=mejbmejb_jarMejb_EO Classname=weblogic.management.j2ee.mejb.Mejb_dj5nps_EOImpl getObject=ClusterableRemoteRef(4485985896511196818S:169.254.152.121:pvdomain:AdminServer [4485985896511196818S:169.254.152.121:pvdomain:AdminServer/294])/294
all 10 ToString=_WL_internal_0Z7vb3dMvYJ62jEwg8odDkTCYHT0HwjvQwlqEb8FYeA1jZjPDZBGLEATyZk7rdEu: weblogic.jndi.internal.WLEventContextImpl:EventContext (_WL_internal_0Z7vb3dMvYJ62jEwg8odDkTCYHT0HwjvQwlqEb8FYeA1jZjPDZBGLEATyZk7rdEu) Name=_WL_internal_0Z7vb3dMvYJ62jEwg8odDkTCYHT0HwjvQwlqEb8FYeA1jZjPDZBGLEATyZk7rdEu Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (_WL_internal_0Z7vb3dMvYJ62jEwg8odDkTCYHT0HwjvQwlqEb8FYeA1jZjPDZBGLEATyZk7rdEu)
jms 1 ToString=PVQueue: weblogic.jms.common.DestinationImpl:SystemModule-0!Queue-0 Name=PVQueue Classname=weblogic.jms.common.DestinationImpl getObject=SystemModule-0!Queue-0
jms 2 ToString=PVConnectionFactory: weblogic.jms.client.JMSXAConnectionFactory:weblogic.jms.client.JMSXAConnectionFactory@1a31048 Name=PVConnectionFactory Classname=weblogic.jms.client.JMSXAConnectionFactory getObject=weblogic.jms.client.JMSXAConnectionFactory@1a31048
jms 3 ToString=PVConnectionFactoryLocal: weblogic.jms.client.JMSXAConnectionFactory:weblogic.jms.client.JMSXAConnectionFactory@10414e6 Name=PVConnectionFactoryLocal Classname=weblogic.jms.client.JMSXAConnectionFactory getObject=weblogic.jms.client.JMSXAConnectionFactory@10414e6



(I have a stateless EJB "PVStateless" in the same module , implementing a PVStatelessRemote interface.... plus a JMS queue "PVQueue" with JNDI name "jms/PVQueue" and a JMS CF "PVConnectionFactory" with JNDI name "jms/PVConnectionFactory"....

Interesting javadoc http://docs.oracle.com/javase/7/docs/api/javax/naming/Binding.html and http://docs.oracle.com/javase/7/docs/api/javax/naming/InitialContext.html

Lync copy and paste nightmare

$
0
0
Very unfortunately I have to use Lync as a chat platform. Some stuff is pretty cool, but there are 2 TERRIBLE issues:

one is that you select some text (ANY text), copy and paste (in any way you want) and what you paste is A BIG MESS including stuff who is miles away from your selection. I ended up ALWAYS pasting first into notepad, then selectin again only the stuff I need.

the other is that it's TERRIBLY slow (tens of seconds) at delivering messages....somethines you get the notification that you got a message (often showing the WRONG username as author), then you have to wait patiently many seconds to get the text.

On the whole, I would rather have a less feature-rich chat, but more reliable and fast. This is typical Microsoft product, overloaded with features but clumsy and slow and full of bugs.

no more stinky cmd prompt in Windows: use cmder instead!

installing WLS 12.2.1 on Linux RHEL 6.5

$
0
0
Download the generic installer fmw_12.2.1.0.0_wls.jar from http://www.oracle.com/technetwork/middleware/fusion-middleware/downloads/index.html and put into /opt/install/
Download Java 8 JDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
install this one:
http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-x64.rpm


rpm -i jdk-8u65-linux-x64.rpm

you should now find /usr/java/jdk1.8.0_65/bin/java


groupadd oracle
useradd oracle -g oracle
su - oracle
/usr/java/jdk1.8.0_65/bin/java -jar /tmp/fmw_12.2.1.0.0_wls.jar
#this fails because I don't have X11, so I have to do silent installation

vi installfmw.rsp


(see here for sample response files for WLS 12.2.1)



[ENGINE]

#DO NOT CHANGE THIS.
Response File Version=1.0.0.0.0

[GENERIC]

#The oracle home location. This can be an existing Oracle Home or a new Oracle Home
ORACLE_HOME=/opt/oracle/fmw

#Set this variable value to the Installation Type selected. e.g. Fusion Middleware Infrastructure, Fusion Middleware Infrastructure With Examples.
INSTALL_TYPE=WebLogic Server

#Provide the My Oracle Support Username. If you wish to ignore Oracle Configuration Manager configuration provide empty string for user name.
MYORACLESUPPORT_USERNAME=

#Provide the My Oracle Support Password
MYORACLESUPPORT_PASSWORD=

#Set this to true if you wish to decline the security updates. Setting this to true and providing empty string for My Oracle Support username will ignore the Oracle Configuration Manager configuration
DECLINE_SECURITY_UPDATES=true

#Set this to true if My Oracle Support Password is specified
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false

#Provide the Proxy Host
PROXY_HOST=

#Provide the Proxy Port
PROXY_PORT=

#Provide the Proxy Username
PROXY_USER=

#Provide the Proxy Password
PROXY_PWD=

#Type String (URL format) Indicates the OCM Repeater URL which should be of the format [scheme[Http/Https]]://[repeater host]:[repeater port]
COLLECTOR_SUPPORTHUB_URL=



as root:

vi /etc/oraInst.loc

inventory_loc=/opt/oracle/inventory
inst_group=oinstall


chmod 777 /etc/oraInst.loc

mkdir -p /opt/oracle/inventory
chown oracle:oinstall /opt/oracle/inventory
mkdir /opt/oracle/fmw
chown oracle:oinstall /opt/oracle/fmw

su - oracle

/usr/java/jdk1.8.0_65/bin/java -jar /opt/install/fmw_12.2.1.0.0_wls.jar -silent -responseFile /cs/oracle/data/installfmw.rsp -invPtrLoc /etc/oraInst.loc


javax.transaction.SystemException: SubCoordinator not available

$
0
0
If you see this "javax.transaction.SystemException: SubCoordinator not available" in the logs, AND you have recently moved your domain to new servers, it could very well be that you need to purge your TLOG DB tables (of file store).. in fact, IP address of previous servers is still hardcoded in the TLOG info, so those TX will still linger around failing recovery until the Abandon Timeout is hit (read the "Moving the Server" chapter here http://docs.oracle.com/cd/E24329_01/web.1211/e24377/trxman.htm#WLJTA176" the server identity may no longer match the information stored in the transaction logs"

Getting started with JSF and CDI

$
0
0
I have followed this tutorial http://reka-neva.blogspot.ch/2014/08/weblogic-jsf-2-tutorial.html
Clone this git repo https://github.com/vernetto/JSFWeb.git . It's an Eclipse 4.3 OEPE for WLS 12.1.3 project.

Deploy the application to a running WLS and test with http://localhost:7001/JSFWeb

You can login using this username/pw: ADMIN/password



The Java code uses the annotations
javax.enterprise.context.SessionScoped
javax.enterprise.inject.Model
javax.inject.Inject
javax.enterprise.inject.Produces

PS in October 2015, 70 Palestinians (including many children and infants) have been cold-blooded killed by Israeli soldiers and some 2500 injured. Have you read this in the news? No? I am not surprised!

Book: Pro JSF and HTML5

$
0
0


The book does a very good job at explaining the intricate history and structure of JSF framework, particularly regarding the CDI aspects. So definitely I would recommend it as an introduction to JSF.

However, I shake in terror at the idea of having to use JSF to develop font end application. The whole EL stuff reminds me of the days I have wasted trying to make JSTL tag library code work which fails silently... and JEE CDI seems to me another "magic under the hood" that becomes quite impossible to debug once anything goes wrong.

Besides, any attempt to write anything dynamic in a XML-like fashion should be straight away punished with 25 lashes on the back bottom. And any attempt to build complex expressions in a xhtml page using a combination of {, #, :, . , not validated by a compiler, is bound only to waste your life troubleshooting.

So, the learning curve is steep and the ways you can break the structure and waste days without any progress, infinite. It's a pity that frameworks like Vaadin don't get much attention and investment from big companies...

IMHO the root issue is that anybody with 2 hands and without at least a PhD in Mathematics can hack together a makeshift framework - glue, duct tape and some strings - and, if he hits the right market at the right time, find people who adopt it - for lack of a better alternative.

JProfiler: Ingo Kegel man of the year

$
0
0
I was looking for training material on JProfiler and I found some 15 videos on youtube created by Ingo Kegel. He is really very professional! Thanks a lot Ingo! Ingo for President!
















Limiting concurrent MDB pumping messages from a JMS (or MQ) queue (throttle)

Java Mission Control JMC with Java 7 u79

$
0
0
jmc is installed OOTB with this jmc.ini file:


-startup
../lib/missioncontrol/plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
../lib/missioncontrol/plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20141007-2033
--launcher.appendVmargs
-vm
../jre/bin/
-vmargs
-XX:+UseG1GC
-XX:+UnlockCommercialFeatures
-XX:+FlightRecorder
-XX:FlightRecorderOptions=defaultrecording=true
-Djava.net.preferIPv4Stack=true


unfortunately it doesn't discover my local JVM (run with a JDK java!)

I get this error message:



"no local (attachable) JVM were detected". The JMC help says:

Why does Java Mission Control fail to find any local JVMs?
Consider the following:

•Make sure that you are using JAVA_HOME/bin/jmc to start the JMC client.


•If you are running JMC from Eclipse, make sure that Eclipse is running on a JDK (not JRE).


•Make sure that there is a directory named hsperfdata_username in the system's tmp directory, that it is writable by the user running JMC, and that the file system supports access control lists (ACLs).



First in the jmc.ini file I change ../jre/bin/ into C:\pierre\Java\jdk1.7.0_79\bin, then I select the C:\temp\hsperfdata_pierre folder and make it R/W (it was readonly!) and give full control to everyone. This time around all works fine. So sad that I don't get a better error message from JMC.... it would have been so simple just to display me a stacktrace or something more detailed. Even running "jmc -debug" didn't help...

If zou forget to run your program under test with the JMC options "-XX:+UnlockCommercialFeatures -XX:+FlightRecorder", you get this message:

Flight Recorder features are not enabled. To enable this you need to use a Java 7u4 or later JVM started with -XX:+UnlockCommercialFeatures -XX:+FlightRecorder.

JMC: how to capture details of caught and unlogged exceptions

$
0
0
It happens occasionally that inexperienced programmers catch an exception and ignore it, or they catch it and throw another exception without reporting the full details of the root cause.

This situation turns naturally in an operational nightmare.

But Java Mission Control can really help you out. Let´s run this code:

public class ThrowsException {
public static void main(String[] args) {
while (true) {
try {
Thread.sleep(1000);
throw new Exception("ciao bella gioia");
}
catch (Throwable t) {
}
}
}
}


I run the JMC flight recorder, then go to the Code/Exceptions tab and this is what I get:


SCAN and REDIRECT with Oracle RAC

$
0
0
If you access a ORACLE RAC, be aware that you must open a firewall rule not only for the SCAN listener, but also to all the RAC instances. Connections are NOT routed via the SCAN listeners, they are merely client-side redirected.

Failure to do so will result in the connection fail with a Socket Timeout Exception. You will be puzzled because the telnet to the listener works... the problem is that your JDBC driver is trying to connect ALSO to the instance on a different IP (possibly also PORT...).... so you should test with telnet also the RAC instance!

import java.sql.DriverManager;
import java.sql.SQLException;

public class DBPing {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("length " + args.length);
String user = args[0];
String password = args[1];
String url = args[2];
String now = new java.util.Date().toString();
System.out.println(now + " user= " + user + " password=" + password + " url=" + url);
java.sql.Connection conn = DriverManager.getConnection(url, user, password);
System.out.println("ok");
}
}


java -cp /acme/appsrv/bin/wl12.1a/oracle_common/modules/oracle.jdbc_12.1.0/ojdbc6.jar:/home/userpippo DBPing dbusername dbpassword "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhostname-scan)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=myservicename)))"&^

The program will wait for connection for a while, then timeout. If you netstat BEFORE the timeout:

netstat -an | grep 1522

you will discover which IP corresponds to the RAC INSTANCE:

tcp 0 1 10.11.12.13:59482 44.55.66.222:1522 SYN_SENT

What is 44.55.66.222 ? It's NOT the dbhostname-scan IP, but rather the IP of a RAC instance.... the SCAN listener tells the Oracle JDBC driver to do a redirect to a new IP/PORT where the RAC instance is running.

What is SYN_SENT ? http://serverfault.com/questions/328361/tcptrack-shows-syn-sent-connections-does-that-mean-the-syn-package-reached-the .... which means that the JDBC driver sent a SYN, but the server didn't reply (because the firewall blocked the communication).

Here some doc on SCAN.
See also Oracle Support note "Port 1521 Open on Firewall But Unable to Connect Due to Errors: ORA-12535,TNS-12203 (Doc ID 361284.1)"

WLS 12.2.1 QUICK installer ignores response file

$
0
0
I was trying to install fmw_12.2.1.0.0_wls_quick.jar using the usual command line:
/usr/java/jdk1.8.0_65/bin/java -jar /opt/install/fmw_12.2.1.0.0_wls_quick.jar -silent -logLevel finest -debug -responseFile /opt/install/installfmw1221.rsp -invPtrLoc /etc/oraInst.loc
in vain... it would keep saying "Oracle Home not found, using default /tmp/hsperfdata_wls122/wls1221 " even if there is a variable ORACLE_HOME=/opt/oracle/fmw1221 in my response file.

Then I run "/usr/java/jdk1.8.0_65/bin/java -jar /opt/install/fmw_12.2.1.0.0_wls_quick.jar –help" and I my attention is drawn on this statement:

-responseFile
Location of the response file containing input for OUI. Ignored by quick installers.



So... the right syntax for QUICK installer is:

/usr/java/jdk1.8.0_65/bin/java -jar /opt/install/fmw_12.2.1.0.0_wls_quick.jar -silent -logLevel finest -debug ORACLE_HOME=/opt/oracle/fmw1221 -invPtrLoc /etc/oraInst.loc

Find all Java classes implementing a given interface.... reflections!

$
0
0
https://code.google.com/p/reflections/

Download the ÜBER JAR here https://code.google.com/p/reflections/downloads/detail?name=reflections-0.9.9-RC1-uberjar.jar&can=2&q=



package pierre.reflections;
import java.net.URL;
import java.util.Set;

import org.reflections.Reflections;



public class FindInterfaceImplementations {
public static void main(String[] args) {
Reflections reflections = new Reflections();
Set<URL> urls = reflections.getConfiguration().getUrls();
for (URL item : urls) {
System.out.println(item.toString());
}
Set<Class<? extends javax.enterprise.inject.spi.InjectionTargetFactory>> classes = reflections.getSubTypesOf(javax.enterprise.inject.spi.InjectionTargetFactory.class);
System.out.println(classes.size());
}

}



java.lang.ArrayStoreException

$
0
0
When creating an array, remember that it will be not of the type declared for the variable, but of the type decided in the initializer:



public class ArrayStoreExceptinTest {
public static void main(String[] args) {
System.out.println("starting");

// test 1: all ok

Object[] myarray1 = new Object[2];
System.out.println("myarray1 " + myarray1.getClass().getName());
myarray1[0] = new Integer(0);
myarray1[1] = new String("");
myarray1[1] = new Integer(0);

// test 2: fails with java.lang.ArrayStoreException
try {
Object[] myarray2 = new String[2];
System.out.println("myarray2 " + myarray2.getClass().getName());
myarray2[0] = new Integer(0);
} catch (Exception e) {
e.printStackTrace();
}

// test 3: all ok
Animal[] myarray3 = new Animal[] { new Cat(), new Dog() };
System.out.println("myarray3 " + myarray3.getClass().getName());
myarray3[0] = new Dog();

try {
// test 4: fails with java.lang.ArrayStoreException
Animal[] myarray4 = new Cat[] { new Cat(), new Cat() };
System.out.println("myarray4 " + myarray4.getClass().getName());
myarray4[0] = new Dog();
} catch (Exception e) {
e.printStackTrace();
}

}
}

interface Animal {

}

class Dog implements Animal {

}

class Cat implements Animal {

}



this is the output:


starting
myarray1 [Ljava.lang.Object;
myarray2 [Ljava.lang.String;
java.lang.ArrayStoreException: java.lang.Integer
at ArrayStoreExceptinTest.main(ArrayStoreExceptinTest.java:18)
myarray3 [LAnimal;
myarray4 [LCat;
java.lang.ArrayStoreException: Dog
at ArrayStoreExceptinTest.main(ArrayStoreExceptinTest.java:32)



so if you initialize an Animal[] as a Cat[], you can't assign to a member a variable of type Dog, even if a Dog is an Animal...

Debugging SSL with javax.net.debug=all

$
0
0
This is a guide to interpreting the output of -Djavax.net.debug=all:
https://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/ReadDebug.html
and this is what I get
https://gist.github.com/vernetto/4b5c1e5b9562143998e0
by running this code with args[0]=www.usps.com (code courtesy of the excellent book "Java Network Programming, 4th Edition" that I highly recommend reading)




import java.io.*;
import javax.net.ssl.*;

public class HTTPSClient {

public static void main(String[] args) {

if (args.length == 0) {
System.out.println("Usage: java HTTPSClient2 host");
return;
}

int port = 443; // default https port
String host = args[0];

SSLSocketFactory factory
= (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = null;
try {
socket = (SSLSocket) factory.createSocket(host, port);

// enable all the suites
String[] supported = socket.getSupportedCipherSuites();
socket.setEnabledCipherSuites(supported);

Writer out = new OutputStreamWriter(socket.getOutputStream(), "UTF-8");
// https requires the full URL in the GET line
out.write("GET http://" + host + "/ HTTP/1.1\r\n");
out.write("Host: " + host + "\r\n");
out.write("\r\n");
out.flush();

// read response
BufferedReader in = new BufferedReader(
new InputStreamReader(socket.getInputStream()));

// read the header
String s;
while (!(s = in.readLine()).equals("")) {
System.out.println(s);
}
System.out.println();

// read the length
String contentLength = in.readLine();
int length = Integer.MAX_VALUE;
try {
length = Integer.parseInt(contentLength.trim(), 16);
} catch (NumberFormatException ex) {
// This server doesn't send the content-length
// in the first line of the response body
}
System.out.println(contentLength);

int c;
int i = 0;
while ((c = in.read()) != -1 && i++ < length) {
System.out.write(c);
}

System.out.println();
} catch (IOException ex) {
System.err.println(ex);
} finally {
try {
if (socket != null) socket.close();
} catch (IOException e) {}
}
}
}



Viewing all 1124 articles
Browse latest View live