Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Pascal Lafond

Greenhorn
+ Follow
since Jan 05, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Pascal Lafond

Your 100% right.

The | character means OR in a java pattern and you need to escape it. The pattern "|" that I used looked for an empty string OR an empty string.

"\\|" is the proper pattern to look for the | character.

Thanks
15 years ago
I have strings which use the following seperator |

If I split using "|" I get a string array with one cell for every character. If I use a different character (regex) it works. Does anyone know why? Does the | character have a special meaning in the String.

Below is sample code and output explaining the issue. Note: This uses Java1.5.

class test
{
public static void main(String[] args)
{
int i;
String s1 = "Hello| Wo|rld!";

String[] sArray1 = s1.split("|");
String[] sArray2 = s1.split("o");

System.out.println("s1 = " + s1);
System.out.println("s1.split(\"|\")");
System.out.println("sArray1.length = " + sArray1.length);

for (i = 0 ; i < sArray1.length; i++)
{
System.out.println("sArray1[" + i + "] = " + sArray1[i]);
}

System.out.println();
System.out.println("s1.split(\"o\")");
System.out.println("sArray2.length = " + sArray2.length);
for (i = 0 ; i < sArray2.length; i++)
{
System.out.println("sArray2[" + i + "] = " + sArray2[i]);
}


}
}


// Output
---------- Run ----------
s1 = Hello| Wo|rld!
s1.split("|")
sArray1.length = 15
sArray1[0] =
sArray1[1] = H
sArray1[2] = e
sArray1[3] = l
sArray1[4] = l
sArray1[5] = o
sArray1[6] = |
sArray1[7] =
sArray1[8] = W
sArray1[9] = o
sArray1[10] = |
sArray1[11] = r
sArray1[12] = l
sArray1[13] = d
sArray1[14] = !

s1.split("o")
sArray2.length = 3
sArray2[0] = Hell
sArray2[1] = | W
sArray2[2] = |rld!

Output completed (0 sec consumed) - Normal Termination
15 years ago
Uhhh... I just read the spec for ejbCreate page 192 and it says MUST

"The throws clause must define the javax.ejb.CreateException. The throws clause may define arbitrary application specific exceptions."

The ejbPostCreate says MAY again p192 in ejb
One month ago on my old desktop I got everything running without a hitch using a version of SDK1.4 and J2EE 1.3.1 on XP. I followed the books instructions to the letter and everything worked.

Now on my brand new machine things are not going very well.
Setup is
WinXP, j2sdkee1.3.1 and jdk1.3.1_17 (as posted on https://coderanch.com/t/160071/java-EJB-SCBCD/certification/Sun-RI-NoClassDefFoundError by Jonny Andersson)
I also tried using j2sdk1.4.2_04 but received the exact same result.

My environment variables are as follows
J2EE_HOME=C:\j2sdkee1.3.1
JAVA_HOME=C:\jdk1.3.1_17
CLASSPATH=%J2EE_HOME%\lib\j2ee.jar
PATH=<..long path stuff..>;%JAVA_HOME%\bin;%J2EE_HOME%\bin


Everything works up to page 58 where we run the Advice client and I get the following error.

C:\work\Cert\advice>java -classpath %CLASSPATH%;.\AdviceAppClient.jar;. AdviceClient
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/corba/se/internal/util/JDKBridge
at com.sun.corba.ee.internal.core.IOR$LocalCodeBaseSingletonHolder.<clin
it>(IOR.java:90)
at com.sun.corba.ee.internal.core.IOR.<init>(IOR.java:238)
at com.sun.corba.ee.internal.iiop.messages.LocateReplyMessage_1_2.read(L
ocateReplyMessage_1_2.java:137)
at com.sun.corba.ee.internal.iiop.IIOPInputStream.unmarshalHeader(IIOPInputStream.java:126)
at com.sun.corba.ee.internal.iiop.IIOPConnection.getResponse(IIOPConnection.java:671)
at com.sun.corba.ee.internal.iiop.IIOPConnection.send(IIOPConnection.java:778)
at com.sun.corba.ee.internal.corba.InitialNamingClient.locateObject(InitialNamingClient.java:786)
at com.sun.corba.ee.internal.corba.InitialNamingClient.getIORUsingHostIn
fo(InitialNamingClient.java:597)
at com.sun.corba.ee.internal.corba.InitialNamingClient.resolveCorbaloc(I
nitialNamingClient.java:573)
at com.sun.corba.ee.internal.corba.InitialNamingClient.resolveUsingORBIn
itRef(InitialNamingClient.java:544)
at com.sun.corba.ee.internal.corba.InitialNamingClient.cachedInitialRefe
rences(InitialNamingClient.java:1080)
at com.sun.corba.ee.internal.corba.InitialNamingClient.resolve_initial_r
eferences(InitialNamingClient.java:981)
at com.sun.corba.ee.internal.corba.ORB.resolve_initial_references(ORB.ja
va:2425)
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.jav
a:52)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120
)
at javax.naming.InitialContext.lookup(Unknown Source)
at AdviceClient.go(AdviceClient.java:29)
at AdviceClient.main(AdviceClient.java:15)

I also tried to add the following code in my AdviceClient as sugested by Roger Cavallo in https://coderanch.com/t/160436/java-EJB-SCBCD/certification/Almost-have-AdviceClient-run-but.

It compiled but I got 23 a different error when run.

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:3700");
Context ic= new InitialContext(env);
Object o = ic.lookup("Advisor");


Help would be appreciated. I guess I won't try any of the deployment code for now and just keep reading.