C3750X TrustSec problem
Hi,
I've configured 2 C3750X with SM for working together via vieber (switches in differents cities). I've used configurations from cisco guides. I'm using cts man command with/without cts cred. And it never works. Always I get this logs (and ports protocol go down when I put sap pmk options):
Feb 26 12:01:36.031: Conflicting CLI: CTS and Macsec are not allowed together
Feb 26 11:55:28.325: MACsec-CTS: macsec_cts_sap_session_stop Received SAP session STOP oninterface(GigabitEthernet1/1/2), clean up the SCs
Feb 26 11:55:28.325: MACsec API blocking the invoking context
Feb 26 11:55:28.325: HULC-MACsec: Entering macsec_req_local_handler req 64E8874:
Feb 26 11:55:28.325: HULC-MACsec: macsec_process_req : Req type: 3
Feb 26 11:55:28.325: HULC-MACsec: Process delete RxSC i/f GigabitEthernet1/1/2 SCI 6400F155F2440000
Feb 26 11:55:28.325: HULC-MACsec: RxSC not found (6400F155F2440000)
Feb 26 11:55:28.325: HULC-MACsec: Invoking the callback for req 64E8874
Feb 26 11:55:28.325: macsec_blocking_callback
Feb 26 11:55:28.325: MACSEC_ERROR returned
Feb 26 11:55:28.325: Wake up the blocking process
Feb 26 11:55:28.325: MACsec API blocking the invoking context
Feb 26 11:55:28.325: HULC-MACsec: Entering macsec_req_local_handler req 64E8874:
Feb 26 11:55:28.325: HULC-MACsec: macsec_process_req : Req type: 1
Feb 26 11:55:28.325: HULC-MACsec: Process delete TxSC i/f GigabitEthernet1/1/2 SCI C89C1DE222440000
Feb 26 11:55:28.325: HULC-MACsec: TxSC not found
Feb 26 11:55:28.325: HULC-MACsec: Invoking the callback for req 64E8874
Feb 26 11:55:28.325: macsec_blocking_callback
Feb 26 11:55:28.325: MACSEC_ERROR returned
Feb 26 11:55:28.325: Wake up the blocking process
Feb 26 11:55:28.518: Hulc MACsec: No H/W Subblock
Feb 26 11:55:28.518: Hulc:Destroying the macsec subblock
Feb 26 11:55:28.551: Event notification 2
Feb 26 11:55:28.551: Received-AN: 0, Received-SCI: 0
Feb 26 11:55:28.551: Hulc MACsec: Notify port disabled event
What can be wrong or what I have to do to set up TrustSec between two 3750X?
Hi,
I'm trying to determine if the issue addressed in this post is a match with the following symptom:
As you can see from the output below - the switch 2 power supplies appear to be healthy:
SWITCH#show env power switch 1
SW PID Serial# Status Sys Pwr PoE Pwr Watts
1A C3KX-PWR-350WAC AZS161707F3 OK Good Good 350/0
1B C3KX-PWR-715WAC LIT16180RRU OK Good Good 715/0
SWITCH#show env power switch 2
SW PID Serial# Status Sys Pwr PoE Pwr Watts
2A C3KX-PWR-715WAC LIT16180RRY OK Good Good 715/0
2B C3KX-PWR-350WAC AZS161707FZ OK Good Good 350/0
Yet, the snmpwalk output shows a Sw2 PS2 power supply fault:
snmpwalk -v1 X.X.X.X -c READONLY .1.3.6.1.4.1.9.9.13.1.5.1
SNMPv2-SMI::enterprises.9.9.13.1.5.1.2.1035 = STRING: "Sw1, PS1 Normal, RPS NotExist"
SNMPv2-SMI::enterprises.9.9.13.1.5.1.2.1036 = STRING: "Sw1, PS2 Normal, RPS NotExist"
SNMPv2-SMI::enterprises.9.9.13.1.5.1.2.2034 = STRING: "Sw2, PS1 Normal, RPS NotExist"
SNMPv2-SMI::enterprises.9.9.13.1.5.1.2.2035 = STRING: "Sw2, PS2 Faulty, RPS NotExist"
Do my symptoms match with the issue addressed in this post ?
TIA,
Amir
Similar Messages
-
C3750X - Power supply OIDs problems
Hello,
We are trying to monitor two stacks of CISCO WS-c3750X running IOS 12.2.(58)SE.
We can get the state of the power supplies, but after a power cycle or reboot of the switches the identifier of ONE of the Power supplies ALWAYS change. The OIDs for the rest of the PS do not vary. The problem happens in the two stacks.
Any idea or work around?
Kind regards
MarkHi,
I'm trying to determine if the issue addressed in this post is a match with the following symptom:
As you can see from the output below - the switch 2 power supplies appear to be healthy:
SWITCH#show env power switch 1
SW PID Serial# Status Sys Pwr PoE Pwr Watts
1A C3KX-PWR-350WAC AZS161707F3 OK Good Good 350/0
1B C3KX-PWR-715WAC LIT16180RRU OK Good Good 715/0
SWITCH#show env power switch 2
SW PID Serial# Status Sys Pwr PoE Pwr Watts
2A C3KX-PWR-715WAC LIT16180RRY OK Good Good 715/0
2B C3KX-PWR-350WAC AZS161707FZ OK Good Good 350/0
Yet, the snmpwalk output shows a Sw2 PS2 power supply fault:
snmpwalk -v1 X.X.X.X -c READONLY .1.3.6.1.4.1.9.9.13.1.5.1
SNMPv2-SMI::enterprises.9.9.13.1.5.1.2.1035 = STRING: "Sw1, PS1 Normal, RPS NotExist"
SNMPv2-SMI::enterprises.9.9.13.1.5.1.2.1036 = STRING: "Sw1, PS2 Normal, RPS NotExist"
SNMPv2-SMI::enterprises.9.9.13.1.5.1.2.2034 = STRING: "Sw2, PS1 Normal, RPS NotExist"
SNMPv2-SMI::enterprises.9.9.13.1.5.1.2.2035 = STRING: "Sw2, PS2 Faulty, RPS NotExist"
Do my symptoms match with the issue addressed in this post ?
TIA,
Amir -
Cisco WS-C3750X-24 policy-map problem
In our organization we have a cisco ws.c3750X-24 switch. we are using policy maps to restrict bandwidth in 3750x but if we edit or add new policys other policys are not working.
can you please share config?
-
Front end and console ports are down for switch WS-C3750X-48PF-S
We have a switch WS-C3750X-48PF-S in the stack and front end and console ports stopped working and are down.
I have tried to replug power cable but this didn't help, please let me know if I could replug stack power for this switch without outage of other switches in the stack, since switches are connected into the ring
Please let me know what might be the possible root cause
#sh switch stack-ports
Switch # Port 1 Port 2
2 Down Ok
3 Ok Ok
4 Ok DownHello,
There is a problem with the stacking connection between switch 4 and 2. Can you try replacing the stacking cable between these switches? -
I've ISE v1.1.2.145 and Cat 6500 IOS ADVENTERPRISEK9-M, Version 15.0(1)SY2
I'm trying to add 6500 in the trustsec group with ISE and followed the trustsec 2.1 documentation. After configuring it keeps on giving me error in the ISE logs below with the subject #CTSREQUEST#
11302 Received Secure RADIUS request without a cts-pac-opaque cisco-av-pair attribute
Below are the steps:
11001 Received RADIUS Access-Request
11017 RADIUS created a new session
15012 Selected Access Service - NDAC_SGT_Service
11302 Received Secure RADIUS request without a cts-pac-opaque cisco-av-pair attribute
Also after i configure cts credentials and radius-server pac command in 6500, it starts giving me log messages that radius is down and the next moment it comes up again. It is continously doing that.
Thanks in advance for the help.
Regards,
ZohaibHello Zohaib,
You may find the following of help in solving the problem.
Configuring EAP-FAST Settings
http://www.cisco.com/en/US/docs/security/ise/1.1/user_guide/ise_auth_pol.html#wp1146184
Configuring Security Group Access Settings
http://www.cisco.com/en/US/docs/security/ise/1.1.1/user_guide/ise_sga_pol.html#wp1102430
Extensible Authentication Protocol-Flexible Authentication via Secure Tunneling
http://www.cisco.com/en/US/docs/security/ise/1.0/user_guide/ise10_net_acc_flows.html#wp1135510
EAP-FAST
http://www.cisco.com/en/US/prod/collateral/wireless/ps5679/ps5861/prod_qas09186a00802030dc_ps430_Products_Q_and_A_Item.html -
IP device tracking and idle timer problem
Hi,
We are deploying 802.1X in our network and have encountered problem with a type of payment terminal.
The problem is that the terminal do not 'speak' to the network after the first initial DHCP request, the terminal waits for incoming packets from a counter to start the payment process. After the idle-time the MAC is flushed from the switch and the port is not authorized any more.
To solve this we set 'authentication control-direction in' on the port and use 'ip device tracking' to keep the client on the network, ip device tracking sends an arp request every 30 seconds to clients.
Our ISE is sending Radius:Idle-Timeout = 300 and the timer start to count down when the client is authenticated.
In Wireshark, I can see that the ARP request is going out and the ARP reply coming back in but this does not update the inactivity timer for the client. So after 5 minutes the port is gone, and there is no way to get the port up again from the network. Traffic from the client brings up the network.
This looks like a bug to me, anyone seen this, or a similar behaviour?
Running:
ISE 1.2p6
IOS 12.2(55)SE6
From Trustsec 1.99 Wired 802.1X Deployment Guide:
Tip Enable IP Device Tracking with inactivity timers to keep quiet endpoints connected. When IP Device Tracking is enabled, the switch periodically sends ARP probes to endpoints in the IP Device Tracking table (which is initially populated by DHCP requests or ARP from the end point). As long as the endpoint is connected and responds to these probes, the inactivity timer is not triggered and the endpoint is not inadvertently removed from the network.
From CLI output
SW03#sh auth sessions int fa0/4
Interface: FastEthernet0/4
MAC Address: xxxx.xxxx.5289
IP Address: 10.10.10.64
User-Name: XX-XX-XX-XX-52-89
Status: Authz Success
Domain: DATA
Oper host mode: multi-auth
Oper control dir: both
Authorized By: Authentication Server
Vlan Group: N/A
Session timeout: N/A
Idle timeout: 300s (server), Remaining: 2s
Common Session ID: 0A17BD07000000A925152A7B
Acct Session ID: 0x00000458
Handle: 0x090000A9
Runnable methods list:
Method State
dot1x Failed over
mab Authc Success
SW03#
SW03#
SW03#
SW03#sh auth sessions int fa0/4
Interface: FastEthernet0/4
MAC Address: Unknown
IP Address: Unknown
Status: Running
Domain: UNKNOWN
Oper host mode: multi-auth
Oper control dir: both
Session timeout: N/A
Idle timeout: N/A
Common Session ID: 0A17BD07000000AA251A0019
Acct Session ID: 0x00000462
Handle: 0x800000AA
Runnable methods list:
Method State
dot1x Running
mab Not runHere is the port config.
Just to clarify, everything is working except that the terminal is losing the authentication. The terminal works again if traffic is initiated from the terminals menu, like with ping.
interface FastEthernet0/4
description Standard
switchport access vlan xxx
switchport mode access
switchport block unicast
switchport voice vlan xxx
switchport port-security maximum 2
switchport port-security
switchport port-security aging time 5
switchport port-security violation restrict
priority-queue out
authentication control-direction in
authentication event fail action next-method
authentication event server dead action reinitialize vlan xxx
authentication event server dead action authorize voice
authentication event server alive action reinitialize
authentication host-mode multi-auth
authentication order dot1x mab
authentication priority dot1x mab
authentication port-control auto
authentication periodic
authentication timer reauthenticate server
authentication timer inactivity server
authentication violation restrict
mab
no snmp trap link-status
dot1x pae authenticator
dot1x timeout tx-period 5
storm-control broadcast level pps 100
storm-control multicast level pps 100
storm-control action trap
spanning-tree portfast
service-policy input users -
Hi All,
I'm having trouble figuring out exactly what I need to do for my trustec solution. I have the following topology:-
ISE 1.2
Cisco 2960-X - 2 x Cisco 7004 (each has 3 vdc - dist, core and DC) - Cisco 5548
I have configured each vdc on all the 7004s as a seed devices (probably do not need that many). All devices have been configured on ISE.
I am running SXP between the 2960-X and the distribution vdc on the 7004 - that all seems fine as my SXP devices all show as connected.
My cts environment data appears to be correct in that I am seeing all my seed devices and my SGTs are being downloaded from ISE. The cts pac is also correct. I am seeing my SGACLs being downloaded from ISE as well.
The two problems I see are:-
Unless I manually configure the sgt-map on the 7004 I do not see the mappings. I'm obviously missing something configuration wise here but for all my trolling through trustsec documents I can't find what.
When I do a show cts role-based policy I see the source and destination groups being associated but I don't see the SGACL association - for example:-
sgt:7(Student_SG)
dgt:3(Test_SG) rbacl:Deny IP
deny ip
whereas I would expect to see this SGACL:-
rbacl:Test_SGACL
permit tcp dst eq 80
permit tcp dst eq 443
deny all
All the documentation I read seems to refer to having a 6500 switch as the next hop from the access layer whereas in my case it is a Nexus 7004 and the commands for the 6500 series do not all have an equivalent on the 7004.
Basically I need to know about enforcement on the 7004.
Does anyone know of any links I can look at to try and sort out what I need to do to complete this configuration?
Thanks
AlanHi Elizabeth,
In Query Studio, do you see if there is a horizontal and vertical scrollbar inside a frame? The report output in Query Studio is displayed in a frame. Please double check to make sure you can scroll down or to the right to see other missing columns or rows that do not fit the screen.
Thanks,
Peter -
WS-C3750X-24S - FastEthernet0 question
Hello all,
I have a C3750X-24S and i configured FastEthernet0 with ip address (10.251.157.2) and 10.251.157.1 is connected to a firewall (firewall allowed any-any now). Firewall has default route to 10.251.157.2 configured.
Switch is connected to WAN router and running EIGRP.
I am able to ping to 10.251.157.1 from switch, and extended ping from other interfaces of switch to 10.251.157.1 looks fine as well.
I am able to ping to 10.251.157.2(switch) from remote location without problem as well.
But i am not able to ping to 10.251.157.1 from remote location, traceroute stop at that switch interface.
i am able to ping to 10.251.157.2 from local WAN router, but not able to ping to 10.251.157.1. Trace stop at switch as well.
Below the "eigrp", interface f0 and "sh ver" output. Kindly please help advise what went wrong. Thanks.
interface FastEthernet0
ip address 10.251.157.2 255.255.255.248
no ip route-cache cef
no ip route-cache
end
router eigrp 1
network 10.0.0.0
redistribute static
eigrp stub connected summary
switch#sh ver
Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (f
c1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2011 by Cisco Systems, Inc.
Compiled Thu 21-Jul-11 01:23 by prod_rel_team
ROM: Bootstrap program is C3750E boot loader
BOOTLDR: C3750E Boot Loader (C3750X-HBOOT-M) Version 12.2(58r)SE1, RELEASE SOFTWARE (fc1)
switch uptime is 12 weeks, 3 days, 18 hours, 42 minutes
System returned to ROM by power-on
System image file is "flash:/c3750e-universalk9-mz.122-58.SE2/c3750e-universalk9-mz.122-58.SE2.bin"
This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.
A summary of U.S. laws governing Cisco cryptographic products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html
If you require further assistance please contact us by sending email to
[email protected].
License Level: ipbase
License Type: Permanent
Next reload license Level: ipbase
cisco WS-C3750X-24S (PowerPC405) processor (revision M0) with 524288K bytes of memory.
Processor board ID FDO1828R17B
Last reset from power-on
18 Virtual Ethernet interfaces
1 FastEthernet interface
28 Gigabit Ethernet interfaces
2 Ten Gigabit Ethernet interfaces
The password-recovery mechanism is enabled.
512K bytes of flash-simulated non-volatile configuration memory.
Base ethernet MAC Address : 7C:0E:CE:4F:D4:00
Motherboard assembly number : 73-13061-06
Motherboard serial number : FDO18281DC2
Model revision number : M0
Motherboard revision number : A0
Model number : WS-C3750X-24S-S
Daughterboard assembly number : 800-32727-03
Daughterboard serial number : FDO18281FKC
System serial number : FDO1828R17B
Top Assembly Part Number : 800-33746-06
Top Assembly Revision Number : B0
Version ID : V05
CLEI Code Number : CMMP200DRA
Hardware Board Revision Number : 0x05
Switch Ports Model SW Version SW Image
* 1 30 WS-C3750X-24S 12.2(58)SE2 C3750E-UNIVERSALK9-M
Configuration register is 0xF
Regards,
ChristopherChristopher
As far as I am aware you cannot use that port for normal traffic, it is only for management.
So traffic can't be routed through the switch using that port.
Try using one of the other ports.
Jon -
Problems with LAP-1142n booting
Hi,
I recently installed about 40 LAP-1142n access points fresh out of the box in a new elementary school. All but 5 of the AP's were able to join the controller and were set to function in H-Reap mode. The AP's that didn't join seem to be stuck in the boot process and the LED is coontinuously blinking green. I can leave them in that state all night and the next day it's still blinking green. Powering it down and bringing it back up has no effect.
All AP's are connected to C3750X POE switches and the switchports are all trunked and have the native vlan set, so all 40 have identical settings. Is it possible that I have 5 that are bad out of the box or is there something that I can do to fix this problem? Has anyone seen this before?
Thanks for any help you may be able to give me.Have the cable vendor check wiring scheme and repunch down the cables at each end.
No need. The APs are connected to 3750X. To verify if you have a potential cable defect one has to run the 3750X's built-in TDR test. Works like a charm (much to the annoyance of the cable people!). -
C3750X get power supply errors
Hi, I got a problem with some phones connected to a C3750X-48PS. Phones are Polycom SoundPoint 560. Ports most critical: gig 1/0/9 & 1/0/31.
Actually, the C3750X belongs to a stack, with the IOS: 12.2(55)SE3. The environment conditions: power supply working ok, temperature level: ok. (show env all). Physically the LEDs are in green, and the room does not have temperature issues.
Also, the phones present a humming noise (high pitch). The noise keeps happening even if the phones are plugged in other ports of a stack. It was attempted to connect the phones directly to the stack ports instead of the ports in the cubicules, and the issue keeps happening.
The Stack presents also sudden fan to spin up / spin down for a couple of minutes, and within a couple of minutes from working on and off.
Customer has another facility with the same switches but with IOS12.2(55)SE1, in there the same phones were tested and they are working fine.
A reboot was performed, but now the C3750X show these messages:
%ILPOWER-3-CONTROLLER_PORT_ERR: Controller port error, Interface Gi1/0/9: Power Controller reports power Tstart error detected
%ILPOWER-3-CONTROLLER_PORT_ERR: Controller port error, Interface Gi1/0/31: Power Controller reports power Tstart error detected
Thanks!I've found it! In case anyone is wondering, a lot of server information is available by querying with the iLO xml tag "GET_EMBEDDED_HEALTH".
This returns, buried way down in the results, information about power supplies (section POWER_SUPPLIES).
While there doesn't seem to ask for just information on the power supplies, this works! -
Hello community,
I was wondering if someone can shed any light on this...
We have two buildings which we intend to connect via two different providers (probably metroethernet links). The two buildings will be on the same VTP domain (vlan extension from one building to the other - the providers will implement .1Q tunnelling). The links will be bundled, using etherchannel on 4507 switches - one on each location.
In order to encrypt traffic we were thinking of implementing trustsec between the two switches. As I understand trustsec can only be configured on physical interfaces. As stated above we want to use etherchannel. Is that a problem?
Since the providers' switches are in the physical path between the two sites, do those too fall into the equation? Do they have to be macsec capable or since the traffic will be already encapsulated (.1Q tunneling) they don't care?
Any ideas will be really helpful!
Thank you in advance,
KaterinaMacSec operates on a hop-by-hop basis, therefore in order to implement macsec all the equipment in the path must be managed by us.
So, since we will be going through the providers' metroethernet, macsec seems to be out of the question.
VPLS must be the answer! -
I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
Thank you in advance,
LeftyThis was one solution from the socket programming forum, have you tried this??
public Thread MyThread extends Thread{
boolean active = true;
public void run(){
ss.setSoTimeout(90);
while (active){
try{
serverSocket = ss.accept();
catch (SocketTimeoutException ste){
// do nothing
// interrupt thread
public void deactivate(){
active = false;
// you gotta sleep for a time longer than the
// accept() timeout to make sure that timeout is finished.
try{
sleep(91);
}catch (InterruptedException ie){
interrupt();
} -
A problem with Threads and MMapi
I am tring to execute a class based on Game canvas.
The problem begin when I try to Play both a MIDI tone and to run an infinit Thread loop.
The MIDI tone "Stammers".
How to over come the problem?
Thanks in advance
Kobi
See Code example below:
import java.io.IOException;
import java.io.InputStream;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
public class MainScreenCanvas extends GameCanvas implements Runnable {
private MainMIDlet parent;
private boolean mTrucking = false;
Image imgBackgound = null;
int imgBackgoundX = 0, imgBackgoundY = 0;
Player player;
public MainScreenCanvas(MainMIDlet parent)
super(true);
this.parent = parent;
try
imgBackgound = Image.createImage("/images/area03_bkg0.png");
imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
imgBackgoundY = this.getHeight() - imgBackgound.getHeight();
catch(Exception e)
System.out.println(e.getMessage());
* starts thread
public void start()
mTrucking = true;
Thread t = new Thread(this);
t.start();
* stops thread
public void stop()
mTrucking = false;
public void play()
try
InputStream is = getClass().getResourceAsStream("/sounds/scale.mid");
player = Manager.createPlayer(is, "audio/midi");
player.setLoopCount(-1);
player.prefetch();
player.start();
catch(Exception e)
System.out.println(e.getMessage());
public void run()
Graphics g = getGraphics();
play();
while (true)
tick();
input();
render(g);
* responsible for object movements
private void tick()
* response to key input
private void input()
int keyStates = getKeyStates();
if ((keyStates & LEFT_PRESSED) != 0)
imgBackgoundX++;
if (imgBackgoundX > 0)
imgBackgoundX = 0;
if ((keyStates & RIGHT_PRESSED) != 0)
imgBackgoundX--;
if (imgBackgoundX < this.getWidth() - imgBackgound.getWidth())
imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
* Responsible for the drawing
* @param g
private void render(Graphics g)
g.drawImage(imgBackgound, imgBackgoundX, imgBackgoundY, Graphics.TOP | Graphics.LEFT);
this.flushGraphics();
}You can also try to provide a greater Priority to your player thread so that it gains the CPU time when ever it needs it and don't harm the playback.
However a loop in a Thread and that to an infinite loop is one kind of very bad programming, 'cuz the loop eats up most of your CPU time which in turn adds up more delays of the execution of other tasks (just as in your case it is the playback). By witting codes bit efficiently and planning out the architectural execution flow of the app before start writing the code helps solve these kind of issues.
You can go through [this simple tutorial|http://oreilly.com/catalog/expjava/excerpt/index.html] about Basics of Java and Threads to know more about threads.
Regds,
SD
N.B. And yes there are more articles and tutorials available but much of them targets the Java SE / EE, but if you want to read them here is [another great one straight from SUN|http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html] .
Edited by: find_suvro@SDN on 7 Nov, 2008 12:00 PM -
Hi all,
I would like to ask you for a help. I need to write a small program at my university. I started to write a midlet which function would be to countdown time for sports activities. I woul like to start a new thread - the one that counts down - and at the same time make the main thread sleep. After the "countdown" thread finishes, the main thread wakes up and waits for user input. The problem is that when the "countdown" thread finishes his work, I've got Uncaught exception java/lang/NullPointerException. error and the midlet halts.
Below you can find the code
import java.lang.*;
import java.util.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class intervals extends MIDlet implements CommandListener
public Display ekran;
private SweepCanvas sweeper;
private Form rundy;
private TextField round0, round1, round2, round3, round4, round5, round6, round7, round8;
private long czas,x;
private Command exitCommand;
private Command addRound;
private Command delRound;
private Command start;
private TextField repeat;
private Form odliczanie;
private Alert ostrz;
Licznik thread;
String test;
StringItem test1;
int parz,i,j,k;
static int l;
int ilrund;
int ilpowt;
Item sec;
long sec1;
public intervals()
rundy = new Form("Interwały sportowe");
exitCommand = new Command("Wyjście", Command.EXIT, 2);
addRound = new Command("Dodaj","Dodaj rundę", Command.ITEM,1);
delRound = new Command("Usuń","Usuń ostatnią rundę", Command.ITEM,1);
start = new Command("Start", Command.ITEM,1);
odliczanie = new Form("Odliczanie");
TextField dodaj(TextField kolej)
kolej=new TextField("Podaj czas (s) rundy "+parz,null, 4, TextField.NUMERIC);//stworzenie nowej instancji do wybierania czasu trwania rundy
if(rundy.size()==0)
rundy.insert(rundy.size(),kolej);
else
rundy.insert(rundy.size()-1, kolej);
return kolej;
void odliczanie(TextField round)
monitor m=new monitor();
k=Integer.parseInt(round.getString());
ekran.setCurrent(odliczanie);
thread=new Licznik(k,odliczanie);
thread.start();
ekran.setCurrent(rundy);
public void startApp()// throws MIDletStateChangeException
rundy.deleteAll();
repeat = new TextField("Podaj ilość powtórzeń",null,1,TextField.NUMERIC);
rundy.addCommand(addRound);
rundy.addCommand(exitCommand);
rundy.setCommandListener(this);
Canvas obrazek = new MyCanvas();
ekran = Display.getDisplay(this);
ekran.setCurrent(obrazek);
czas=System.currentTimeMillis();
while (System.currentTimeMillis()<czas+1000)
continue;
ekran.setCurrent(rundy);
public void pauseApp()
public void destroyApp(boolean unconditional)
notifyDestroyed();
public void commandAction(Command c, Displayable s)
if (c == exitCommand)
destroyApp(false);
notifyDestroyed();
else if(c==addRound)
if(rundy.size()==0)//Sprawdzenie ilości elementów w celu poprawnego wyświetlania liczby rund w formie
parz=1;
else
parz=rundy.size();
switch(parz)
case 1:
round0=dodaj(round0);break;
case 2:
round1=dodaj(round1);break;
case 3:
round2= dodaj(round2);break;
case 4:
round3=dodaj(round3);break;
case 5:
round4=dodaj(round4);break;
default:
ostrz=new Alert("Uwaga","Maksymalna liczba rund wynosi 9", null, AlertType.INFO);
ostrz.setTimeout(3000);
ekran.setCurrent(ostrz);
if(rundy.size()==1)
rundy.append(repeat);
rundy.addCommand(start);
rundy.addCommand(delRound);
else if(c==delRound)
if(rundy.size()!=0)
rundy.delete(rundy.size()-2);
if (rundy.size()==1)
rundy.deleteAll();
if(rundy.size()==0)
rundy.removeCommand(delRound);
rundy.removeCommand(start);
else if(c==start)
ilrund=rundy.size()-1;
if(this.repeat.size()>0)
ilpowt=Integer.parseInt(this.repeat.getString());
ekran = Display.getDisplay(this);
for (i=1; i<=ilpowt;i++)
odliczanie= new Form("Odliczanie");
for (j=0;j<ilrund;j++)
switch(j)
case 0:
odliczanie(round0);
break;
case 1:
odliczanie(round1);
break;
case 2:
odliczanie(round2);
break;
case 3:
odliczanie(round3);
break;
case 4:
odliczanie(round4);
break;
case 5:
odliczanie(round5);
break;
case 6:
odliczanie(round6);
break;
case 7:
odliczanie(round7);
break;
case 8:
odliczanie(round8);
break;
class Licznik extends Thread
int czas1,k;
Form forma;
monitor m;
public Licznik(int k,Form formap)
czas1=k;
forma=formap;
public synchronized void run()
while(czas1>0)
forma.deleteAll();
forma.append("Czas pozostały (s): "+czas1);
try{Thread.sleep(1000);} catch(InterruptedException e){e.printStackTrace();}
czas1--;
if(czas1<=0)
m.put();
}and monitor class
public class monitor
boolean busy=false;
synchronized void get()
if(!busy)
try
wait();
}catch(InterruptedException e){e.printStackTrace();}
notify();
synchronized void put()
if(busy)
try
wait();
}catch(InterruptedException e){e.printStackTrace();}
busy=true;
notify();
}Can anybody help me with this?Groovemaker,
Your Licznik class has a member m of type monitor, which has not been instantiated (in other words is null) hence, when calling m.put() you get NullPointerException. Please also mind, that using Thread.sleep(1000) is not an accurate way of measuring time.
If I may, please use recommended for Java class naming conventions - some of your names use lower case, while other don't which is confusing to the reader.
Daniel -
Problem with threads within applet
Hello,
I got an applet, inside this applet I have a singleton, inside this singleton I have a thread.
this thread is running in endless loop.
he is doing something and go to sleep on and on.
the problem is,
when I refresh my IE6 browser I see more than 1 thread.
for debug matter, I did the following things:
inside the thread, sysout every time he goes to sleep.
sysout in the singleton constructor.
sysout in the singleton destructor.
the output goes like this:
when refresh the page, the singleton constructor loading but not every refresh, sometimes I see the constructor output and sometimes I dont.
The thread inside the singleton is giving me the same output, sometime I see more than one thread at a time and sometimes I dont.
The destructor never works (no output there).
I don't understand what is going on.
someone can please shed some light?
thanks.
btw. I am working with JRE 1.1
this is very old and big applet and I can't convert it to something new.Ooops. sorry!
I did.
public void start() {
public void stop() {
public void destroy() {
try {
resetAll();
Configuration.closeConnection();
QuoteItem.closeConnection();
} finally {
try {
super.finalize();
} catch (Throwable e) {
e.printStackTrace();
}
Maybe you are looking for
-
How do I Delete an iTunes U Site?
Does anyone know how to delete an iTunes U Site? We are looking to create a new account.
-
Imbedding sound files in documents
I want to embed mp3 sound files inside a document and be able to share it as a pdf document or other generally available format. Text Edit can accept mp3 files, and a little player bar appears, but Text Edit is not able to 'print' them as PDFs with t
-
Accounting entry GL accoutns for excise invoice
Hi, When we capture and post the excise invoice in J1IEX or MIGO the account which are updated are the excise account as per setting in excise account table in SPRO CIN for transaction GRPO and the cenvat account is as per compnay code setting in
-
I have a table, much like the one below:- A B C D E F G H I J K L M N O P Q R S John Yes Paul No Dave Jay No Matt Yes Yes Karl Lois Jane Maybe Anna Barry No Yes Maybe I want to populate a cell on another sheet with the column headers if the row cont
-
I cannot find the Pen Tool in my InDesign toolbar. Please help me.